|
1 # Copyright (c) 2012 Google Inc. 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 |
|
6 """Top-level presubmit script for GYP. |
|
7 |
|
8 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts |
|
9 for more details about the presubmit API built into gcl. |
|
10 """ |
|
11 |
|
12 |
|
13 PYLINT_BLACKLIST = [ |
|
14 # TODO: fix me. |
|
15 # From SCons, not done in google style. |
|
16 'test/lib/TestCmd.py', |
|
17 'test/lib/TestCommon.py', |
|
18 'test/lib/TestGyp.py', |
|
19 # Needs style fix. |
|
20 'pylib/gyp/generator/scons.py', |
|
21 'pylib/gyp/generator/xcode.py', |
|
22 ] |
|
23 |
|
24 |
|
25 PYLINT_DISABLED_WARNINGS = [ |
|
26 # TODO: fix me. |
|
27 # Many tests include modules they don't use. |
|
28 'W0611', |
|
29 # Include order doesn't properly include local files? |
|
30 'F0401', |
|
31 # Some use of built-in names. |
|
32 'W0622', |
|
33 # Some unused variables. |
|
34 'W0612', |
|
35 # Operator not preceded/followed by space. |
|
36 'C0323', |
|
37 'C0322', |
|
38 # Unnecessary semicolon. |
|
39 'W0301', |
|
40 # Unused argument. |
|
41 'W0613', |
|
42 # String has no effect (docstring in wrong place). |
|
43 'W0105', |
|
44 # Comma not followed by space. |
|
45 'C0324', |
|
46 # Access to a protected member. |
|
47 'W0212', |
|
48 # Bad indent. |
|
49 'W0311', |
|
50 # Line too long. |
|
51 'C0301', |
|
52 # Undefined variable. |
|
53 'E0602', |
|
54 # Not exception type specified. |
|
55 'W0702', |
|
56 # No member of that name. |
|
57 'E1101', |
|
58 # Dangerous default {}. |
|
59 'W0102', |
|
60 # Others, too many to sort. |
|
61 'W0201', 'W0232', 'E1103', 'W0621', 'W0108', 'W0223', 'W0231', |
|
62 'R0201', 'E0101', 'C0321', |
|
63 # ************* Module copy |
|
64 # W0104:427,12:_test.odict.__setitem__: Statement seems to have no effect |
|
65 'W0104', |
|
66 ] |
|
67 |
|
68 |
|
69 def CheckChangeOnUpload(input_api, output_api): |
|
70 report = [] |
|
71 report.extend(input_api.canned_checks.PanProjectChecks( |
|
72 input_api, output_api)) |
|
73 return report |
|
74 |
|
75 |
|
76 def CheckChangeOnCommit(input_api, output_api): |
|
77 report = [] |
|
78 license = ( |
|
79 r'.*? Copyright \(c\) %(year)s Google Inc\. All rights reserved\.\n' |
|
80 r'.*? Use of this source code is governed by a BSD-style license that ' |
|
81 r'can be\n' |
|
82 r'.*? found in the LICENSE file\.\n' |
|
83 ) % { |
|
84 'year': input_api.time.strftime('%Y'), |
|
85 } |
|
86 |
|
87 report.extend(input_api.canned_checks.PanProjectChecks( |
|
88 input_api, output_api, license_header=license)) |
|
89 report.extend(input_api.canned_checks.CheckTreeIsOpen( |
|
90 input_api, output_api, |
|
91 'http://gyp-status.appspot.com/status', |
|
92 'http://gyp-status.appspot.com/current')) |
|
93 |
|
94 import sys |
|
95 old_sys_path = sys.path |
|
96 try: |
|
97 sys.path = ['pylib', 'test/lib'] + sys.path |
|
98 report.extend(input_api.canned_checks.RunPylint( |
|
99 input_api, |
|
100 output_api, |
|
101 black_list=PYLINT_BLACKLIST, |
|
102 disabled_warnings=PYLINT_DISABLED_WARNINGS)) |
|
103 finally: |
|
104 sys.path = old_sys_path |
|
105 return report |
|
106 |
|
107 |
|
108 def GetPreferredTrySlaves(): |
|
109 return ['gyp-win32', 'gyp-win64', 'gyp-linux', 'gyp-mac'] |