OLD | NEW |
1 # Copyright 2012 The Chromium Authors. All rights reserved. | 1 # Copyright 2012 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 import os | 4 import os |
5 import sys | 5 import sys |
6 | 6 |
7 | 7 |
8 def _CommonChecks(input_api, output_api): | 8 def _CommonChecks(input_api, output_api): |
9 results = [] | 9 results = [] |
10 | 10 |
11 # TODO(nduca): This should call update_docs.IsUpdateDocsNeeded(). | 11 # TODO(nduca): This should call update_docs.IsUpdateDocsNeeded(). |
12 # Disabled due to crbug.com/255326. | 12 # Disabled due to crbug.com/255326. |
13 if False: | 13 if False: |
14 update_docs_path = os.path.join( | 14 update_docs_path = os.path.join( |
15 input_api.PresubmitLocalPath(), 'update_docs') | 15 input_api.PresubmitLocalPath(), 'update_docs') |
16 assert os.path.exists(update_docs_path) | 16 assert os.path.exists(update_docs_path) |
17 results.append(output_api.PresubmitError( | 17 results.append(output_api.PresubmitError( |
18 'Docs are stale. Please run:\n' + | 18 'Docs are stale. Please run:\n' + |
19 '$ %s' % os.path.abspath(update_docs_path))) | 19 '$ %s' % os.path.abspath(update_docs_path))) |
20 | 20 |
21 pylint_checks = input_api.canned_checks.GetPylint( | 21 pylint_checks = input_api.canned_checks.GetPylint( |
22 input_api, output_api, black_list=[], pylintrc='pylintrc') | 22 input_api, output_api, black_list=[], pylintrc='pylintrc') |
23 | 23 |
24 results.extend(input_api.RunTests(pylint_checks)) | 24 results.extend(input_api.RunTests(pylint_checks)) |
25 return results | 25 return results |
26 | 26 |
27 def GetPathsToPrepend(input_api): | 27 def GetPathsToPrepend(input_api): |
28 return [input_api.PresubmitLocalPath(), | 28 return [input_api.PresubmitLocalPath(), |
29 os.path.join(input_api.PresubmitLocalPath(), os.path.pardir, | 29 os.path.join(input_api.PresubmitLocalPath(), 'third_party', 'typ')] |
30 os.path.pardir, 'third_party', 'typ')] | |
31 | 30 |
32 def RunWithPrependedPath(prepended_path, fn, *args): | 31 def RunWithPrependedPath(prepended_path, fn, *args): |
33 old_path = sys.path | 32 old_path = sys.path |
34 | 33 |
35 try: | 34 try: |
36 sys.path = prepended_path + old_path | 35 sys.path = prepended_path + old_path |
37 return fn(*args) | 36 return fn(*args) |
38 finally: | 37 finally: |
39 sys.path = old_path | 38 sys.path = old_path |
40 | 39 |
41 def CheckChangeOnUpload(input_api, output_api): | 40 def CheckChangeOnUpload(input_api, output_api): |
42 def go(): | 41 def go(): |
43 results = [] | 42 results = [] |
44 results.extend(_CommonChecks(input_api, output_api)) | 43 results.extend(_CommonChecks(input_api, output_api)) |
45 return results | 44 return results |
46 return RunWithPrependedPath(GetPathsToPrepend(input_api), go) | 45 return RunWithPrependedPath(GetPathsToPrepend(input_api), go) |
47 | 46 |
48 def CheckChangeOnCommit(input_api, output_api): | 47 def CheckChangeOnCommit(input_api, output_api): |
49 def go(): | 48 def go(): |
50 results = [] | 49 results = [] |
51 results.extend(_CommonChecks(input_api, output_api)) | 50 results.extend(_CommonChecks(input_api, output_api)) |
52 return results | 51 return results |
53 return RunWithPrependedPath(GetPathsToPrepend(input_api), go) | 52 return RunWithPrependedPath(GetPathsToPrepend(input_api), go) |
OLD | NEW |