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.
6 """Top-level presubmit script for GYP.
8 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
9 for more details about the presubmit API built into gcl.
15 # From SCons, not done in google style.
16 'test/lib/TestCmd.py',
17 'test/lib/TestCommon.py',
18 'test/lib/TestGyp.py',
22 PYLINT_DISABLED_WARNINGS = [
24 # Many tests include modules they don't use.
26 # Possible unbalanced tuple unpacking with sequence.
28 # Attempting to unpack a non-sequence.
30 # Include order doesn't properly include local files?
32 # Some use of built-in names.
34 # Some unused variables.
36 # Operator not preceded/followed by space.
39 # Unnecessary semicolon.
43 # String has no effect (docstring in wrong place).
45 # map/filter on lambda could be replaced by comprehension.
49 # Comma not followed by space.
51 # Access to a protected member.
59 # Not exception type specified.
61 # No member of that name.
63 # Dangerous default {}.
67 # Others, too many to sort.
68 'W0201', 'W0232', 'E1103', 'W0621', 'W0108', 'W0223', 'W0231',
69 'R0201', 'E0101', 'C0321',
70 # ************* Module copy
71 # W0104:427,12:_test.odict.__setitem__: Statement seems to have no effect
76 def CheckChangeOnUpload(input_api, output_api):
78 report.extend(input_api.canned_checks.PanProjectChecks(
79 input_api, output_api))
83 def CheckChangeOnCommit(input_api, output_api):
86 # Accept any year number from 2009 to the current year.
87 current_year = int(input_api.time.strftime('%Y'))
88 allowed_years = (str(s) for s in reversed(xrange(2009, current_year + 1)))
89 years_re = '(' + '|'.join(allowed_years) + ')'
91 # The (c) is deprecated, but tolerate it until it's removed from all files.
93 r'.*? Copyright (\(c\) )?%(year)s Google Inc\. All rights reserved\.\n'
94 r'.*? Use of this source code is governed by a BSD-style license that '
96 r'.*? found in the LICENSE file\.\n'
101 report.extend(input_api.canned_checks.PanProjectChecks(
102 input_api, output_api, license_header=license))
103 report.extend(input_api.canned_checks.CheckTreeIsOpen(
104 input_api, output_api,
105 'http://gyp-status.appspot.com/status',
106 'http://gyp-status.appspot.com/current'))
110 old_sys_path = sys.path
112 sys.path = ['pylib', 'test/lib'] + sys.path
113 blacklist = PYLINT_BLACKLIST
114 if sys.platform == 'win32':
115 blacklist = [os.path.normpath(x).replace('\\', '\\\\')
116 for x in PYLINT_BLACKLIST]
117 report.extend(input_api.canned_checks.RunPylint(
120 black_list=blacklist,
121 disabled_warnings=PYLINT_DISABLED_WARNINGS))
123 sys.path = old_sys_path
134 def GetPreferredTryMasters(_, change):
136 'client.gyp': { t: set(['defaulttests']) for t in TRYBOTS },