OLD | NEW |
1 # Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2014 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 | 4 |
5 """Top-level presubmit script for buildbot. | 5 """Top-level presubmit script for buildbot. |
6 | 6 |
7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for | 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for |
8 details on the presubmit API built into gcl. | 8 details on the presubmit API built into gcl. |
9 """ | 9 """ |
10 | 10 |
11 | |
12 DISABLED_TESTS = [ | 11 DISABLED_TESTS = [ |
13 '.*appengine/chromium_status/tests/main_test.py', | 12 '.*appengine/chromium_status/tests/main_test.py', |
14 '.*appengine/chromium_build/app_test.py', | 13 '.*appengine/chromium_build/app_test.py', |
15 ] | 14 ] |
16 | 15 |
17 | 16 |
18 DISABLED_PROJECTS = [ | 17 DISABLED_PROJECTS = [ |
19 'appengine/chromium_build', | 18 'appengine/chromium_build', |
20 'infra/services/lkgr_finder', | 19 'infra/services/lkgr_finder', |
21 'infra/services/gnumbd', | 20 'infra/services/gnumbd', |
22 ] | 21 ] |
23 | 22 |
24 | 23 |
25 def CommonChecks(input_api, output_api): | 24 def CommonChecks(input_api, output_api): |
| 25 # Cause all pylint commands to execute in the virtualenv |
| 26 input_api.python_executable = ( |
| 27 input_api.os_path.join(input_api.PresubmitLocalPath(), |
| 28 'ENV', 'bin', 'python')) |
| 29 |
26 tests = [] | 30 tests = [] |
27 | 31 |
28 blacklist = list(input_api.DEFAULT_BLACK_LIST) + DISABLED_PROJECTS | 32 blacklist = list(input_api.DEFAULT_BLACK_LIST) + DISABLED_PROJECTS |
29 | 33 |
30 status_output = input_api.subprocess.check_output( | 34 status_output = input_api.subprocess.check_output( |
31 ['git', 'status', '--porcelain', '--ignored']) | 35 ['git', 'status', '--porcelain', '--ignored']) |
32 statuses = [(line[:2], line[3:]) for line in status_output.splitlines()] | 36 statuses = [(line[:2], line[3:]) for line in status_output.splitlines()] |
33 ignored_files = [path for (mode, path) in statuses if mode in ('!!', '??')] | 37 ignored_files = [path for (mode, path) in statuses if mode in ('!!', '??')] |
34 | 38 |
35 blacklist = blacklist + ignored_files | 39 blacklist = blacklist + ignored_files |
36 | 40 |
37 disabled_warnings = [ | 41 disabled_warnings = [ |
38 'W0231', # __init__ method from base class is not called | 42 'W0231', # __init__ method from base class is not called |
39 'W0232', # Class has no __init__ method | 43 'W0232', # Class has no __init__ method |
40 'W0613', # Unused argument | 44 'W0613', # Unused argument |
41 'F0401', # Unable to import | 45 'F0401', # Unable to import |
42 ] | 46 ] |
43 appengine_path = input_api.os_path.abspath( | 47 appengine_path = input_api.os_path.abspath( |
44 input_api.os_path.join( | 48 input_api.os_path.join( |
45 input_api.os_path.dirname(input_api.PresubmitLocalPath()), | 49 input_api.os_path.dirname(input_api.PresubmitLocalPath()), |
46 'google_appengine')) | 50 'google_appengine')) |
47 tests.extend(input_api.canned_checks.GetPylint( | 51 tests.extend(input_api.canned_checks.GetPylint( |
48 input_api, | 52 input_api, |
49 output_api, | 53 output_api, |
50 black_list=blacklist, | 54 black_list=blacklist, |
51 disabled_warnings=disabled_warnings, | 55 disabled_warnings=disabled_warnings, |
52 extra_paths_list=[appengine_path])) | 56 extra_paths_list=[appengine_path, |
| 57 '/infra/infra/ENV/lib/python2.7'])) |
53 | 58 |
54 whitelist = [r'.+_test\.py$'] | 59 message_type = (output_api.PresubmitError if output_api.is_committing else |
55 blacklist = blacklist + DISABLED_TESTS | 60 output_api.PresubmitPromptWarning) |
56 tests.extend(input_api.canned_checks.GetUnitTestsRecursively( | 61 tests.append(input_api.Command( |
57 input_api, output_api, '.', whitelist=whitelist, blacklist=blacklist)) | 62 name='All Tests', |
| 63 cmd=input_api.os_path.join('ENV', 'bin', 'expect_tests'), |
| 64 kwargs={'cwd': input_api.PresubmitLocalPath()}, |
| 65 message=message_type, |
| 66 )) |
58 | 67 |
59 # Run the tests. | 68 # Run the tests. |
60 return input_api.RunTests(tests) | 69 return input_api.RunTests(tests) |
61 | 70 |
62 | 71 |
63 def CheckChangeOnUpload(input_api, output_api): | 72 def CheckChangeOnUpload(input_api, output_api): |
64 return CommonChecks(input_api, output_api) | 73 return CommonChecks(input_api, output_api) |
65 | 74 |
66 | 75 |
67 def CheckChangeOnCommit(input_api, output_api): | 76 def CheckChangeOnCommit(input_api, output_api): |
68 output = CommonChecks(input_api, output_api) | 77 output = CommonChecks(input_api, output_api) |
69 output.extend(input_api.canned_checks.CheckOwners(input_api, output_api)) | 78 output.extend(input_api.canned_checks.CheckOwners(input_api, output_api)) |
70 return output | 79 return output |
OLD | NEW |