OLD | NEW |
| (Empty) |
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 | |
3 # found in the LICENSE file. | |
4 | |
5 """Top-level presubmit script for commit-queue. | |
6 | |
7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for | |
8 details on the presubmit API built into gcl. | |
9 """ | |
10 | |
11 | |
12 def CommonChecks(input_api, output_api): | |
13 import sys | |
14 def join(*args): | |
15 return input_api.os_path.join(input_api.PresubmitLocalPath(), *args) | |
16 | |
17 output = [] | |
18 | |
19 sys_path_backup = sys.path | |
20 try: | |
21 # Note that this won't work on the commit queue. | |
22 sys.path = [join('..', 'commit-queue-internal')] + sys.path | |
23 black_list = list(input_api.DEFAULT_BLACK_LIST) + [ | |
24 r'^workdir/.*', | |
25 r'^tests/.+', | |
26 ] | |
27 output.extend(input_api.canned_checks.RunPylint( | |
28 input_api, output_api, black_list=black_list)) | |
29 | |
30 sys.path = [join('tests')] + sys.path | |
31 black_list = list(input_api.DEFAULT_BLACK_LIST) + [ | |
32 r'^workdir/.*', | |
33 ] | |
34 white_list = [ r'tests/.+\.py$' ] | |
35 output.extend(input_api.canned_checks.RunPylint( | |
36 input_api, output_api, black_list=black_list, white_list=white_list)) | |
37 finally: | |
38 sys.path = sys_path_backup | |
39 | |
40 output.extend(input_api.canned_checks.RunUnitTestsInDirectory( | |
41 input_api, output_api, 'tests', whitelist=[r'.*_test\.py$'])) | |
42 return output | |
43 | |
44 | |
45 def CheckChangeOnUpload(input_api, output_api): | |
46 return CommonChecks(input_api, output_api) | |
47 | |
48 | |
49 def CheckChangeOnCommit(input_api, output_api): | |
50 return CommonChecks(input_api, output_api) | |
OLD | NEW |