OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 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 | 4 |
5 """Top-level presubmit script for depot tools. | 5 """Top-level presubmit script for depot tools. |
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 depot_tools. | 8 details on the presubmit API built into depot_tools. |
9 """ | 9 """ |
10 | 10 |
11 | 11 |
12 def CommonChecks(input_api, output_api, tests_to_black_list): | 12 def CommonChecks(input_api, output_api, tests_to_black_list): |
13 results = [] | 13 results = [] |
14 results.extend(input_api.canned_checks.CheckOwners(input_api, output_api)) | 14 results.extend(input_api.canned_checks.CheckOwners(input_api, output_api)) |
15 black_list = list(input_api.DEFAULT_BLACK_LIST) + [ | 15 black_list = list(input_api.DEFAULT_BLACK_LIST) + [ |
16 r'^cpplint\.py$', | 16 r'^cpplint\.py$', |
17 r'^cpplint_chromium\.py$', | 17 r'^cpplint_chromium\.py$', |
18 r'^python[0-9]*_bin[\/\\].+', | 18 r'^python[0-9]*_bin[\/\\].+', |
19 r'^site-packages-py[0-9]\.[0-9][\/\\].+', | 19 r'^site-packages-py[0-9]\.[0-9][\/\\].+', |
20 r'^svn_bin[\/\\].+', | 20 r'^svn_bin[\/\\].+', |
21 r'^testing_support[\/\\]_rietveld[\/\\].+'] | 21 r'^testing_support[\/\\]_rietveld[\/\\].+'] |
22 disabled_warnings = [ | 22 disabled_warnings = [ |
23 'R0401', # Cyclic import | 23 'R0401', # Cyclic import |
24 'W0613', # Unused argument | 24 'W0613', # Unused argument |
25 ] | 25 ] |
26 results.extend(input_api.RunTests( | 26 pylint = input_api.canned_checks.GetPylint( |
27 input_api.canned_checks.GetPylint( | 27 input_api, |
28 input_api, | 28 output_api, |
29 output_api, | 29 white_list=[r'.*\.py$'], |
30 white_list=[r'.*\.py$'], | 30 black_list=black_list, |
31 black_list=black_list, | 31 disabled_warnings=disabled_warnings) |
32 disabled_warnings=disabled_warnings) + | 32 # TODO(maruel): Make sure at least one file is modified first. |
33 # TODO(maruel): Make sure at least one file is modified first. | 33 # TODO(maruel): If only tests are modified, only run them. |
34 # TODO(maruel): If only tests are modified, only run them. | 34 unit_tests = input_api.canned_checks.GetUnitTestsInDirectory( |
35 input_api.canned_checks.GetUnitTestsInDirectory( | 35 input_api, |
36 input_api, | 36 output_api, |
37 output_api, | 37 'tests', |
38 'tests', | 38 whitelist=[r'.*test\.py$'], |
39 whitelist=[r'.*test\.py$'], | 39 blacklist=tests_to_black_list) |
40 blacklist=tests_to_black_list))) | 40 tests = pylint |
| 41 if not input_api.platform.startswith(('cygwin', 'win32')): |
| 42 tests.extend(unit_tests) |
| 43 else: |
| 44 print('Warning: not running unit tests on Windows') |
| 45 results.extend(input_api.RunTests(tests)) |
41 return results | 46 return results |
42 | 47 |
43 | 48 |
44 def RunGitClTests(input_api, output_api): | 49 def RunGitClTests(input_api, output_api): |
45 """Run all the shells scripts in the directory test. | 50 """Run all the shells scripts in the directory test. |
46 """ | 51 """ |
47 if input_api.platform == 'win32': | 52 if input_api.platform == 'win32': |
48 # Skip for now as long as the test scripts are bash scripts. | 53 # Skip for now as long as the test scripts are bash scripts. |
49 return [] | 54 return [] |
50 | 55 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 | 107 |
103 | 108 |
104 def CheckChangeOnCommit(input_api, output_api): | 109 def CheckChangeOnCommit(input_api, output_api): |
105 output = [] | 110 output = [] |
106 output.extend(CommonChecks(input_api, output_api, [])) | 111 output.extend(CommonChecks(input_api, output_api, [])) |
107 output.extend(input_api.canned_checks.CheckDoNotSubmit( | 112 output.extend(input_api.canned_checks.CheckDoNotSubmit( |
108 input_api, | 113 input_api, |
109 output_api)) | 114 output_api)) |
110 output.extend(RunGitClTests(input_api, output_api)) | 115 output.extend(RunGitClTests(input_api, output_api)) |
111 return output | 116 return output |
OLD | NEW |