blob: eafc8fe35a13ce7600db422c8feb792690b56457 [file] [log] [blame]
[email protected]a18130a2012-01-03 17:52:081# Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]ca8d19842009-02-19 16:33:122# 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 Chromium.
6
[email protected]f1293792009-07-31 18:09:567See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
[email protected]50d7d721e2009-11-15 17:56:188for more details about the presubmit API built into gcl.
[email protected]ca8d19842009-02-19 16:33:129"""
10
[email protected]eea609a2011-11-18 13:10:1211
[email protected]379e7dd2010-01-28 17:39:2112_EXCLUDED_PATHS = (
[email protected]3e4eb112011-01-18 03:29:5413 r"^breakpad[\\\/].*",
[email protected]40d1dbb2012-10-26 07:18:0014 r"^native_client_sdk[\\\/]src[\\\/]build_tools[\\\/]make_rules.py",
15 r"^native_client_sdk[\\\/]src[\\\/]build_tools[\\\/]make_simple.py",
[email protected]8886ffcb2013-02-12 04:56:2816 r"^native_client_sdk[\\\/]src[\\\/]tools[\\\/].*.mk",
[email protected]a18130a2012-01-03 17:52:0817 r"^net[\\\/]tools[\\\/]spdyshark[\\\/].*",
[email protected]3e4eb112011-01-18 03:29:5418 r"^skia[\\\/].*",
19 r"^v8[\\\/].*",
20 r".*MakeFile$",
[email protected]1084ccc2012-03-14 03:22:5321 r".+_autogen\.h$",
[email protected]ce145c02012-09-06 09:49:3422 r".+[\\\/]pnacl_shim\.c$",
[email protected]e07b6ac72013-08-20 00:30:4223 r"^gpu[\\\/]config[\\\/].*_list_json\.cc$",
[email protected]d2600602014-02-19 00:09:1924 r"^chrome[\\\/]browser[\\\/]resources[\\\/]pdf[\\\/]index.js"
[email protected]4306417642009-06-11 00:33:4025)
[email protected]ca8d19842009-02-19 16:33:1226
jochen9ea8fdbc2014-09-25 13:21:3527# The NetscapePlugIn library is excluded from pan-project as it will soon
28# be deleted together with the rest of the NPAPI and it's not worthwhile to
29# update the coding style until then.
[email protected]3de922f2013-12-20 13:27:3830_TESTRUNNER_PATHS = (
[email protected]de28fed2e2014-02-01 14:36:3231 r"^content[\\\/]shell[\\\/]tools[\\\/]plugin[\\\/].*",
[email protected]3de922f2013-12-20 13:27:3832)
33
[email protected]06e6d0ff2012-12-11 01:36:4434# Fragment of a regular expression that matches C++ and Objective-C++
35# implementation files.
36_IMPLEMENTATION_EXTENSIONS = r'\.(cc|cpp|cxx|mm)$'
37
38# Regular expression that matches code only used for test binaries
39# (best effort).
40_TEST_CODE_EXCLUDED_PATHS = (
joaodasilva718f87672014-08-30 09:25:4941 r'.*[\\\/](fake_|test_|mock_).+%s' % _IMPLEMENTATION_EXTENSIONS,
[email protected]06e6d0ff2012-12-11 01:36:4442 r'.+_test_(base|support|util)%s' % _IMPLEMENTATION_EXTENSIONS,
[email protected]6e04f8c2014-01-29 18:08:3243 r'.+_(api|browser|kif|perf|pixel|unit|ui)?test(_[a-z]+)?%s' %
[email protected]e2d7e6f2013-04-23 12:57:1244 _IMPLEMENTATION_EXTENSIONS,
[email protected]06e6d0ff2012-12-11 01:36:4445 r'.+profile_sync_service_harness%s' % _IMPLEMENTATION_EXTENSIONS,
joaodasilva718f87672014-08-30 09:25:4946 r'.*[\\\/](test|tool(s)?)[\\\/].*',
[email protected]ef070cc2013-05-03 11:53:0547 # content_shell is used for running layout tests.
joaodasilva718f87672014-08-30 09:25:4948 r'content[\\\/]shell[\\\/].*',
[email protected]06e6d0ff2012-12-11 01:36:4449 # At request of folks maintaining this folder.
joaodasilva718f87672014-08-30 09:25:4950 r'chrome[\\\/]browser[\\\/]automation[\\\/].*',
[email protected]7b054982013-11-27 00:44:4751 # Non-production example code.
joaodasilva718f87672014-08-30 09:25:4952 r'mojo[\\\/]examples[\\\/].*',
[email protected]8176de12014-06-20 19:07:0853 # Launcher for running iOS tests on the simulator.
joaodasilva718f87672014-08-30 09:25:4954 r'testing[\\\/]iossim[\\\/]iossim\.mm$',
[email protected]06e6d0ff2012-12-11 01:36:4455)
[email protected]ca8d19842009-02-19 16:33:1256
[email protected]eea609a2011-11-18 13:10:1257_TEST_ONLY_WARNING = (
58 'You might be calling functions intended only for testing from\n'
59 'production code. It is OK to ignore this warning if you know what\n'
60 'you are doing, as the heuristics used to detect the situation are\n'
[email protected]b0149772014-03-27 16:47:5861 'not perfect. The commit queue will not block on this warning.')
[email protected]eea609a2011-11-18 13:10:1262
63
[email protected]cf9b78f2012-11-14 11:40:2864_INCLUDE_ORDER_WARNING = (
65 'Your #include order seems to be broken. Send mail to\n'
66 '[email protected] if this is not the case.')
67
68
[email protected]127f18ec2012-06-16 05:05:5969_BANNED_OBJC_FUNCTIONS = (
70 (
71 'addTrackingRect:',
[email protected]23e6cbc2012-06-16 18:51:2072 (
73 'The use of -[NSView addTrackingRect:owner:userData:assumeInside:] is'
[email protected]127f18ec2012-06-16 05:05:5974 'prohibited. Please use CrTrackingArea instead.',
75 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
76 ),
77 False,
78 ),
79 (
[email protected]eaae1972014-04-16 04:17:2680 r'/NSTrackingArea\W',
[email protected]23e6cbc2012-06-16 18:51:2081 (
82 'The use of NSTrackingAreas is prohibited. Please use CrTrackingArea',
[email protected]127f18ec2012-06-16 05:05:5983 'instead.',
84 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
85 ),
86 False,
87 ),
88 (
89 'convertPointFromBase:',
[email protected]23e6cbc2012-06-16 18:51:2090 (
91 'The use of -[NSView convertPointFromBase:] is almost certainly wrong.',
[email protected]127f18ec2012-06-16 05:05:5992 'Please use |convertPoint:(point) fromView:nil| instead.',
93 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
94 ),
95 True,
96 ),
97 (
98 'convertPointToBase:',
[email protected]23e6cbc2012-06-16 18:51:2099 (
100 'The use of -[NSView convertPointToBase:] is almost certainly wrong.',
[email protected]127f18ec2012-06-16 05:05:59101 'Please use |convertPoint:(point) toView:nil| instead.',
102 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
103 ),
104 True,
105 ),
106 (
107 'convertRectFromBase:',
[email protected]23e6cbc2012-06-16 18:51:20108 (
109 'The use of -[NSView convertRectFromBase:] is almost certainly wrong.',
[email protected]127f18ec2012-06-16 05:05:59110 'Please use |convertRect:(point) fromView:nil| instead.',
111 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
112 ),
113 True,
114 ),
115 (
116 'convertRectToBase:',
[email protected]23e6cbc2012-06-16 18:51:20117 (
118 'The use of -[NSView convertRectToBase:] is almost certainly wrong.',
[email protected]127f18ec2012-06-16 05:05:59119 'Please use |convertRect:(point) toView:nil| instead.',
120 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
121 ),
122 True,
123 ),
124 (
125 'convertSizeFromBase:',
[email protected]23e6cbc2012-06-16 18:51:20126 (
127 'The use of -[NSView convertSizeFromBase:] is almost certainly wrong.',
[email protected]127f18ec2012-06-16 05:05:59128 'Please use |convertSize:(point) fromView:nil| instead.',
129 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
130 ),
131 True,
132 ),
133 (
134 'convertSizeToBase:',
[email protected]23e6cbc2012-06-16 18:51:20135 (
136 'The use of -[NSView convertSizeToBase:] is almost certainly wrong.',
[email protected]127f18ec2012-06-16 05:05:59137 'Please use |convertSize:(point) toView:nil| instead.',
138 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
139 ),
140 True,
141 ),
142)
143
144
145_BANNED_CPP_FUNCTIONS = (
[email protected]23e6cbc2012-06-16 18:51:20146 # Make sure that gtest's FRIEND_TEST() macro is not used; the
147 # FRIEND_TEST_ALL_PREFIXES() macro from base/gtest_prod_util.h should be
[email protected]e00ccc92012-11-01 17:32:30148 # used instead since that allows for FLAKY_ and DISABLED_ prefixes.
[email protected]23e6cbc2012-06-16 18:51:20149 (
150 'FRIEND_TEST(',
151 (
[email protected]e3c945502012-06-26 20:01:49152 'Chromium code should not use gtest\'s FRIEND_TEST() macro. Include',
[email protected]23e6cbc2012-06-16 18:51:20153 'base/gtest_prod_util.h and use FRIEND_TEST_ALL_PREFIXES() instead.',
154 ),
155 False,
[email protected]7345da02012-11-27 14:31:49156 (),
[email protected]23e6cbc2012-06-16 18:51:20157 ),
158 (
159 'ScopedAllowIO',
160 (
[email protected]e3c945502012-06-26 20:01:49161 'New code should not use ScopedAllowIO. Post a task to the blocking',
162 'pool or the FILE thread instead.',
[email protected]23e6cbc2012-06-16 18:51:20163 ),
[email protected]e3c945502012-06-26 20:01:49164 True,
[email protected]7345da02012-11-27 14:31:49165 (
thestig75844fdb2014-09-09 19:47:10166 r"^base[\\\/]process[\\\/]process_metrics_linux\.cc$",
[email protected]b01b9e22014-06-03 22:20:19167 r"^chrome[\\\/]browser[\\\/]chromeos[\\\/]boot_times_loader\.cc$",
philipj3f9d5bde2014-08-28 14:09:09168 r"^components[\\\/]crash[\\\/]app[\\\/]breakpad_mac\.mm$",
[email protected]de7d61ff2013-08-20 11:30:41169 r"^content[\\\/]shell[\\\/]browser[\\\/]shell_browser_main\.cc$",
170 r"^content[\\\/]shell[\\\/]browser[\\\/]shell_message_filter\.cc$",
jamesra03ae492014-10-03 04:26:48171 r"^mojo[\\\/]edk[\\\/]embedder[\\\/]" +
172 r"simple_platform_shared_buffer_posix\.cc$",
[email protected]398ad132013-04-02 15:11:01173 r"^net[\\\/]disk_cache[\\\/]cache_util\.cc$",
[email protected]1f52a572014-05-12 23:21:54174 r"^net[\\\/]url_request[\\\/]test_url_fetcher_factory\.cc$",
[email protected]7345da02012-11-27 14:31:49175 ),
[email protected]23e6cbc2012-06-16 18:51:20176 ),
[email protected]52657f62013-05-20 05:30:31177 (
178 'SkRefPtr',
179 (
180 'The use of SkRefPtr is prohibited. ',
181 'Please use skia::RefPtr instead.'
182 ),
183 True,
184 (),
185 ),
186 (
187 'SkAutoRef',
188 (
189 'The indirect use of SkRefPtr via SkAutoRef is prohibited. ',
190 'Please use skia::RefPtr instead.'
191 ),
192 True,
193 (),
194 ),
195 (
196 'SkAutoTUnref',
197 (
198 'The use of SkAutoTUnref is dangerous because it implicitly ',
199 'converts to a raw pointer. Please use skia::RefPtr instead.'
200 ),
201 True,
202 (),
203 ),
204 (
205 'SkAutoUnref',
206 (
207 'The indirect use of SkAutoTUnref through SkAutoUnref is dangerous ',
208 'because it implicitly converts to a raw pointer. ',
209 'Please use skia::RefPtr instead.'
210 ),
211 True,
212 (),
213 ),
[email protected]d89eec82013-12-03 14:10:59214 (
215 r'/HANDLE_EINTR\(.*close',
216 (
217 'HANDLE_EINTR(close) is invalid. If close fails with EINTR, the file',
218 'descriptor will be closed, and it is incorrect to retry the close.',
219 'Either call close directly and ignore its return value, or wrap close',
220 'in IGNORE_EINTR to use its return value. See http://crbug.com/269623'
221 ),
222 True,
223 (),
224 ),
225 (
226 r'/IGNORE_EINTR\((?!.*close)',
227 (
228 'IGNORE_EINTR is only valid when wrapping close. To wrap other system',
229 'calls, use HANDLE_EINTR. See http://crbug.com/269623',
230 ),
231 True,
232 (
233 # Files that #define IGNORE_EINTR.
234 r'^base[\\\/]posix[\\\/]eintr_wrapper\.h$',
235 r'^ppapi[\\\/]tests[\\\/]test_broker\.cc$',
236 ),
237 ),
[email protected]ec5b3f02014-04-04 18:43:43238 (
239 r'/v8::Extension\(',
240 (
241 'Do not introduce new v8::Extensions into the code base, use',
242 'gin::Wrappable instead. See http://crbug.com/334679',
243 ),
244 True,
[email protected]f55c90ee62014-04-12 00:50:03245 (
joaodasilva718f87672014-08-30 09:25:49246 r'extensions[\\\/]renderer[\\\/]safe_builtins\.*',
[email protected]f55c90ee62014-04-12 00:50:03247 ),
[email protected]ec5b3f02014-04-04 18:43:43248 ),
[email protected]127f18ec2012-06-16 05:05:59249)
250
mlamouria82272622014-09-16 18:45:04251_IPC_ENUM_TRAITS_DEPRECATED = (
252 'You are using IPC_ENUM_TRAITS() in your code. It has been deprecated.\n'
253 'See http://www.chromium.org/Home/chromium-security/education/security-tips-for-ipc')
254
[email protected]127f18ec2012-06-16 05:05:59255
[email protected]b00342e7f2013-03-26 16:21:54256_VALID_OS_MACROS = (
257 # Please keep sorted.
258 'OS_ANDROID',
[email protected]f4440b42014-03-19 05:47:01259 'OS_ANDROID_HOST',
[email protected]b00342e7f2013-03-26 16:21:54260 'OS_BSD',
261 'OS_CAT', # For testing.
262 'OS_CHROMEOS',
263 'OS_FREEBSD',
264 'OS_IOS',
265 'OS_LINUX',
266 'OS_MACOSX',
267 'OS_NACL',
268 'OS_OPENBSD',
269 'OS_POSIX',
[email protected]eda7afa12014-02-06 12:27:37270 'OS_QNX',
[email protected]b00342e7f2013-03-26 16:21:54271 'OS_SOLARIS',
[email protected]b00342e7f2013-03-26 16:21:54272 'OS_WIN',
273)
274
275
[email protected]55459852011-08-10 15:17:19276def _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api):
277 """Attempts to prevent use of functions intended only for testing in
278 non-testing code. For now this is just a best-effort implementation
279 that ignores header files and may have some false positives. A
280 better implementation would probably need a proper C++ parser.
281 """
282 # We only scan .cc files and the like, as the declaration of
283 # for-testing functions in header files are hard to distinguish from
284 # calls to such functions without a proper C++ parser.
[email protected]06e6d0ff2012-12-11 01:36:44285 file_inclusion_pattern = r'.+%s' % _IMPLEMENTATION_EXTENSIONS
[email protected]55459852011-08-10 15:17:19286
[email protected]23501822014-05-14 02:06:09287 base_function_pattern = r'[ :]test::[^\s]+|ForTest(ing)?|for_test(ing)?'
[email protected]55459852011-08-10 15:17:19288 inclusion_pattern = input_api.re.compile(r'(%s)\s*\(' % base_function_pattern)
[email protected]23501822014-05-14 02:06:09289 comment_pattern = input_api.re.compile(r'//.*(%s)' % base_function_pattern)
[email protected]55459852011-08-10 15:17:19290 exclusion_pattern = input_api.re.compile(
291 r'::[A-Za-z0-9_]+(%s)|(%s)[^;]+\{' % (
292 base_function_pattern, base_function_pattern))
293
294 def FilterFile(affected_file):
[email protected]06e6d0ff2012-12-11 01:36:44295 black_list = (_EXCLUDED_PATHS +
296 _TEST_CODE_EXCLUDED_PATHS +
297 input_api.DEFAULT_BLACK_LIST)
[email protected]55459852011-08-10 15:17:19298 return input_api.FilterSourceFile(
299 affected_file,
300 white_list=(file_inclusion_pattern, ),
301 black_list=black_list)
302
303 problems = []
304 for f in input_api.AffectedSourceFiles(FilterFile):
305 local_path = f.LocalPath()
[email protected]825d27182014-01-02 21:24:24306 for line_number, line in f.ChangedContents():
[email protected]2fdd1f362013-01-16 03:56:03307 if (inclusion_pattern.search(line) and
[email protected]de4f7d22013-05-23 14:27:46308 not comment_pattern.search(line) and
[email protected]2fdd1f362013-01-16 03:56:03309 not exclusion_pattern.search(line)):
[email protected]55459852011-08-10 15:17:19310 problems.append(
[email protected]2fdd1f362013-01-16 03:56:03311 '%s:%d\n %s' % (local_path, line_number, line.strip()))
[email protected]55459852011-08-10 15:17:19312
313 if problems:
[email protected]f7051d52013-04-02 18:31:42314 return [output_api.PresubmitPromptOrNotify(_TEST_ONLY_WARNING, problems)]
[email protected]2fdd1f362013-01-16 03:56:03315 else:
316 return []
[email protected]55459852011-08-10 15:17:19317
318
[email protected]10689ca2011-09-02 02:31:54319def _CheckNoIOStreamInHeaders(input_api, output_api):
320 """Checks to make sure no .h files include <iostream>."""
321 files = []
322 pattern = input_api.re.compile(r'^#include\s*<iostream>',
323 input_api.re.MULTILINE)
324 for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile):
325 if not f.LocalPath().endswith('.h'):
326 continue
327 contents = input_api.ReadFile(f)
328 if pattern.search(contents):
329 files.append(f)
330
331 if len(files):
332 return [ output_api.PresubmitError(
[email protected]6c063c62012-07-11 19:11:06333 'Do not #include <iostream> in header files, since it inserts static '
334 'initialization into every file including the header. Instead, '
[email protected]10689ca2011-09-02 02:31:54335 '#include <ostream>. See http://crbug.com/94794',
336 files) ]
337 return []
338
339
[email protected]72df4e782012-06-21 16:28:18340def _CheckNoUNIT_TESTInSourceFiles(input_api, output_api):
341 """Checks to make sure no source files use UNIT_TEST"""
342 problems = []
343 for f in input_api.AffectedFiles():
344 if (not f.LocalPath().endswith(('.cc', '.mm'))):
345 continue
346
347 for line_num, line in f.ChangedContents():
[email protected]549f86a2013-11-19 13:00:04348 if 'UNIT_TEST ' in line or line.endswith('UNIT_TEST'):
[email protected]72df4e782012-06-21 16:28:18349 problems.append(' %s:%d' % (f.LocalPath(), line_num))
350
351 if not problems:
352 return []
353 return [output_api.PresubmitPromptWarning('UNIT_TEST is only for headers.\n' +
354 '\n'.join(problems))]
355
356
[email protected]8ea5d4b2011-09-13 21:49:22357def _CheckNoNewWStrings(input_api, output_api):
358 """Checks to make sure we don't introduce use of wstrings."""
[email protected]55463aa62011-10-12 00:48:27359 problems = []
[email protected]8ea5d4b2011-09-13 21:49:22360 for f in input_api.AffectedFiles():
[email protected]b5c24292011-11-28 14:38:20361 if (not f.LocalPath().endswith(('.cc', '.h')) or
[email protected]24be83c2013-08-29 23:01:23362 f.LocalPath().endswith(('test.cc', '_win.cc', '_win.h'))):
[email protected]b5c24292011-11-28 14:38:20363 continue
[email protected]8ea5d4b2011-09-13 21:49:22364
[email protected]a11dbe9b2012-08-07 01:32:58365 allowWString = False
[email protected]b5c24292011-11-28 14:38:20366 for line_num, line in f.ChangedContents():
[email protected]a11dbe9b2012-08-07 01:32:58367 if 'presubmit: allow wstring' in line:
368 allowWString = True
369 elif not allowWString and 'wstring' in line:
[email protected]55463aa62011-10-12 00:48:27370 problems.append(' %s:%d' % (f.LocalPath(), line_num))
[email protected]a11dbe9b2012-08-07 01:32:58371 allowWString = False
372 else:
373 allowWString = False
[email protected]8ea5d4b2011-09-13 21:49:22374
[email protected]55463aa62011-10-12 00:48:27375 if not problems:
376 return []
377 return [output_api.PresubmitPromptWarning('New code should not use wstrings.'
[email protected]a11dbe9b2012-08-07 01:32:58378 ' If you are calling a cross-platform API that accepts a wstring, '
379 'fix the API.\n' +
[email protected]55463aa62011-10-12 00:48:27380 '\n'.join(problems))]
[email protected]8ea5d4b2011-09-13 21:49:22381
382
[email protected]2a8ac9c2011-10-19 17:20:44383def _CheckNoDEPSGIT(input_api, output_api):
384 """Make sure .DEPS.git is never modified manually."""
385 if any(f.LocalPath().endswith('.DEPS.git') for f in
386 input_api.AffectedFiles()):
387 return [output_api.PresubmitError(
388 'Never commit changes to .DEPS.git. This file is maintained by an\n'
389 'automated system based on what\'s in DEPS and your changes will be\n'
390 'overwritten.\n'
[email protected]cb706912014-06-28 20:46:34391 'See https://sites.google.com/a/chromium.org/dev/developers/how-tos/get-the-code#Rolling_DEPS\n'
[email protected]2a8ac9c2011-10-19 17:20:44392 'for more information')]
393 return []
394
395
tandriief664692014-09-23 14:51:47396def _CheckValidHostsInDEPS(input_api, output_api):
397 """Checks that DEPS file deps are from allowed_hosts."""
398 # Run only if DEPS file has been modified to annoy fewer bystanders.
399 if all(f.LocalPath() != 'DEPS' for f in input_api.AffectedFiles()):
400 return []
401 # Outsource work to gclient verify
402 try:
403 input_api.subprocess.check_output(['gclient', 'verify'])
404 return []
405 except input_api.subprocess.CalledProcessError, error:
406 return [output_api.PresubmitError(
407 'DEPS file must have only git dependencies.',
408 long_text=error.output)]
409
410
[email protected]127f18ec2012-06-16 05:05:59411def _CheckNoBannedFunctions(input_api, output_api):
412 """Make sure that banned functions are not used."""
413 warnings = []
414 errors = []
415
416 file_filter = lambda f: f.LocalPath().endswith(('.mm', '.m', '.h'))
417 for f in input_api.AffectedFiles(file_filter=file_filter):
418 for line_num, line in f.ChangedContents():
419 for func_name, message, error in _BANNED_OBJC_FUNCTIONS:
[email protected]eaae1972014-04-16 04:17:26420 matched = False
421 if func_name[0:1] == '/':
422 regex = func_name[1:]
423 if input_api.re.search(regex, line):
424 matched = True
425 elif func_name in line:
426 matched = True
427 if matched:
[email protected]127f18ec2012-06-16 05:05:59428 problems = warnings;
429 if error:
430 problems = errors;
431 problems.append(' %s:%d:' % (f.LocalPath(), line_num))
432 for message_line in message:
433 problems.append(' %s' % message_line)
434
435 file_filter = lambda f: f.LocalPath().endswith(('.cc', '.mm', '.h'))
436 for f in input_api.AffectedFiles(file_filter=file_filter):
437 for line_num, line in f.ChangedContents():
[email protected]7345da02012-11-27 14:31:49438 for func_name, message, error, excluded_paths in _BANNED_CPP_FUNCTIONS:
439 def IsBlacklisted(affected_file, blacklist):
440 local_path = affected_file.LocalPath()
441 for item in blacklist:
442 if input_api.re.match(item, local_path):
443 return True
444 return False
445 if IsBlacklisted(f, excluded_paths):
446 continue
[email protected]d89eec82013-12-03 14:10:59447 matched = False
448 if func_name[0:1] == '/':
449 regex = func_name[1:]
450 if input_api.re.search(regex, line):
451 matched = True
452 elif func_name in line:
453 matched = True
454 if matched:
[email protected]127f18ec2012-06-16 05:05:59455 problems = warnings;
456 if error:
457 problems = errors;
458 problems.append(' %s:%d:' % (f.LocalPath(), line_num))
459 for message_line in message:
460 problems.append(' %s' % message_line)
461
462 result = []
463 if (warnings):
464 result.append(output_api.PresubmitPromptWarning(
465 'Banned functions were used.\n' + '\n'.join(warnings)))
466 if (errors):
467 result.append(output_api.PresubmitError(
468 'Banned functions were used.\n' + '\n'.join(errors)))
469 return result
470
471
[email protected]6c063c62012-07-11 19:11:06472def _CheckNoPragmaOnce(input_api, output_api):
473 """Make sure that banned functions are not used."""
474 files = []
475 pattern = input_api.re.compile(r'^#pragma\s+once',
476 input_api.re.MULTILINE)
477 for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile):
478 if not f.LocalPath().endswith('.h'):
479 continue
480 contents = input_api.ReadFile(f)
481 if pattern.search(contents):
482 files.append(f)
483
484 if files:
485 return [output_api.PresubmitError(
486 'Do not use #pragma once in header files.\n'
487 'See http://www.chromium.org/developers/coding-style#TOC-File-headers',
488 files)]
489 return []
490
[email protected]127f18ec2012-06-16 05:05:59491
[email protected]e7479052012-09-19 00:26:12492def _CheckNoTrinaryTrueFalse(input_api, output_api):
493 """Checks to make sure we don't introduce use of foo ? true : false."""
494 problems = []
495 pattern = input_api.re.compile(r'\?\s*(true|false)\s*:\s*(true|false)')
496 for f in input_api.AffectedFiles():
497 if not f.LocalPath().endswith(('.cc', '.h', '.inl', '.m', '.mm')):
498 continue
499
500 for line_num, line in f.ChangedContents():
501 if pattern.match(line):
502 problems.append(' %s:%d' % (f.LocalPath(), line_num))
503
504 if not problems:
505 return []
506 return [output_api.PresubmitPromptWarning(
507 'Please consider avoiding the "? true : false" pattern if possible.\n' +
508 '\n'.join(problems))]
509
510
[email protected]55f9f382012-07-31 11:02:18511def _CheckUnwantedDependencies(input_api, output_api):
512 """Runs checkdeps on #include statements added in this
513 change. Breaking - rules is an error, breaking ! rules is a
514 warning.
515 """
mohan.reddyf21db962014-10-16 12:26:47516 import sys
[email protected]55f9f382012-07-31 11:02:18517 # We need to wait until we have an input_api object and use this
518 # roundabout construct to import checkdeps because this file is
519 # eval-ed and thus doesn't have __file__.
520 original_sys_path = sys.path
521 try:
522 sys.path = sys.path + [input_api.os_path.join(
[email protected]5298cc982014-05-29 20:53:47523 input_api.PresubmitLocalPath(), 'buildtools', 'checkdeps')]
[email protected]55f9f382012-07-31 11:02:18524 import checkdeps
525 from cpp_checker import CppChecker
526 from rules import Rule
527 finally:
528 # Restore sys.path to what it was before.
529 sys.path = original_sys_path
530
531 added_includes = []
532 for f in input_api.AffectedFiles():
533 if not CppChecker.IsCppFile(f.LocalPath()):
534 continue
535
536 changed_lines = [line for line_num, line in f.ChangedContents()]
537 added_includes.append([f.LocalPath(), changed_lines])
538
[email protected]26385172013-05-09 23:11:35539 deps_checker = checkdeps.DepsChecker(input_api.PresubmitLocalPath())
[email protected]55f9f382012-07-31 11:02:18540
541 error_descriptions = []
542 warning_descriptions = []
543 for path, rule_type, rule_description in deps_checker.CheckAddedCppIncludes(
544 added_includes):
545 description_with_path = '%s\n %s' % (path, rule_description)
546 if rule_type == Rule.DISALLOW:
547 error_descriptions.append(description_with_path)
548 else:
549 warning_descriptions.append(description_with_path)
550
551 results = []
552 if error_descriptions:
553 results.append(output_api.PresubmitError(
554 'You added one or more #includes that violate checkdeps rules.',
555 error_descriptions))
556 if warning_descriptions:
[email protected]f7051d52013-04-02 18:31:42557 results.append(output_api.PresubmitPromptOrNotify(
[email protected]55f9f382012-07-31 11:02:18558 'You added one or more #includes of files that are temporarily\n'
559 'allowed but being removed. Can you avoid introducing the\n'
560 '#include? See relevant DEPS file(s) for details and contacts.',
561 warning_descriptions))
562 return results
563
564
[email protected]fbcafe5a2012-08-08 15:31:22565def _CheckFilePermissions(input_api, output_api):
566 """Check that all files have their permissions properly set."""
[email protected]791507202014-02-03 23:19:15567 if input_api.platform == 'win32':
568 return []
mohan.reddyf21db962014-10-16 12:26:47569 args = [input_api.python_executable, 'tools/checkperms/checkperms.py',
570 '--root', input_api.change.RepositoryRoot()]
[email protected]fbcafe5a2012-08-08 15:31:22571 for f in input_api.AffectedFiles():
572 args += ['--file', f.LocalPath()]
[email protected]f0d330f2014-01-30 01:44:34573 checkperms = input_api.subprocess.Popen(args,
574 stdout=input_api.subprocess.PIPE)
575 errors = checkperms.communicate()[0].strip()
[email protected]fbcafe5a2012-08-08 15:31:22576 if errors:
[email protected]f0d330f2014-01-30 01:44:34577 return [output_api.PresubmitError('checkperms.py failed.',
578 errors.splitlines())]
579 return []
[email protected]fbcafe5a2012-08-08 15:31:22580
581
[email protected]c8278b32012-10-30 20:35:49582def _CheckNoAuraWindowPropertyHInHeaders(input_api, output_api):
583 """Makes sure we don't include ui/aura/window_property.h
584 in header files.
585 """
586 pattern = input_api.re.compile(r'^#include\s*"ui/aura/window_property.h"')
587 errors = []
588 for f in input_api.AffectedFiles():
589 if not f.LocalPath().endswith('.h'):
590 continue
591 for line_num, line in f.ChangedContents():
592 if pattern.match(line):
593 errors.append(' %s:%d' % (f.LocalPath(), line_num))
594
595 results = []
596 if errors:
597 results.append(output_api.PresubmitError(
598 'Header files should not include ui/aura/window_property.h', errors))
599 return results
600
601
[email protected]cf9b78f2012-11-14 11:40:28602def _CheckIncludeOrderForScope(scope, input_api, file_path, changed_linenums):
603 """Checks that the lines in scope occur in the right order.
604
605 1. C system files in alphabetical order
606 2. C++ system files in alphabetical order
607 3. Project's .h files
608 """
609
610 c_system_include_pattern = input_api.re.compile(r'\s*#include <.*\.h>')
611 cpp_system_include_pattern = input_api.re.compile(r'\s*#include <.*>')
612 custom_include_pattern = input_api.re.compile(r'\s*#include ".*')
613
614 C_SYSTEM_INCLUDES, CPP_SYSTEM_INCLUDES, CUSTOM_INCLUDES = range(3)
615
616 state = C_SYSTEM_INCLUDES
617
618 previous_line = ''
[email protected]728b9bb2012-11-14 20:38:57619 previous_line_num = 0
[email protected]cf9b78f2012-11-14 11:40:28620 problem_linenums = []
621 for line_num, line in scope:
622 if c_system_include_pattern.match(line):
623 if state != C_SYSTEM_INCLUDES:
[email protected]728b9bb2012-11-14 20:38:57624 problem_linenums.append((line_num, previous_line_num))
[email protected]cf9b78f2012-11-14 11:40:28625 elif previous_line and previous_line > line:
[email protected]728b9bb2012-11-14 20:38:57626 problem_linenums.append((line_num, previous_line_num))
[email protected]cf9b78f2012-11-14 11:40:28627 elif cpp_system_include_pattern.match(line):
628 if state == C_SYSTEM_INCLUDES:
629 state = CPP_SYSTEM_INCLUDES
630 elif state == CUSTOM_INCLUDES:
[email protected]728b9bb2012-11-14 20:38:57631 problem_linenums.append((line_num, previous_line_num))
[email protected]cf9b78f2012-11-14 11:40:28632 elif previous_line and previous_line > line:
[email protected]728b9bb2012-11-14 20:38:57633 problem_linenums.append((line_num, previous_line_num))
[email protected]cf9b78f2012-11-14 11:40:28634 elif custom_include_pattern.match(line):
635 if state != CUSTOM_INCLUDES:
636 state = CUSTOM_INCLUDES
637 elif previous_line and previous_line > line:
[email protected]728b9bb2012-11-14 20:38:57638 problem_linenums.append((line_num, previous_line_num))
[email protected]cf9b78f2012-11-14 11:40:28639 else:
640 problem_linenums.append(line_num)
641 previous_line = line
[email protected]728b9bb2012-11-14 20:38:57642 previous_line_num = line_num
[email protected]cf9b78f2012-11-14 11:40:28643
644 warnings = []
[email protected]728b9bb2012-11-14 20:38:57645 for (line_num, previous_line_num) in problem_linenums:
646 if line_num in changed_linenums or previous_line_num in changed_linenums:
[email protected]cf9b78f2012-11-14 11:40:28647 warnings.append(' %s:%d' % (file_path, line_num))
648 return warnings
649
650
[email protected]ac294a12012-12-06 16:38:43651def _CheckIncludeOrderInFile(input_api, f, changed_linenums):
[email protected]cf9b78f2012-11-14 11:40:28652 """Checks the #include order for the given file f."""
653
[email protected]2299dcf2012-11-15 19:56:24654 system_include_pattern = input_api.re.compile(r'\s*#include \<.*')
[email protected]23093b62013-09-20 12:16:30655 # Exclude the following includes from the check:
656 # 1) #include <.../...>, e.g., <sys/...> includes often need to appear in a
657 # specific order.
658 # 2) <atlbase.h>, "build/build_config.h"
659 excluded_include_pattern = input_api.re.compile(
660 r'\s*#include (\<.*/.*|\<atlbase\.h\>|"build/build_config.h")')
[email protected]2299dcf2012-11-15 19:56:24661 custom_include_pattern = input_api.re.compile(r'\s*#include "(?P<FILE>.*)"')
[email protected]3e83618c2013-10-09 22:32:33662 # Match the final or penultimate token if it is xxxtest so we can ignore it
663 # when considering the special first include.
664 test_file_tag_pattern = input_api.re.compile(
665 r'_[a-z]+test(?=(_[a-zA-Z0-9]+)?\.)')
[email protected]0e5c1852012-12-18 20:17:11666 if_pattern = input_api.re.compile(
667 r'\s*#\s*(if|elif|else|endif|define|undef).*')
668 # Some files need specialized order of includes; exclude such files from this
669 # check.
670 uncheckable_includes_pattern = input_api.re.compile(
671 r'\s*#include '
672 '("ipc/.*macros\.h"|<windows\.h>|".*gl.*autogen.h")\s*')
[email protected]cf9b78f2012-11-14 11:40:28673
674 contents = f.NewContents()
675 warnings = []
676 line_num = 0
677
[email protected]ac294a12012-12-06 16:38:43678 # Handle the special first include. If the first include file is
679 # some/path/file.h, the corresponding including file can be some/path/file.cc,
680 # some/other/path/file.cc, some/path/file_platform.cc, some/path/file-suffix.h
681 # etc. It's also possible that no special first include exists.
[email protected]3e83618c2013-10-09 22:32:33682 # If the included file is some/path/file_platform.h the including file could
683 # also be some/path/file_xxxtest_platform.h.
684 including_file_base_name = test_file_tag_pattern.sub(
685 '', input_api.os_path.basename(f.LocalPath()))
686
[email protected]ac294a12012-12-06 16:38:43687 for line in contents:
688 line_num += 1
689 if system_include_pattern.match(line):
690 # No special first include -> process the line again along with normal
691 # includes.
692 line_num -= 1
693 break
694 match = custom_include_pattern.match(line)
695 if match:
696 match_dict = match.groupdict()
[email protected]3e83618c2013-10-09 22:32:33697 header_basename = test_file_tag_pattern.sub(
698 '', input_api.os_path.basename(match_dict['FILE'])).replace('.h', '')
699
700 if header_basename not in including_file_base_name:
[email protected]2299dcf2012-11-15 19:56:24701 # No special first include -> process the line again along with normal
702 # includes.
703 line_num -= 1
[email protected]ac294a12012-12-06 16:38:43704 break
[email protected]cf9b78f2012-11-14 11:40:28705
706 # Split into scopes: Each region between #if and #endif is its own scope.
707 scopes = []
708 current_scope = []
709 for line in contents[line_num:]:
710 line_num += 1
[email protected]0e5c1852012-12-18 20:17:11711 if uncheckable_includes_pattern.match(line):
[email protected]4436c9e2014-01-07 23:19:54712 continue
[email protected]2309b0fa02012-11-16 12:18:27713 if if_pattern.match(line):
[email protected]cf9b78f2012-11-14 11:40:28714 scopes.append(current_scope)
715 current_scope = []
[email protected]962f117e2012-11-22 18:11:56716 elif ((system_include_pattern.match(line) or
717 custom_include_pattern.match(line)) and
718 not excluded_include_pattern.match(line)):
[email protected]cf9b78f2012-11-14 11:40:28719 current_scope.append((line_num, line))
720 scopes.append(current_scope)
721
722 for scope in scopes:
723 warnings.extend(_CheckIncludeOrderForScope(scope, input_api, f.LocalPath(),
724 changed_linenums))
725 return warnings
726
727
728def _CheckIncludeOrder(input_api, output_api):
729 """Checks that the #include order is correct.
730
731 1. The corresponding header for source files.
732 2. C system files in alphabetical order
733 3. C++ system files in alphabetical order
734 4. Project's .h files in alphabetical order
735
[email protected]ac294a12012-12-06 16:38:43736 Each region separated by #if, #elif, #else, #endif, #define and #undef follows
737 these rules separately.
[email protected]cf9b78f2012-11-14 11:40:28738 """
[email protected]e120b012014-08-15 19:08:35739 def FileFilterIncludeOrder(affected_file):
740 black_list = (_EXCLUDED_PATHS + input_api.DEFAULT_BLACK_LIST)
741 return input_api.FilterSourceFile(affected_file, black_list=black_list)
[email protected]cf9b78f2012-11-14 11:40:28742
743 warnings = []
[email protected]e120b012014-08-15 19:08:35744 for f in input_api.AffectedFiles(file_filter=FileFilterIncludeOrder):
[email protected]ac294a12012-12-06 16:38:43745 if f.LocalPath().endswith(('.cc', '.h')):
746 changed_linenums = set(line_num for line_num, _ in f.ChangedContents())
747 warnings.extend(_CheckIncludeOrderInFile(input_api, f, changed_linenums))
[email protected]cf9b78f2012-11-14 11:40:28748
749 results = []
750 if warnings:
[email protected]f7051d52013-04-02 18:31:42751 results.append(output_api.PresubmitPromptOrNotify(_INCLUDE_ORDER_WARNING,
[email protected]120cf540d2012-12-10 17:55:53752 warnings))
[email protected]cf9b78f2012-11-14 11:40:28753 return results
754
755
[email protected]70ca77752012-11-20 03:45:03756def _CheckForVersionControlConflictsInFile(input_api, f):
757 pattern = input_api.re.compile('^(?:<<<<<<<|>>>>>>>) |^=======$')
758 errors = []
759 for line_num, line in f.ChangedContents():
760 if pattern.match(line):
761 errors.append(' %s:%d %s' % (f.LocalPath(), line_num, line))
762 return errors
763
764
765def _CheckForVersionControlConflicts(input_api, output_api):
766 """Usually this is not intentional and will cause a compile failure."""
767 errors = []
768 for f in input_api.AffectedFiles():
769 errors.extend(_CheckForVersionControlConflictsInFile(input_api, f))
770
771 results = []
772 if errors:
773 results.append(output_api.PresubmitError(
774 'Version control conflict markers found, please resolve.', errors))
775 return results
776
777
[email protected]06e6d0ff2012-12-11 01:36:44778def _CheckHardcodedGoogleHostsInLowerLayers(input_api, output_api):
779 def FilterFile(affected_file):
780 """Filter function for use with input_api.AffectedSourceFiles,
781 below. This filters out everything except non-test files from
782 top-level directories that generally speaking should not hard-code
783 service URLs (e.g. src/android_webview/, src/content/ and others).
784 """
785 return input_api.FilterSourceFile(
786 affected_file,
[email protected]78bb39d62012-12-11 15:11:56787 white_list=(r'^(android_webview|base|content|net)[\\\/].*', ),
[email protected]06e6d0ff2012-12-11 01:36:44788 black_list=(_EXCLUDED_PATHS +
789 _TEST_CODE_EXCLUDED_PATHS +
790 input_api.DEFAULT_BLACK_LIST))
791
[email protected]de4f7d22013-05-23 14:27:46792 base_pattern = '"[^"]*google\.com[^"]*"'
793 comment_pattern = input_api.re.compile('//.*%s' % base_pattern)
794 pattern = input_api.re.compile(base_pattern)
[email protected]06e6d0ff2012-12-11 01:36:44795 problems = [] # items are (filename, line_number, line)
796 for f in input_api.AffectedSourceFiles(FilterFile):
797 for line_num, line in f.ChangedContents():
[email protected]de4f7d22013-05-23 14:27:46798 if not comment_pattern.search(line) and pattern.search(line):
[email protected]06e6d0ff2012-12-11 01:36:44799 problems.append((f.LocalPath(), line_num, line))
800
801 if problems:
[email protected]f7051d52013-04-02 18:31:42802 return [output_api.PresubmitPromptOrNotify(
[email protected]06e6d0ff2012-12-11 01:36:44803 'Most layers below src/chrome/ should not hardcode service URLs.\n'
[email protected]b0149772014-03-27 16:47:58804 'Are you sure this is correct?',
[email protected]06e6d0ff2012-12-11 01:36:44805 [' %s:%d: %s' % (
806 problem[0], problem[1], problem[2]) for problem in problems])]
[email protected]2fdd1f362013-01-16 03:56:03807 else:
808 return []
[email protected]06e6d0ff2012-12-11 01:36:44809
810
[email protected]d2530012013-01-25 16:39:27811def _CheckNoAbbreviationInPngFileName(input_api, output_api):
812 """Makes sure there are no abbreviations in the name of PNG files.
813 """
[email protected]4053a48e2013-01-25 21:43:04814 pattern = input_api.re.compile(r'.*_[a-z]_.*\.png$|.*_[a-z]\.png$')
[email protected]d2530012013-01-25 16:39:27815 errors = []
816 for f in input_api.AffectedFiles(include_deletes=False):
817 if pattern.match(f.LocalPath()):
818 errors.append(' %s' % f.LocalPath())
819
820 results = []
821 if errors:
822 results.append(output_api.PresubmitError(
823 'The name of PNG files should not have abbreviations. \n'
824 'Use _hover.png, _center.png, instead of _h.png, _c.png.\n'
825 'Contact [email protected] if you have questions.', errors))
826 return results
827
828
[email protected]14a6131c2014-01-08 01:15:41829def _FilesToCheckForIncomingDeps(re, changed_lines):
[email protected]f32e2d1e2013-07-26 21:39:08830 """Helper method for _CheckAddedDepsHaveTargetApprovals. Returns
[email protected]14a6131c2014-01-08 01:15:41831 a set of DEPS entries that we should look up.
832
833 For a directory (rather than a specific filename) we fake a path to
834 a specific filename by adding /DEPS. This is chosen as a file that
835 will seldom or never be subject to per-file include_rules.
836 """
[email protected]2b438d62013-11-14 17:54:14837 # We ignore deps entries on auto-generated directories.
838 AUTO_GENERATED_DIRS = ['grit', 'jni']
[email protected]f32e2d1e2013-07-26 21:39:08839
840 # This pattern grabs the path without basename in the first
841 # parentheses, and the basename (if present) in the second. It
842 # relies on the simple heuristic that if there is a basename it will
843 # be a header file ending in ".h".
844 pattern = re.compile(
845 r"""['"]\+([^'"]+?)(/[a-zA-Z0-9_]+\.h)?['"].*""")
[email protected]2b438d62013-11-14 17:54:14846 results = set()
[email protected]f32e2d1e2013-07-26 21:39:08847 for changed_line in changed_lines:
848 m = pattern.match(changed_line)
849 if m:
850 path = m.group(1)
[email protected]2b438d62013-11-14 17:54:14851 if path.split('/')[0] not in AUTO_GENERATED_DIRS:
[email protected]14a6131c2014-01-08 01:15:41852 if m.group(2):
853 results.add('%s%s' % (path, m.group(2)))
854 else:
855 results.add('%s/DEPS' % path)
[email protected]f32e2d1e2013-07-26 21:39:08856 return results
857
858
[email protected]e871964c2013-05-13 14:14:55859def _CheckAddedDepsHaveTargetApprovals(input_api, output_api):
860 """When a dependency prefixed with + is added to a DEPS file, we
861 want to make sure that the change is reviewed by an OWNER of the
862 target file or directory, to avoid layering violations from being
863 introduced. This check verifies that this happens.
864 """
865 changed_lines = set()
866 for f in input_api.AffectedFiles():
867 filename = input_api.os_path.basename(f.LocalPath())
868 if filename == 'DEPS':
869 changed_lines |= set(line.strip()
870 for line_num, line
871 in f.ChangedContents())
872 if not changed_lines:
873 return []
874
[email protected]14a6131c2014-01-08 01:15:41875 virtual_depended_on_files = _FilesToCheckForIncomingDeps(input_api.re,
876 changed_lines)
[email protected]e871964c2013-05-13 14:14:55877 if not virtual_depended_on_files:
878 return []
879
880 if input_api.is_committing:
881 if input_api.tbr:
882 return [output_api.PresubmitNotifyResult(
883 '--tbr was specified, skipping OWNERS check for DEPS additions')]
884 if not input_api.change.issue:
885 return [output_api.PresubmitError(
886 "DEPS approval by OWNERS check failed: this change has "
887 "no Rietveld issue number, so we can't check it for approvals.")]
888 output = output_api.PresubmitError
889 else:
890 output = output_api.PresubmitNotifyResult
891
892 owners_db = input_api.owners_db
893 owner_email, reviewers = input_api.canned_checks._RietveldOwnerAndReviewers(
894 input_api,
895 owners_db.email_regexp,
896 approval_needed=input_api.is_committing)
897
898 owner_email = owner_email or input_api.change.author_email
899
[email protected]de4f7d22013-05-23 14:27:46900 reviewers_plus_owner = set(reviewers)
[email protected]e71c6082013-05-22 02:28:51901 if owner_email:
[email protected]de4f7d22013-05-23 14:27:46902 reviewers_plus_owner.add(owner_email)
[email protected]e871964c2013-05-13 14:14:55903 missing_files = owners_db.files_not_covered_by(virtual_depended_on_files,
904 reviewers_plus_owner)
[email protected]14a6131c2014-01-08 01:15:41905
906 # We strip the /DEPS part that was added by
907 # _FilesToCheckForIncomingDeps to fake a path to a file in a
908 # directory.
909 def StripDeps(path):
910 start_deps = path.rfind('/DEPS')
911 if start_deps != -1:
912 return path[:start_deps]
913 else:
914 return path
915 unapproved_dependencies = ["'+%s'," % StripDeps(path)
[email protected]e871964c2013-05-13 14:14:55916 for path in missing_files]
917
918 if unapproved_dependencies:
919 output_list = [
[email protected]14a6131c2014-01-08 01:15:41920 output('Missing LGTM from OWNERS of dependencies added to DEPS:\n %s' %
[email protected]e871964c2013-05-13 14:14:55921 '\n '.join(sorted(unapproved_dependencies)))]
922 if not input_api.is_committing:
923 suggested_owners = owners_db.reviewers_for(missing_files, owner_email)
924 output_list.append(output(
925 'Suggested missing target path OWNERS:\n %s' %
926 '\n '.join(suggested_owners or [])))
927 return output_list
928
929 return []
930
931
[email protected]85218562013-11-22 07:41:40932def _CheckSpamLogging(input_api, output_api):
933 file_inclusion_pattern = r'.+%s' % _IMPLEMENTATION_EXTENSIONS
934 black_list = (_EXCLUDED_PATHS +
935 _TEST_CODE_EXCLUDED_PATHS +
936 input_api.DEFAULT_BLACK_LIST +
[email protected]6f742dd02013-11-26 23:19:50937 (r"^base[\\\/]logging\.h$",
[email protected]80f360a2014-01-23 01:36:19938 r"^base[\\\/]logging\.cc$",
[email protected]8dc338c2013-12-09 16:28:48939 r"^chrome[\\\/]app[\\\/]chrome_main_delegate\.cc$",
[email protected]6e268db2013-12-04 01:41:46940 r"^chrome[\\\/]browser[\\\/]chrome_browser_main\.cc$",
[email protected]4de75262013-12-18 23:16:12941 r"^chrome[\\\/]browser[\\\/]ui[\\\/]startup[\\\/]"
942 r"startup_browser_creator\.cc$",
[email protected]fe0e6e12013-12-04 05:52:58943 r"^chrome[\\\/]installer[\\\/]setup[\\\/].*",
[email protected]8cf6f842014-08-08 21:33:16944 r"chrome[\\\/]browser[\\\/]diagnostics[\\\/]" +
[email protected]f5b9a3f342014-08-08 22:06:03945 r"diagnostics_writer\.cc$",
[email protected]9f13b602014-08-07 02:59:15946 r"^chrome_elf[\\\/]dll_hash[\\\/]dll_hash_main\.cc$",
947 r"^chromecast[\\\/]",
948 r"^cloud_print[\\\/]",
[email protected]9056e732014-01-08 06:25:25949 r"^content[\\\/]common[\\\/]gpu[\\\/]client[\\\/]"
950 r"gl_helper_benchmark\.cc$",
thestigc9e38a22014-09-13 01:02:11951 r"^courgette[\\\/]courgette_tool\.cc$",
[email protected]9f13b602014-08-07 02:59:15952 r"^extensions[\\\/]renderer[\\\/]logging_native_handler\.cc$",
[email protected]9c36d922014-03-24 16:47:52953 r"^native_client_sdk[\\\/]",
[email protected]cdbdced2013-11-27 21:35:50954 r"^remoting[\\\/]base[\\\/]logging\.h$",
[email protected]67c96ab2013-12-17 02:05:36955 r"^remoting[\\\/]host[\\\/].*",
[email protected]8232f8fd2013-12-14 00:52:31956 r"^sandbox[\\\/]linux[\\\/].*",
[email protected]0b7a21e2014-02-11 18:38:13957 r"^tools[\\\/]",
thestig22dfc4012014-09-05 08:29:44958 r"^ui[\\\/]aura[\\\/]bench[\\\/]bench_main\.cc$",
959 r"^webkit[\\\/]browser[\\\/]fileapi[\\\/]" +
960 r"dump_file_system.cc$",))
[email protected]85218562013-11-22 07:41:40961 source_file_filter = lambda x: input_api.FilterSourceFile(
962 x, white_list=(file_inclusion_pattern,), black_list=black_list)
963
964 log_info = []
965 printf = []
966
967 for f in input_api.AffectedSourceFiles(source_file_filter):
968 contents = input_api.ReadFile(f, 'rb')
mohan.reddyf21db962014-10-16 12:26:47969 if input_api.re.search(r"\bD?LOG\s*\(\s*INFO\s*\)", contents):
[email protected]85218562013-11-22 07:41:40970 log_info.append(f.LocalPath())
mohan.reddyf21db962014-10-16 12:26:47971 elif input_api.re.search(r"\bD?LOG_IF\s*\(\s*INFO\s*,", contents):
[email protected]85210652013-11-28 05:50:13972 log_info.append(f.LocalPath())
[email protected]18b466b2013-12-02 22:01:37973
mohan.reddyf21db962014-10-16 12:26:47974 if input_api.re.search(r"\bprintf\(", contents):
[email protected]18b466b2013-12-02 22:01:37975 printf.append(f.LocalPath())
mohan.reddyf21db962014-10-16 12:26:47976 elif input_api.re.search(r"\bfprintf\((stdout|stderr)", contents):
[email protected]85218562013-11-22 07:41:40977 printf.append(f.LocalPath())
978
979 if log_info:
980 return [output_api.PresubmitError(
981 'These files spam the console log with LOG(INFO):',
982 items=log_info)]
983 if printf:
984 return [output_api.PresubmitError(
985 'These files spam the console log with printf/fprintf:',
986 items=printf)]
987 return []
988
989
[email protected]49aa76a2013-12-04 06:59:16990def _CheckForAnonymousVariables(input_api, output_api):
991 """These types are all expected to hold locks while in scope and
992 so should never be anonymous (which causes them to be immediately
993 destroyed)."""
994 they_who_must_be_named = [
995 'base::AutoLock',
996 'base::AutoReset',
997 'base::AutoUnlock',
998 'SkAutoAlphaRestore',
999 'SkAutoBitmapShaderInstall',
1000 'SkAutoBlitterChoose',
1001 'SkAutoBounderCommit',
1002 'SkAutoCallProc',
1003 'SkAutoCanvasRestore',
1004 'SkAutoCommentBlock',
1005 'SkAutoDescriptor',
1006 'SkAutoDisableDirectionCheck',
1007 'SkAutoDisableOvalCheck',
1008 'SkAutoFree',
1009 'SkAutoGlyphCache',
1010 'SkAutoHDC',
1011 'SkAutoLockColors',
1012 'SkAutoLockPixels',
1013 'SkAutoMalloc',
1014 'SkAutoMaskFreeImage',
1015 'SkAutoMutexAcquire',
1016 'SkAutoPathBoundsUpdate',
1017 'SkAutoPDFRelease',
1018 'SkAutoRasterClipValidate',
1019 'SkAutoRef',
1020 'SkAutoTime',
1021 'SkAutoTrace',
1022 'SkAutoUnref',
1023 ]
1024 anonymous = r'(%s)\s*[({]' % '|'.join(they_who_must_be_named)
1025 # bad: base::AutoLock(lock.get());
1026 # not bad: base::AutoLock lock(lock.get());
1027 bad_pattern = input_api.re.compile(anonymous)
1028 # good: new base::AutoLock(lock.get())
1029 good_pattern = input_api.re.compile(r'\bnew\s*' + anonymous)
1030 errors = []
1031
1032 for f in input_api.AffectedFiles():
1033 if not f.LocalPath().endswith(('.cc', '.h', '.inl', '.m', '.mm')):
1034 continue
1035 for linenum, line in f.ChangedContents():
1036 if bad_pattern.search(line) and not good_pattern.search(line):
1037 errors.append('%s:%d' % (f.LocalPath(), linenum))
1038
1039 if errors:
1040 return [output_api.PresubmitError(
1041 'These lines create anonymous variables that need to be named:',
1042 items=errors)]
1043 return []
1044
1045
[email protected]5fe0f8742013-11-29 01:04:591046def _CheckCygwinShell(input_api, output_api):
1047 source_file_filter = lambda x: input_api.FilterSourceFile(
1048 x, white_list=(r'.+\.(gyp|gypi)$',))
1049 cygwin_shell = []
1050
1051 for f in input_api.AffectedSourceFiles(source_file_filter):
1052 for linenum, line in f.ChangedContents():
1053 if 'msvs_cygwin_shell' in line:
1054 cygwin_shell.append(f.LocalPath())
1055 break
1056
1057 if cygwin_shell:
1058 return [output_api.PresubmitError(
1059 'These files should not use msvs_cygwin_shell (the default is 0):',
1060 items=cygwin_shell)]
1061 return []
1062
[email protected]85218562013-11-22 07:41:401063
[email protected]999261d2014-03-03 20:08:081064def _CheckUserActionUpdate(input_api, output_api):
1065 """Checks if any new user action has been added."""
[email protected]2f92dec2014-03-07 19:21:521066 if any('actions.xml' == input_api.os_path.basename(f) for f in
[email protected]999261d2014-03-03 20:08:081067 input_api.LocalPaths()):
[email protected]2f92dec2014-03-07 19:21:521068 # If actions.xml is already included in the changelist, the PRESUBMIT
1069 # for actions.xml will do a more complete presubmit check.
[email protected]999261d2014-03-03 20:08:081070 return []
1071
[email protected]999261d2014-03-03 20:08:081072 file_filter = lambda f: f.LocalPath().endswith(('.cc', '.mm'))
1073 action_re = r'[^a-zA-Z]UserMetricsAction\("([^"]*)'
[email protected]2f92dec2014-03-07 19:21:521074 current_actions = None
[email protected]999261d2014-03-03 20:08:081075 for f in input_api.AffectedFiles(file_filter=file_filter):
1076 for line_num, line in f.ChangedContents():
1077 match = input_api.re.search(action_re, line)
1078 if match:
[email protected]2f92dec2014-03-07 19:21:521079 # Loads contents in tools/metrics/actions/actions.xml to memory. It's
1080 # loaded only once.
1081 if not current_actions:
1082 with open('tools/metrics/actions/actions.xml') as actions_f:
1083 current_actions = actions_f.read()
1084 # Search for the matched user action name in |current_actions|.
[email protected]999261d2014-03-03 20:08:081085 for action_name in match.groups():
[email protected]2f92dec2014-03-07 19:21:521086 action = 'name="{0}"'.format(action_name)
1087 if action not in current_actions:
[email protected]999261d2014-03-03 20:08:081088 return [output_api.PresubmitPromptWarning(
1089 'File %s line %d: %s is missing in '
[email protected]2f92dec2014-03-07 19:21:521090 'tools/metrics/actions/actions.xml. Please run '
1091 'tools/metrics/actions/extract_actions.py to update.'
[email protected]999261d2014-03-03 20:08:081092 % (f.LocalPath(), line_num, action_name))]
1093 return []
1094
1095
[email protected]99171a92014-06-03 08:44:471096def _GetJSONParseError(input_api, filename, eat_comments=True):
1097 try:
1098 contents = input_api.ReadFile(filename)
1099 if eat_comments:
1100 json_comment_eater = input_api.os_path.join(
1101 input_api.PresubmitLocalPath(),
1102 'tools', 'json_comment_eater', 'json_comment_eater.py')
1103 process = input_api.subprocess.Popen(
1104 [input_api.python_executable, json_comment_eater],
1105 stdin=input_api.subprocess.PIPE,
1106 stdout=input_api.subprocess.PIPE,
1107 universal_newlines=True)
1108 (contents, _) = process.communicate(input=contents)
1109
1110 input_api.json.loads(contents)
1111 except ValueError as e:
1112 return e
1113 return None
1114
1115
1116def _GetIDLParseError(input_api, filename):
1117 try:
1118 contents = input_api.ReadFile(filename)
1119 idl_schema = input_api.os_path.join(
1120 input_api.PresubmitLocalPath(),
1121 'tools', 'json_schema_compiler', 'idl_schema.py')
1122 process = input_api.subprocess.Popen(
1123 [input_api.python_executable, idl_schema],
1124 stdin=input_api.subprocess.PIPE,
1125 stdout=input_api.subprocess.PIPE,
1126 stderr=input_api.subprocess.PIPE,
1127 universal_newlines=True)
1128 (_, error) = process.communicate(input=contents)
1129 return error or None
1130 except ValueError as e:
1131 return e
1132
1133
1134def _CheckParseErrors(input_api, output_api):
1135 """Check that IDL and JSON files do not contain syntax errors."""
1136 actions = {
1137 '.idl': _GetIDLParseError,
1138 '.json': _GetJSONParseError,
1139 }
1140 # These paths contain test data and other known invalid JSON files.
1141 excluded_patterns = [
joaodasilva718f87672014-08-30 09:25:491142 r'test[\\\/]data[\\\/]',
1143 r'^components[\\\/]policy[\\\/]resources[\\\/]policy_templates\.json$',
[email protected]99171a92014-06-03 08:44:471144 ]
1145 # Most JSON files are preprocessed and support comments, but these do not.
1146 json_no_comments_patterns = [
joaodasilva718f87672014-08-30 09:25:491147 r'^testing[\\\/]',
[email protected]99171a92014-06-03 08:44:471148 ]
1149 # Only run IDL checker on files in these directories.
1150 idl_included_patterns = [
joaodasilva718f87672014-08-30 09:25:491151 r'^chrome[\\\/]common[\\\/]extensions[\\\/]api[\\\/]',
1152 r'^extensions[\\\/]common[\\\/]api[\\\/]',
[email protected]99171a92014-06-03 08:44:471153 ]
1154
1155 def get_action(affected_file):
1156 filename = affected_file.LocalPath()
1157 return actions.get(input_api.os_path.splitext(filename)[1])
1158
1159 def MatchesFile(patterns, path):
1160 for pattern in patterns:
1161 if input_api.re.search(pattern, path):
1162 return True
1163 return False
1164
1165 def FilterFile(affected_file):
1166 action = get_action(affected_file)
1167 if not action:
1168 return False
1169 path = affected_file.LocalPath()
1170
1171 if MatchesFile(excluded_patterns, path):
1172 return False
1173
1174 if (action == _GetIDLParseError and
1175 not MatchesFile(idl_included_patterns, path)):
1176 return False
1177 return True
1178
1179 results = []
1180 for affected_file in input_api.AffectedFiles(
1181 file_filter=FilterFile, include_deletes=False):
1182 action = get_action(affected_file)
1183 kwargs = {}
1184 if (action == _GetJSONParseError and
1185 MatchesFile(json_no_comments_patterns, affected_file.LocalPath())):
1186 kwargs['eat_comments'] = False
1187 parse_error = action(input_api,
1188 affected_file.AbsoluteLocalPath(),
1189 **kwargs)
1190 if parse_error:
1191 results.append(output_api.PresubmitError('%s could not be parsed: %s' %
1192 (affected_file.LocalPath(), parse_error)))
1193 return results
1194
1195
[email protected]760deea2013-12-10 19:33:491196def _CheckJavaStyle(input_api, output_api):
1197 """Runs checkstyle on changed java files and returns errors if any exist."""
mohan.reddyf21db962014-10-16 12:26:471198 import sys
[email protected]760deea2013-12-10 19:33:491199 original_sys_path = sys.path
1200 try:
1201 sys.path = sys.path + [input_api.os_path.join(
1202 input_api.PresubmitLocalPath(), 'tools', 'android', 'checkstyle')]
1203 import checkstyle
1204 finally:
1205 # Restore sys.path to what it was before.
1206 sys.path = original_sys_path
1207
1208 return checkstyle.RunCheckstyle(
1209 input_api, output_api, 'tools/android/checkstyle/chromium-style-5.0.xml')
1210
1211
[email protected]fd20b902014-05-09 02:14:531212_DEPRECATED_CSS = [
1213 # Values
1214 ( "-webkit-box", "flex" ),
1215 ( "-webkit-inline-box", "inline-flex" ),
1216 ( "-webkit-flex", "flex" ),
1217 ( "-webkit-inline-flex", "inline-flex" ),
1218 ( "-webkit-min-content", "min-content" ),
1219 ( "-webkit-max-content", "max-content" ),
1220
1221 # Properties
1222 ( "-webkit-background-clip", "background-clip" ),
1223 ( "-webkit-background-origin", "background-origin" ),
1224 ( "-webkit-background-size", "background-size" ),
1225 ( "-webkit-box-shadow", "box-shadow" ),
1226
1227 # Functions
1228 ( "-webkit-gradient", "gradient" ),
1229 ( "-webkit-repeating-gradient", "repeating-gradient" ),
1230 ( "-webkit-linear-gradient", "linear-gradient" ),
1231 ( "-webkit-repeating-linear-gradient", "repeating-linear-gradient" ),
1232 ( "-webkit-radial-gradient", "radial-gradient" ),
1233 ( "-webkit-repeating-radial-gradient", "repeating-radial-gradient" ),
1234]
1235
1236def _CheckNoDeprecatedCSS(input_api, output_api):
1237 """ Make sure that we don't use deprecated CSS
[email protected]9a48e3f82014-05-22 00:06:251238 properties, functions or values. Our external
1239 documentation is ignored by the hooks as it
1240 needs to be consumed by WebKit. """
[email protected]fd20b902014-05-09 02:14:531241 results = []
[email protected]9a48e3f82014-05-22 00:06:251242 file_inclusion_pattern = (r".+\.css$")
1243 black_list = (_EXCLUDED_PATHS +
1244 _TEST_CODE_EXCLUDED_PATHS +
1245 input_api.DEFAULT_BLACK_LIST +
1246 (r"^chrome/common/extensions/docs",
1247 r"^chrome/docs",
1248 r"^native_client_sdk"))
1249 file_filter = lambda f: input_api.FilterSourceFile(
1250 f, white_list=file_inclusion_pattern, black_list=black_list)
[email protected]fd20b902014-05-09 02:14:531251 for fpath in input_api.AffectedFiles(file_filter=file_filter):
1252 for line_num, line in fpath.ChangedContents():
1253 for (deprecated_value, value) in _DEPRECATED_CSS:
1254 if input_api.re.search(deprecated_value, line):
1255 results.append(output_api.PresubmitError(
1256 "%s:%d: Use of deprecated CSS %s, use %s instead" %
1257 (fpath.LocalPath(), line_num, deprecated_value, value)))
1258 return results
1259
mohan.reddyf21db962014-10-16 12:26:471260
1261def _CheckForOverrideAndFinalRules(input_api, output_api):
1262 """Checks for final and override used as per C++11"""
1263 problems = []
1264 for f in input_api.AffectedFiles():
1265 if (f.LocalPath().endswith(('.cc', '.cpp', '.h', '.mm'))):
1266 for line_num, line in f.ChangedContents():
1267 if (input_api.re.search(r'\b(FINAL|OVERRIDE)\b', line)):
1268 problems.append(' %s:%d' % (f.LocalPath(), line_num))
1269
1270 if not problems:
1271 return []
1272 return [output_api.PresubmitError('Use C++11\'s |final| and |override| '
1273 'rather than FINAL and OVERRIDE.',
1274 problems)]
1275
1276
[email protected]22c9bd72011-03-27 16:47:391277def _CommonChecks(input_api, output_api):
1278 """Checks common to both upload and commit."""
1279 results = []
1280 results.extend(input_api.canned_checks.PanProjectChecks(
[email protected]3de922f2013-12-20 13:27:381281 input_api, output_api,
1282 excluded_paths=_EXCLUDED_PATHS + _TESTRUNNER_PATHS))
[email protected]66daa702011-05-28 14:41:461283 results.extend(_CheckAuthorizedAuthor(input_api, output_api))
[email protected]55459852011-08-10 15:17:191284 results.extend(
[email protected]760deea2013-12-10 19:33:491285 _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api))
[email protected]10689ca2011-09-02 02:31:541286 results.extend(_CheckNoIOStreamInHeaders(input_api, output_api))
[email protected]72df4e782012-06-21 16:28:181287 results.extend(_CheckNoUNIT_TESTInSourceFiles(input_api, output_api))
[email protected]8ea5d4b2011-09-13 21:49:221288 results.extend(_CheckNoNewWStrings(input_api, output_api))
[email protected]2a8ac9c2011-10-19 17:20:441289 results.extend(_CheckNoDEPSGIT(input_api, output_api))
[email protected]127f18ec2012-06-16 05:05:591290 results.extend(_CheckNoBannedFunctions(input_api, output_api))
[email protected]6c063c62012-07-11 19:11:061291 results.extend(_CheckNoPragmaOnce(input_api, output_api))
[email protected]e7479052012-09-19 00:26:121292 results.extend(_CheckNoTrinaryTrueFalse(input_api, output_api))
[email protected]55f9f382012-07-31 11:02:181293 results.extend(_CheckUnwantedDependencies(input_api, output_api))
[email protected]fbcafe5a2012-08-08 15:31:221294 results.extend(_CheckFilePermissions(input_api, output_api))
[email protected]c8278b32012-10-30 20:35:491295 results.extend(_CheckNoAuraWindowPropertyHInHeaders(input_api, output_api))
[email protected]2309b0fa02012-11-16 12:18:271296 results.extend(_CheckIncludeOrder(input_api, output_api))
[email protected]70ca77752012-11-20 03:45:031297 results.extend(_CheckForVersionControlConflicts(input_api, output_api))
[email protected]b8079ae4a2012-12-05 19:56:491298 results.extend(_CheckPatchFiles(input_api, output_api))
[email protected]06e6d0ff2012-12-11 01:36:441299 results.extend(_CheckHardcodedGoogleHostsInLowerLayers(input_api, output_api))
[email protected]d2530012013-01-25 16:39:271300 results.extend(_CheckNoAbbreviationInPngFileName(input_api, output_api))
[email protected]b00342e7f2013-03-26 16:21:541301 results.extend(_CheckForInvalidOSMacros(input_api, output_api))
lliabraa35bab3932014-10-01 12:16:441302 results.extend(_CheckForInvalidIfDefinedMacros(input_api, output_api))
danakj3c84d0c2014-10-06 15:35:461303 # TODO(danakj): Remove this when base/move.h is removed.
1304 results.extend(_CheckForUsingSideEffectsOfPass(input_api, output_api))
[email protected]e871964c2013-05-13 14:14:551305 results.extend(_CheckAddedDepsHaveTargetApprovals(input_api, output_api))
[email protected]9f919cc2013-07-31 03:04:041306 results.extend(
1307 input_api.canned_checks.CheckChangeHasNoTabs(
1308 input_api,
1309 output_api,
1310 source_file_filter=lambda x: x.LocalPath().endswith('.grd')))
[email protected]85218562013-11-22 07:41:401311 results.extend(_CheckSpamLogging(input_api, output_api))
[email protected]49aa76a2013-12-04 06:59:161312 results.extend(_CheckForAnonymousVariables(input_api, output_api))
[email protected]5fe0f8742013-11-29 01:04:591313 results.extend(_CheckCygwinShell(input_api, output_api))
[email protected]999261d2014-03-03 20:08:081314 results.extend(_CheckUserActionUpdate(input_api, output_api))
[email protected]fd20b902014-05-09 02:14:531315 results.extend(_CheckNoDeprecatedCSS(input_api, output_api))
[email protected]99171a92014-06-03 08:44:471316 results.extend(_CheckParseErrors(input_api, output_api))
mlamouria82272622014-09-16 18:45:041317 results.extend(_CheckForIPCRules(input_api, output_api))
mohan.reddyf21db962014-10-16 12:26:471318 results.extend(_CheckForOverrideAndFinalRules(input_api, output_api))
[email protected]2299dcf2012-11-15 19:56:241319
1320 if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()):
1321 results.extend(input_api.canned_checks.RunUnitTestsInDirectory(
1322 input_api, output_api,
1323 input_api.PresubmitLocalPath(),
[email protected]6be63382013-01-21 15:42:381324 whitelist=[r'^PRESUBMIT_test\.py$']))
[email protected]22c9bd72011-03-27 16:47:391325 return results
[email protected]1f7b4172010-01-28 01:17:341326
[email protected]b337cb5b2011-01-23 21:24:051327
[email protected]66daa702011-05-28 14:41:461328def _CheckAuthorizedAuthor(input_api, output_api):
1329 """For non-googler/chromites committers, verify the author's email address is
1330 in AUTHORS.
1331 """
[email protected]9bb9cb82011-06-13 20:43:011332 # TODO(maruel): Add it to input_api?
1333 import fnmatch
1334
[email protected]66daa702011-05-28 14:41:461335 author = input_api.change.author_email
[email protected]9bb9cb82011-06-13 20:43:011336 if not author:
1337 input_api.logging.info('No author, skipping AUTHOR check')
[email protected]66daa702011-05-28 14:41:461338 return []
[email protected]c99663292011-05-31 19:46:081339 authors_path = input_api.os_path.join(
[email protected]66daa702011-05-28 14:41:461340 input_api.PresubmitLocalPath(), 'AUTHORS')
1341 valid_authors = (
1342 input_api.re.match(r'[^#]+\s+\<(.+?)\>\s*$', line)
1343 for line in open(authors_path))
[email protected]ac54b132011-06-06 18:11:181344 valid_authors = [item.group(1).lower() for item in valid_authors if item]
[email protected]d8b50be2011-06-15 14:19:441345 if not any(fnmatch.fnmatch(author.lower(), valid) for valid in valid_authors):
[email protected]5861efb2013-01-07 18:33:231346 input_api.logging.info('Valid authors are %s', ', '.join(valid_authors))
[email protected]66daa702011-05-28 14:41:461347 return [output_api.PresubmitPromptWarning(
1348 ('%s is not in AUTHORS file. If you are a new contributor, please visit'
1349 '\n'
1350 'http://www.chromium.org/developers/contributing-code and read the '
1351 '"Legal" section\n'
1352 'If you are a chromite, verify the contributor signed the CLA.') %
1353 author)]
1354 return []
1355
1356
[email protected]b8079ae4a2012-12-05 19:56:491357def _CheckPatchFiles(input_api, output_api):
1358 problems = [f.LocalPath() for f in input_api.AffectedFiles()
1359 if f.LocalPath().endswith(('.orig', '.rej'))]
1360 if problems:
1361 return [output_api.PresubmitError(
1362 "Don't commit .rej and .orig files.", problems)]
[email protected]2fdd1f362013-01-16 03:56:031363 else:
1364 return []
[email protected]b8079ae4a2012-12-05 19:56:491365
1366
[email protected]b00342e7f2013-03-26 16:21:541367def _DidYouMeanOSMacro(bad_macro):
1368 try:
1369 return {'A': 'OS_ANDROID',
1370 'B': 'OS_BSD',
1371 'C': 'OS_CHROMEOS',
1372 'F': 'OS_FREEBSD',
1373 'L': 'OS_LINUX',
1374 'M': 'OS_MACOSX',
1375 'N': 'OS_NACL',
1376 'O': 'OS_OPENBSD',
1377 'P': 'OS_POSIX',
1378 'S': 'OS_SOLARIS',
1379 'W': 'OS_WIN'}[bad_macro[3].upper()]
1380 except KeyError:
1381 return ''
1382
1383
1384def _CheckForInvalidOSMacrosInFile(input_api, f):
1385 """Check for sensible looking, totally invalid OS macros."""
1386 preprocessor_statement = input_api.re.compile(r'^\s*#')
1387 os_macro = input_api.re.compile(r'defined\((OS_[^)]+)\)')
1388 results = []
1389 for lnum, line in f.ChangedContents():
1390 if preprocessor_statement.search(line):
1391 for match in os_macro.finditer(line):
1392 if not match.group(1) in _VALID_OS_MACROS:
1393 good = _DidYouMeanOSMacro(match.group(1))
1394 did_you_mean = ' (did you mean %s?)' % good if good else ''
1395 results.append(' %s:%d %s%s' % (f.LocalPath(),
1396 lnum,
1397 match.group(1),
1398 did_you_mean))
1399 return results
1400
1401
1402def _CheckForInvalidOSMacros(input_api, output_api):
1403 """Check all affected files for invalid OS macros."""
1404 bad_macros = []
1405 for f in input_api.AffectedFiles():
1406 if not f.LocalPath().endswith(('.py', '.js', '.html', '.css')):
1407 bad_macros.extend(_CheckForInvalidOSMacrosInFile(input_api, f))
1408
1409 if not bad_macros:
1410 return []
1411
1412 return [output_api.PresubmitError(
1413 'Possibly invalid OS macro[s] found. Please fix your code\n'
1414 'or add your macro to src/PRESUBMIT.py.', bad_macros)]
1415
lliabraa35bab3932014-10-01 12:16:441416
1417def _CheckForInvalidIfDefinedMacrosInFile(input_api, f):
1418 """Check all affected files for invalid "if defined" macros."""
1419 ALWAYS_DEFINED_MACROS = (
1420 "TARGET_CPU_PPC",
1421 "TARGET_CPU_PPC64",
1422 "TARGET_CPU_68K",
1423 "TARGET_CPU_X86",
1424 "TARGET_CPU_ARM",
1425 "TARGET_CPU_MIPS",
1426 "TARGET_CPU_SPARC",
1427 "TARGET_CPU_ALPHA",
1428 "TARGET_IPHONE_SIMULATOR",
1429 "TARGET_OS_EMBEDDED",
1430 "TARGET_OS_IPHONE",
1431 "TARGET_OS_MAC",
1432 "TARGET_OS_UNIX",
1433 "TARGET_OS_WIN32",
1434 )
1435 ifdef_macro = input_api.re.compile(r'^\s*#.*(?:ifdef\s|defined\()([^\s\)]+)')
1436 results = []
1437 for lnum, line in f.ChangedContents():
1438 for match in ifdef_macro.finditer(line):
1439 if match.group(1) in ALWAYS_DEFINED_MACROS:
1440 always_defined = ' %s is always defined. ' % match.group(1)
1441 did_you_mean = 'Did you mean \'#if %s\'?' % match.group(1)
1442 results.append(' %s:%d %s\n\t%s' % (f.LocalPath(),
1443 lnum,
1444 always_defined,
1445 did_you_mean))
1446 return results
1447
1448
1449def _CheckForInvalidIfDefinedMacros(input_api, output_api):
1450 """Check all affected files for invalid "if defined" macros."""
1451 bad_macros = []
1452 for f in input_api.AffectedFiles():
1453 if f.LocalPath().endswith(('.h', '.c', '.cc', '.m', '.mm')):
1454 bad_macros.extend(_CheckForInvalidIfDefinedMacrosInFile(input_api, f))
1455
1456 if not bad_macros:
1457 return []
1458
1459 return [output_api.PresubmitError(
1460 'Found ifdef check on always-defined macro[s]. Please fix your code\n'
1461 'or check the list of ALWAYS_DEFINED_MACROS in src/PRESUBMIT.py.',
1462 bad_macros)]
1463
1464
danakj3c84d0c2014-10-06 15:35:461465def _CheckForUsingSideEffectsOfPass(input_api, output_api):
1466 """Check all affected files for using side effects of Pass."""
1467 errors = []
1468 for f in input_api.AffectedFiles():
1469 if f.LocalPath().endswith(('.h', '.c', '.cc', '.m', '.mm')):
1470 for lnum, line in f.ChangedContents():
1471 # Disallow Foo(*my_scoped_thing.Pass()); See crbug.com/418297.
mohan.reddyf21db962014-10-16 12:26:471472 if input_api.re.search(r'\*[a-zA-Z0-9_]+\.Pass\(\)', line):
danakj3c84d0c2014-10-06 15:35:461473 errors.append(output_api.PresubmitError(
1474 ('%s:%d uses *foo.Pass() to delete the contents of scoped_ptr. ' +
1475 'See crbug.com/418297.') % (f.LocalPath(), lnum)))
1476 return errors
1477
1478
mlamouria82272622014-09-16 18:45:041479def _CheckForIPCRules(input_api, output_api):
1480 """Check for same IPC rules described in
1481 http://www.chromium.org/Home/chromium-security/education/security-tips-for-ipc
1482 """
1483 base_pattern = r'IPC_ENUM_TRAITS\('
1484 inclusion_pattern = input_api.re.compile(r'(%s)' % base_pattern)
1485 comment_pattern = input_api.re.compile(r'//.*(%s)' % base_pattern)
1486
1487 problems = []
1488 for f in input_api.AffectedSourceFiles(None):
1489 local_path = f.LocalPath()
1490 if not local_path.endswith('.h'):
1491 continue
1492 for line_number, line in f.ChangedContents():
1493 if inclusion_pattern.search(line) and not comment_pattern.search(line):
1494 problems.append(
1495 '%s:%d\n %s' % (local_path, line_number, line.strip()))
1496
1497 if problems:
1498 return [output_api.PresubmitPromptWarning(
1499 _IPC_ENUM_TRAITS_DEPRECATED, problems)]
1500 else:
1501 return []
1502
[email protected]b00342e7f2013-03-26 16:21:541503
[email protected]1f7b4172010-01-28 01:17:341504def CheckChangeOnUpload(input_api, output_api):
1505 results = []
1506 results.extend(_CommonChecks(input_api, output_api))
tandriief664692014-09-23 14:51:471507 results.extend(_CheckValidHostsInDEPS(input_api, output_api))
aurimas8d3bc1c52014-10-15 01:02:171508 results.extend(_CheckJavaStyle(input_api, output_api))
[email protected]fe5f57c52009-06-05 14:25:541509 return results
[email protected]ca8d19842009-02-19 16:33:121510
1511
[email protected]1bfb8322014-04-23 01:02:411512def GetTryServerMasterForBot(bot):
1513 """Returns the Try Server master for the given bot.
1514
[email protected]0bb112362014-07-26 04:38:321515 It tries to guess the master from the bot name, but may still fail
1516 and return None. There is no longer a default master.
1517 """
1518 # Potentially ambiguous bot names are listed explicitly.
1519 master_map = {
[email protected]1bfb8322014-04-23 01:02:411520 'linux_gpu': 'tryserver.chromium.gpu',
[email protected]5c5f13042014-05-09 21:28:301521 'mac_gpu': 'tryserver.chromium.gpu',
[email protected]d263d5b2014-04-30 01:15:551522 'win_gpu': 'tryserver.chromium.gpu',
[email protected]0bb112362014-07-26 04:38:321523 'chromium_presubmit': 'tryserver.chromium.linux',
1524 'blink_presubmit': 'tryserver.chromium.linux',
1525 'tools_build_presubmit': 'tryserver.chromium.linux',
[email protected]1bfb8322014-04-23 01:02:411526 }
[email protected]0bb112362014-07-26 04:38:321527 master = master_map.get(bot)
1528 if not master:
1529 if 'gpu' in bot:
1530 master = 'tryserver.chromium.gpu'
1531 elif 'linux' in bot or 'android' in bot or 'presubmit' in bot:
1532 master = 'tryserver.chromium.linux'
1533 elif 'win' in bot:
1534 master = 'tryserver.chromium.win'
1535 elif 'mac' in bot or 'ios' in bot:
1536 master = 'tryserver.chromium.mac'
1537 return master
[email protected]1bfb8322014-04-23 01:02:411538
1539
[email protected]38c6a512013-12-18 23:48:011540def GetDefaultTryConfigs(bots=None):
1541 """Returns a list of ('bot', set(['tests']), optionally filtered by [bots].
1542
1543 To add tests to this list, they MUST be in the the corresponding master's
1544 gatekeeper config. For example, anything on master.chromium would be closed by
1545 tools/build/masters/master.chromium/master_gatekeeper_cfg.py.
1546
1547 If 'bots' is specified, will only return configurations for bots in that list.
1548 """
1549
1550 standard_tests = [
1551 'base_unittests',
1552 'browser_tests',
1553 'cacheinvalidation_unittests',
1554 'check_deps',
1555 'check_deps2git',
1556 'content_browsertests',
1557 'content_unittests',
1558 'crypto_unittests',
[email protected]38c6a512013-12-18 23:48:011559 'gpu_unittests',
1560 'interactive_ui_tests',
1561 'ipc_tests',
1562 'jingle_unittests',
1563 'media_unittests',
1564 'net_unittests',
1565 'ppapi_unittests',
1566 'printing_unittests',
1567 'sql_unittests',
1568 'sync_unit_tests',
1569 'unit_tests',
1570 # Broken in release.
1571 #'url_unittests',
1572 #'webkit_unit_tests',
1573 ]
1574
[email protected]38c6a512013-12-18 23:48:011575 builders_and_tests = {
1576 # TODO(maruel): Figure out a way to run 'sizes' where people can
1577 # effectively update the perf expectation correctly. This requires a
1578 # clobber=True build running 'sizes'. 'sizes' is not accurate with
1579 # incremental build. Reference:
1580 # http://chromium.org/developers/tree-sheriffs/perf-sheriffs.
1581 # TODO(maruel): An option would be to run 'sizes' but not count a failure
1582 # of this step as a try job failure.
1583 'android_aosp': ['compile'],
scottmgd4724062014-09-20 00:27:091584 'android_arm64_dbg_recipe': ['slave_steps'],
1585 'android_chromium_gn_compile_dbg': ['compile'],
[email protected]5a65d3042014-05-07 14:26:011586 'android_chromium_gn_compile_rel': ['compile'],
[email protected]38c6a512013-12-18 23:48:011587 'android_clang_dbg': ['slave_steps'],
scottmgd4724062014-09-20 00:27:091588 'android_clang_dbg_recipe': ['slave_steps'],
[email protected]5bd4f0cd2014-08-22 21:59:291589 'android_dbg_tests_recipe': ['slave_steps'],
[email protected]38c6a512013-12-18 23:48:011590 'cros_x86': ['defaulttests'],
1591 'ios_dbg_simulator': [
1592 'compile',
1593 'base_unittests',
1594 'content_unittests',
1595 'crypto_unittests',
1596 'url_unittests',
1597 'net_unittests',
1598 'sql_unittests',
tfarina201471d2014-10-02 18:12:111599 'ui_base_unittests',
[email protected]38c6a512013-12-18 23:48:011600 'ui_unittests',
1601 ],
1602 'ios_rel_device': ['compile'],
scottmgd4724062014-09-20 00:27:091603 'ios_rel_device_ninja': ['compile'],
[email protected]971b08ce2014-03-19 22:03:561604 'mac_asan': ['compile'],
[email protected]38c6a512013-12-18 23:48:011605 #TODO(stip): Change the name of this builder to reflect that it's release.
[email protected]71afb4ec2014-02-07 02:45:131606 'linux_gtk': standard_tests,
[email protected]971b08ce2014-03-19 22:03:561607 'linux_chromeos_asan': ['compile'],
[email protected]d910b6082014-02-27 18:15:431608 'linux_chromium_chromeos_clang_dbg': ['defaulttests'],
[email protected]ce51953982014-08-07 15:43:241609 'linux_chromium_chromeos_rel_swarming': ['defaulttests'],
[email protected]d910b6082014-02-27 18:15:431610 'linux_chromium_compile_dbg': ['defaulttests'],
scottmgd4724062014-09-20 00:27:091611 'linux_chromium_gn_dbg': ['compile'],
[email protected]5a65d3042014-05-07 14:26:011612 'linux_chromium_gn_rel': ['defaulttests'],
[email protected]0bb112362014-07-26 04:38:321613 'linux_chromium_rel_swarming': ['defaulttests'],
[email protected]d910b6082014-02-27 18:15:431614 'linux_chromium_clang_dbg': ['defaulttests'],
[email protected]1bfb8322014-04-23 01:02:411615 'linux_gpu': ['defaulttests'],
[email protected]9780bac2014-01-11 00:12:021616 'linux_nacl_sdk_build': ['compile'],
[email protected]d910b6082014-02-27 18:15:431617 'mac_chromium_compile_dbg': ['defaulttests'],
[email protected]ce51953982014-08-07 15:43:241618 'mac_chromium_rel_swarming': ['defaulttests'],
[email protected]5c5f13042014-05-09 21:28:301619 'mac_gpu': ['defaulttests'],
[email protected]9780bac2014-01-11 00:12:021620 'mac_nacl_sdk_build': ['compile'],
[email protected]0094fa12014-03-13 03:18:281621 'win_chromium_compile_dbg': ['defaulttests'],
[email protected]c17144e42014-04-15 09:32:431622 'win_chromium_dbg': ['defaulttests'],
[email protected]02a7f6362014-08-13 02:04:161623 'win_chromium_rel_swarming': ['defaulttests'],
[email protected]c0f4e82b2014-08-15 23:35:341624 'win_chromium_x64_rel_swarming': ['defaulttests'],
[email protected]d263d5b2014-04-30 01:15:551625 'win_gpu': ['defaulttests'],
[email protected]9780bac2014-01-11 00:12:021626 'win_nacl_sdk_build': ['compile'],
danakjc89745a2014-09-16 01:33:031627 'win8_chromium_rel': ['defaulttests'],
[email protected]38c6a512013-12-18 23:48:011628 }
1629
[email protected]38c6a512013-12-18 23:48:011630 if bots:
[email protected]1bfb8322014-04-23 01:02:411631 filtered_builders_and_tests = dict((bot, set(builders_and_tests[bot]))
1632 for bot in bots)
[email protected]38c6a512013-12-18 23:48:011633 else:
[email protected]1bfb8322014-04-23 01:02:411634 filtered_builders_and_tests = dict(
1635 (bot, set(tests))
1636 for bot, tests in builders_and_tests.iteritems())
1637
1638 # Build up the mapping from tryserver master to bot/test.
1639 out = dict()
1640 for bot, tests in filtered_builders_and_tests.iteritems():
1641 out.setdefault(GetTryServerMasterForBot(bot), {})[bot] = tests
1642 return out
[email protected]38c6a512013-12-18 23:48:011643
1644
[email protected]ca8d19842009-02-19 16:33:121645def CheckChangeOnCommit(input_api, output_api):
[email protected]fe5f57c52009-06-05 14:25:541646 results = []
[email protected]1f7b4172010-01-28 01:17:341647 results.extend(_CommonChecks(input_api, output_api))
[email protected]dd805fe2009-10-01 08:11:511648 # TODO(thestig) temporarily disabled, doesn't work in third_party/
1649 #results.extend(input_api.canned_checks.CheckSvnModifiedDirectories(
1650 # input_api, output_api, sources))
[email protected]fe5f57c52009-06-05 14:25:541651 # Make sure the tree is 'open'.
[email protected]806e98e2010-03-19 17:49:271652 results.extend(input_api.canned_checks.CheckTreeIsOpen(
[email protected]7f238152009-08-12 19:00:341653 input_api,
1654 output_api,
[email protected]2fdd1f362013-01-16 03:56:031655 json_url='http://chromium-status.appspot.com/current?format=json'))
[email protected]806e98e2010-03-19 17:49:271656
[email protected]3e4eb112011-01-18 03:29:541657 results.extend(input_api.canned_checks.CheckChangeHasBugField(
1658 input_api, output_api))
[email protected]c4b47562011-12-05 23:39:411659 results.extend(input_api.canned_checks.CheckChangeHasDescription(
1660 input_api, output_api))
[email protected]fe5f57c52009-06-05 14:25:541661 return results
[email protected]ca8d19842009-02-19 16:33:121662
1663
[email protected]7468ac522014-03-12 23:35:571664def GetPreferredTryMasters(project, change):
mohan.reddyf21db962014-10-16 12:26:471665 import re
[email protected]4ce995ea2012-06-27 02:13:101666 files = change.LocalPaths()
1667
joaodasilva718f87672014-08-30 09:25:491668 if not files or all(re.search(r'[\\\/]OWNERS$', f) for f in files):
[email protected]7468ac522014-03-12 23:35:571669 return {}
[email protected]3019c902012-06-29 00:09:031670
joaodasilva718f87672014-08-30 09:25:491671 if all(re.search(r'\.(m|mm)$|(^|[\\\/_])mac[\\\/_.]', f) for f in files):
[email protected]d96b1f42014-02-27 19:17:521672 return GetDefaultTryConfigs([
1673 'mac_chromium_compile_dbg',
[email protected]e6890ec2014-08-07 16:59:421674 'mac_chromium_rel_swarming',
[email protected]d96b1f42014-02-27 19:17:521675 ])
[email protected]d668899a2012-09-06 18:16:591676 if all(re.search('(^|[/_])win[/_.]', f) for f in files):
[email protected]02a7f6362014-08-13 02:04:161677 return GetDefaultTryConfigs([
1678 'win_chromium_dbg',
1679 'win_chromium_rel_swarming',
danakjc89745a2014-09-16 01:33:031680 'win8_chromium_rel',
[email protected]02a7f6362014-08-13 02:04:161681 ])
joaodasilva718f87672014-08-30 09:25:491682 if all(re.search(r'(^|[\\\/_])android[\\\/_.]', f) for f in files):
[email protected]38c6a512013-12-18 23:48:011683 return GetDefaultTryConfigs([
1684 'android_aosp',
1685 'android_clang_dbg',
[email protected]5bd4f0cd2014-08-22 21:59:291686 'android_dbg_tests_recipe',
[email protected]38c6a512013-12-18 23:48:011687 ])
joaodasilva718f87672014-08-30 09:25:491688 if all(re.search(r'[\\\/_]ios[\\\/_.]', f) for f in files):
[email protected]38c6a512013-12-18 23:48:011689 return GetDefaultTryConfigs(['ios_rel_device', 'ios_dbg_simulator'])
[email protected]4ce995ea2012-06-27 02:13:101690
[email protected]7468ac522014-03-12 23:35:571691 builders = [
scottmgd4724062014-09-20 00:27:091692 'android_arm64_dbg_recipe',
[email protected]5a65d3042014-05-07 14:26:011693 'android_chromium_gn_compile_rel',
scottmgd4724062014-09-20 00:27:091694 'android_chromium_gn_compile_dbg',
[email protected]3e2f0402012-11-02 16:28:011695 'android_clang_dbg',
scottmgd4724062014-09-20 00:27:091696 'android_clang_dbg_recipe',
[email protected]5bd4f0cd2014-08-22 21:59:291697 'android_dbg_tests_recipe',
[email protected]3e2f0402012-11-02 16:28:011698 'ios_dbg_simulator',
1699 'ios_rel_device',
scottmgd4724062014-09-20 00:27:091700 'ios_rel_device_ninja',
[email protected]e6890ec2014-08-07 16:59:421701 'linux_chromium_chromeos_rel_swarming',
[email protected]d96b1f42014-02-27 19:17:521702 'linux_chromium_clang_dbg',
scottmgd4724062014-09-20 00:27:091703 'linux_chromium_gn_dbg',
[email protected]5a65d3042014-05-07 14:26:011704 'linux_chromium_gn_rel',
[email protected]0bb112362014-07-26 04:38:321705 'linux_chromium_rel_swarming',
[email protected]1bfb8322014-04-23 01:02:411706 'linux_gpu',
[email protected]d96b1f42014-02-27 19:17:521707 'mac_chromium_compile_dbg',
[email protected]e6890ec2014-08-07 16:59:421708 'mac_chromium_rel_swarming',
[email protected]5c5f13042014-05-09 21:28:301709 'mac_gpu',
[email protected]0094fa12014-03-13 03:18:281710 'win_chromium_compile_dbg',
[email protected]02a7f6362014-08-13 02:04:161711 'win_chromium_rel_swarming',
[email protected]c0f4e82b2014-08-15 23:35:341712 'win_chromium_x64_rel_swarming',
[email protected]d263d5b2014-04-30 01:15:551713 'win_gpu',
danakjc89745a2014-09-16 01:33:031714 'win8_chromium_rel',
[email protected]7468ac522014-03-12 23:35:571715 ]
[email protected]911753b2012-08-02 12:11:541716
1717 # Match things like path/aura/file.cc and path/file_aura.cc.
[email protected]95c989162012-11-29 05:58:251718 # Same for chromeos.
joaodasilva718f87672014-08-30 09:25:491719 if any(re.search(r'[\\\/_](aura|chromeos)', f) for f in files):
[email protected]7468ac522014-03-12 23:35:571720 builders.extend([
1721 'linux_chromeos_asan',
1722 'linux_chromium_chromeos_clang_dbg'
1723 ])
[email protected]4ce995ea2012-06-27 02:13:101724
[email protected]e8df48f2013-09-30 20:07:541725 # If there are gyp changes to base, build, or chromeos, run a full cros build
1726 # in addition to the shorter linux_chromeos build. Changes to high level gyp
1727 # files have a much higher chance of breaking the cros build, which is
1728 # differnt from the linux_chromeos build that most chrome developers test
1729 # with.
1730 if any(re.search('^(base|build|chromeos).*\.gypi?$', f) for f in files):
[email protected]7468ac522014-03-12 23:35:571731 builders.extend(['cros_x86'])
[email protected]e8df48f2013-09-30 20:07:541732
[email protected]d95948ef2013-07-02 10:51:001733 # The AOSP bot doesn't build the chrome/ layer, so ignore any changes to it
1734 # unless they're .gyp(i) files as changes to those files can break the gyp
1735 # step on that bot.
1736 if (not all(re.search('^chrome', f) for f in files) or
1737 any(re.search('\.gypi?$', f) for f in files)):
[email protected]7468ac522014-03-12 23:35:571738 builders.extend(['android_aosp'])
[email protected]d95948ef2013-07-02 10:51:001739
[email protected]7468ac522014-03-12 23:35:571740 return GetDefaultTryConfigs(builders)