OLD | NEW |
1 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2011 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 UNIT_TESTS = [ | |
12 'tests.fix_encoding_test', | |
13 'tests.gcl_unittest', | |
14 'tests.gclient_scm_test', | |
15 'tests.gclient_smoketest', | |
16 'tests.gclient_utils_test', | |
17 'tests.owners_unittest', | |
18 'tests.presubmit_unittest', | |
19 'tests.scm_unittest', | |
20 'tests.trychange_unittest', | |
21 'tests.watchlists_unittest', | |
22 ] | |
23 | |
24 | 11 |
25 def CommonChecks(input_api, output_api): | 12 def CommonChecks(input_api, output_api): |
26 output = [] | 13 results = [] |
27 # Verify that LocalPath() is local, e.g.: | |
28 # os.path.join(PresubmitLocalPath(), LocalPath()) == AbsoluteLocalPath() | |
29 for i in input_api.AffectedFiles(): | |
30 if (input_api.os_path.join(input_api.PresubmitLocalPath(), i.LocalPath()) != | |
31 i.AbsoluteLocalPath()): | |
32 output.append(output_api.PresubmitError('Path inconsistency')) | |
33 # Return right away because it needs to be fixed first. | |
34 return output | |
35 | 14 |
36 output.extend(input_api.canned_checks.CheckOwners(input_api, output_api)) | 15 results.extend(input_api.canned_checks.CheckOwners(input_api, output_api)) |
37 | 16 black_list = list(input_api.DEFAULT_BLACK_LIST) + [ |
38 output.extend(input_api.canned_checks.RunPythonUnitTests( | 17 r'^cpplint\.py$', |
| 18 r'^tests[\/\\]\w+?[\/\\].+'] |
| 19 results.extend(input_api.canned_checks.RunPylint( |
39 input_api, | 20 input_api, |
40 output_api, | 21 output_api, |
41 UNIT_TESTS)) | 22 white_list=[r'.*\.py$', r'^git-try$'], |
| 23 black_list=black_list)) |
42 | 24 |
43 white_list = [r'.*\.py$', r'^git-try$'] | 25 # TODO(maruel): Make sure at least one file is modified first. |
44 black_list = list(input_api.DEFAULT_BLACK_LIST) + [ | 26 # TODO(maruel): If only tests are modified, only run them. |
45 r'^cpplint\.py$', | 27 verbose = False |
46 r'^tests[\/\\]\w+?[\/\\].+', | 28 results.extend(input_api.canned_checks.RunUnitTestsInDirectory( |
47 ] | |
48 output.extend(input_api.canned_checks.RunPylint( | |
49 input_api, | 29 input_api, |
50 output_api, | 30 output_api, |
51 white_list=white_list, | 31 'tests', |
52 black_list=black_list)) | 32 whitelist=[r'.*test\.py$'], |
53 output.extend(RunGitClTests(input_api, output_api)) | 33 verbose=verbose)) |
54 return output | 34 results.extend(RunGitClTests(input_api, output_api)) |
| 35 return results |
55 | 36 |
56 | 37 |
57 def RunGitClTests(input_api, output_api): | 38 def RunGitClTests(input_api, output_api): |
58 """Run all the shells scripts in the directory test. | 39 """Run all the shells scripts in the directory test. |
59 """ | 40 """ |
60 # Not exposed from InputApi. | 41 # Not exposed from InputApi. |
61 from os import listdir | 42 from os import listdir |
62 | 43 |
63 # First loads a local Rietveld instance. | 44 # First loads a local Rietveld instance. |
64 import sys | 45 import sys |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 return CommonChecks(input_api, output_api) | 93 return CommonChecks(input_api, output_api) |
113 | 94 |
114 | 95 |
115 def CheckChangeOnCommit(input_api, output_api): | 96 def CheckChangeOnCommit(input_api, output_api): |
116 output = [] | 97 output = [] |
117 output.extend(CommonChecks(input_api, output_api)) | 98 output.extend(CommonChecks(input_api, output_api)) |
118 output.extend(input_api.canned_checks.CheckDoNotSubmit( | 99 output.extend(input_api.canned_checks.CheckDoNotSubmit( |
119 input_api, | 100 input_api, |
120 output_api)) | 101 output_api)) |
121 return output | 102 return output |
OLD | NEW |