blob: b304285365847e5497af6a192e26eea8ba11bfb9 [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]9d16ad12011-12-14 20:49:4712import re
[email protected]fbcafe5a2012-08-08 15:31:2213import subprocess
[email protected]55f9f382012-07-31 11:02:1814import sys
[email protected]9d16ad12011-12-14 20:49:4715
16
[email protected]379e7dd2010-01-28 17:39:2117_EXCLUDED_PATHS = (
[email protected]3e4eb112011-01-18 03:29:5418 r"^breakpad[\\\/].*",
[email protected]40d1dbb2012-10-26 07:18:0019 r"^native_client_sdk[\\\/]src[\\\/]build_tools[\\\/]make_rules.py",
20 r"^native_client_sdk[\\\/]src[\\\/]build_tools[\\\/]make_simple.py",
[email protected]8886ffcb2013-02-12 04:56:2821 r"^native_client_sdk[\\\/]src[\\\/]tools[\\\/].*.mk",
[email protected]a18130a2012-01-03 17:52:0822 r"^net[\\\/]tools[\\\/]spdyshark[\\\/].*",
[email protected]3e4eb112011-01-18 03:29:5423 r"^skia[\\\/].*",
24 r"^v8[\\\/].*",
25 r".*MakeFile$",
[email protected]1084ccc2012-03-14 03:22:5326 r".+_autogen\.h$",
[email protected]ce145c02012-09-06 09:49:3427 r".+[\\\/]pnacl_shim\.c$",
[email protected]4306417642009-06-11 00:33:4028)
[email protected]ca8d19842009-02-19 16:33:1229
[email protected]06e6d0ff2012-12-11 01:36:4430# Fragment of a regular expression that matches file name suffixes
31# used to indicate different platforms.
32_PLATFORM_SPECIFIERS = r'(_(android|chromeos|gtk|mac|posix|win))?'
33
34# 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 = (
41 r'.*[/\\](fake_|test_|mock_).+%s' % _IMPLEMENTATION_EXTENSIONS,
42 r'.+_test_(base|support|util)%s' % _IMPLEMENTATION_EXTENSIONS,
43 r'.+_(api|browser|perf|unit|ui)?test%s%s' % (_PLATFORM_SPECIFIERS,
44 _IMPLEMENTATION_EXTENSIONS),
45 r'.+profile_sync_service_harness%s' % _IMPLEMENTATION_EXTENSIONS,
46 r'.*[/\\](test|tool(s)?)[/\\].*',
47 # At request of folks maintaining this folder.
48 r'chrome[/\\]browser[/\\]automation[/\\].*',
49)
[email protected]ca8d19842009-02-19 16:33:1250
[email protected]eea609a2011-11-18 13:10:1251_TEST_ONLY_WARNING = (
52 'You might be calling functions intended only for testing from\n'
53 'production code. It is OK to ignore this warning if you know what\n'
54 'you are doing, as the heuristics used to detect the situation are\n'
55 'not perfect. The commit queue will not block on this warning.\n'
56 'Email [email protected] if you have questions.')
57
58
[email protected]cf9b78f2012-11-14 11:40:2859_INCLUDE_ORDER_WARNING = (
60 'Your #include order seems to be broken. Send mail to\n'
61 '[email protected] if this is not the case.')
62
63
[email protected]127f18ec2012-06-16 05:05:5964_BANNED_OBJC_FUNCTIONS = (
65 (
66 'addTrackingRect:',
[email protected]23e6cbc2012-06-16 18:51:2067 (
68 'The use of -[NSView addTrackingRect:owner:userData:assumeInside:] is'
[email protected]127f18ec2012-06-16 05:05:5969 'prohibited. Please use CrTrackingArea instead.',
70 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
71 ),
72 False,
73 ),
74 (
75 'NSTrackingArea',
[email protected]23e6cbc2012-06-16 18:51:2076 (
77 'The use of NSTrackingAreas is prohibited. Please use CrTrackingArea',
[email protected]127f18ec2012-06-16 05:05:5978 'instead.',
79 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
80 ),
81 False,
82 ),
83 (
84 'convertPointFromBase:',
[email protected]23e6cbc2012-06-16 18:51:2085 (
86 'The use of -[NSView convertPointFromBase:] is almost certainly wrong.',
[email protected]127f18ec2012-06-16 05:05:5987 'Please use |convertPoint:(point) fromView:nil| instead.',
88 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
89 ),
90 True,
91 ),
92 (
93 'convertPointToBase:',
[email protected]23e6cbc2012-06-16 18:51:2094 (
95 'The use of -[NSView convertPointToBase:] is almost certainly wrong.',
[email protected]127f18ec2012-06-16 05:05:5996 'Please use |convertPoint:(point) toView:nil| instead.',
97 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
98 ),
99 True,
100 ),
101 (
102 'convertRectFromBase:',
[email protected]23e6cbc2012-06-16 18:51:20103 (
104 'The use of -[NSView convertRectFromBase:] is almost certainly wrong.',
[email protected]127f18ec2012-06-16 05:05:59105 'Please use |convertRect:(point) fromView:nil| instead.',
106 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
107 ),
108 True,
109 ),
110 (
111 'convertRectToBase:',
[email protected]23e6cbc2012-06-16 18:51:20112 (
113 'The use of -[NSView convertRectToBase:] is almost certainly wrong.',
[email protected]127f18ec2012-06-16 05:05:59114 'Please use |convertRect:(point) toView:nil| instead.',
115 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
116 ),
117 True,
118 ),
119 (
120 'convertSizeFromBase:',
[email protected]23e6cbc2012-06-16 18:51:20121 (
122 'The use of -[NSView convertSizeFromBase:] is almost certainly wrong.',
[email protected]127f18ec2012-06-16 05:05:59123 'Please use |convertSize:(point) fromView:nil| instead.',
124 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
125 ),
126 True,
127 ),
128 (
129 'convertSizeToBase:',
[email protected]23e6cbc2012-06-16 18:51:20130 (
131 'The use of -[NSView convertSizeToBase:] is almost certainly wrong.',
[email protected]127f18ec2012-06-16 05:05:59132 'Please use |convertSize:(point) toView:nil| instead.',
133 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
134 ),
135 True,
136 ),
137)
138
139
140_BANNED_CPP_FUNCTIONS = (
[email protected]23e6cbc2012-06-16 18:51:20141 # Make sure that gtest's FRIEND_TEST() macro is not used; the
142 # FRIEND_TEST_ALL_PREFIXES() macro from base/gtest_prod_util.h should be
[email protected]e00ccc92012-11-01 17:32:30143 # used instead since that allows for FLAKY_ and DISABLED_ prefixes.
[email protected]23e6cbc2012-06-16 18:51:20144 (
145 'FRIEND_TEST(',
146 (
[email protected]e3c945502012-06-26 20:01:49147 'Chromium code should not use gtest\'s FRIEND_TEST() macro. Include',
[email protected]23e6cbc2012-06-16 18:51:20148 'base/gtest_prod_util.h and use FRIEND_TEST_ALL_PREFIXES() instead.',
149 ),
150 False,
[email protected]7345da02012-11-27 14:31:49151 (),
[email protected]23e6cbc2012-06-16 18:51:20152 ),
153 (
154 'ScopedAllowIO',
155 (
[email protected]e3c945502012-06-26 20:01:49156 'New code should not use ScopedAllowIO. Post a task to the blocking',
157 'pool or the FILE thread instead.',
[email protected]23e6cbc2012-06-16 18:51:20158 ),
[email protected]e3c945502012-06-26 20:01:49159 True,
[email protected]7345da02012-11-27 14:31:49160 (
161 r"^content[\\\/]shell[\\\/]shell_browser_main\.cc$",
162 ),
[email protected]23e6cbc2012-06-16 18:51:20163 ),
[email protected]127f18ec2012-06-16 05:05:59164)
165
166
[email protected]b00342e7f2013-03-26 16:21:54167_VALID_OS_MACROS = (
168 # Please keep sorted.
169 'OS_ANDROID',
170 'OS_BSD',
171 'OS_CAT', # For testing.
172 'OS_CHROMEOS',
173 'OS_FREEBSD',
174 'OS_IOS',
175 'OS_LINUX',
176 'OS_MACOSX',
177 'OS_NACL',
178 'OS_OPENBSD',
179 'OS_POSIX',
180 'OS_SOLARIS',
181 'OS_SUN', # Not in build/build_config.h but in skia.
182 'OS_WIN',
183)
184
185
[email protected]55459852011-08-10 15:17:19186def _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api):
187 """Attempts to prevent use of functions intended only for testing in
188 non-testing code. For now this is just a best-effort implementation
189 that ignores header files and may have some false positives. A
190 better implementation would probably need a proper C++ parser.
191 """
192 # We only scan .cc files and the like, as the declaration of
193 # for-testing functions in header files are hard to distinguish from
194 # calls to such functions without a proper C++ parser.
[email protected]06e6d0ff2012-12-11 01:36:44195 file_inclusion_pattern = r'.+%s' % _IMPLEMENTATION_EXTENSIONS
[email protected]55459852011-08-10 15:17:19196
197 base_function_pattern = r'ForTest(ing)?|for_test(ing)?'
198 inclusion_pattern = input_api.re.compile(r'(%s)\s*\(' % base_function_pattern)
199 exclusion_pattern = input_api.re.compile(
200 r'::[A-Za-z0-9_]+(%s)|(%s)[^;]+\{' % (
201 base_function_pattern, base_function_pattern))
202
203 def FilterFile(affected_file):
[email protected]06e6d0ff2012-12-11 01:36:44204 black_list = (_EXCLUDED_PATHS +
205 _TEST_CODE_EXCLUDED_PATHS +
206 input_api.DEFAULT_BLACK_LIST)
[email protected]55459852011-08-10 15:17:19207 return input_api.FilterSourceFile(
208 affected_file,
209 white_list=(file_inclusion_pattern, ),
210 black_list=black_list)
211
212 problems = []
213 for f in input_api.AffectedSourceFiles(FilterFile):
214 local_path = f.LocalPath()
[email protected]2fdd1f362013-01-16 03:56:03215 lines = input_api.ReadFile(f).splitlines()
216 line_number = 0
217 for line in lines:
218 if (inclusion_pattern.search(line) and
219 not exclusion_pattern.search(line)):
[email protected]55459852011-08-10 15:17:19220 problems.append(
[email protected]2fdd1f362013-01-16 03:56:03221 '%s:%d\n %s' % (local_path, line_number, line.strip()))
222 line_number += 1
[email protected]55459852011-08-10 15:17:19223
224 if problems:
[email protected]2fdd1f362013-01-16 03:56:03225 if not input_api.is_committing:
226 return [output_api.PresubmitPromptWarning(_TEST_ONLY_WARNING, problems)]
227 else:
[email protected]eea609a2011-11-18 13:10:12228 # We don't warn on commit, to avoid stopping commits going through CQ.
229 return [output_api.PresubmitNotifyResult(_TEST_ONLY_WARNING, problems)]
[email protected]2fdd1f362013-01-16 03:56:03230 else:
231 return []
[email protected]55459852011-08-10 15:17:19232
233
[email protected]10689ca2011-09-02 02:31:54234def _CheckNoIOStreamInHeaders(input_api, output_api):
235 """Checks to make sure no .h files include <iostream>."""
236 files = []
237 pattern = input_api.re.compile(r'^#include\s*<iostream>',
238 input_api.re.MULTILINE)
239 for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile):
240 if not f.LocalPath().endswith('.h'):
241 continue
242 contents = input_api.ReadFile(f)
243 if pattern.search(contents):
244 files.append(f)
245
246 if len(files):
247 return [ output_api.PresubmitError(
[email protected]6c063c62012-07-11 19:11:06248 'Do not #include <iostream> in header files, since it inserts static '
249 'initialization into every file including the header. Instead, '
[email protected]10689ca2011-09-02 02:31:54250 '#include <ostream>. See http://crbug.com/94794',
251 files) ]
252 return []
253
254
[email protected]72df4e782012-06-21 16:28:18255def _CheckNoUNIT_TESTInSourceFiles(input_api, output_api):
256 """Checks to make sure no source files use UNIT_TEST"""
257 problems = []
258 for f in input_api.AffectedFiles():
259 if (not f.LocalPath().endswith(('.cc', '.mm'))):
260 continue
261
262 for line_num, line in f.ChangedContents():
263 if 'UNIT_TEST' in line:
264 problems.append(' %s:%d' % (f.LocalPath(), line_num))
265
266 if not problems:
267 return []
268 return [output_api.PresubmitPromptWarning('UNIT_TEST is only for headers.\n' +
269 '\n'.join(problems))]
270
271
[email protected]8ea5d4b2011-09-13 21:49:22272def _CheckNoNewWStrings(input_api, output_api):
273 """Checks to make sure we don't introduce use of wstrings."""
[email protected]55463aa62011-10-12 00:48:27274 problems = []
[email protected]8ea5d4b2011-09-13 21:49:22275 for f in input_api.AffectedFiles():
[email protected]b5c24292011-11-28 14:38:20276 if (not f.LocalPath().endswith(('.cc', '.h')) or
277 f.LocalPath().endswith('test.cc')):
278 continue
[email protected]8ea5d4b2011-09-13 21:49:22279
[email protected]a11dbe9b2012-08-07 01:32:58280 allowWString = False
[email protected]b5c24292011-11-28 14:38:20281 for line_num, line in f.ChangedContents():
[email protected]a11dbe9b2012-08-07 01:32:58282 if 'presubmit: allow wstring' in line:
283 allowWString = True
284 elif not allowWString and 'wstring' in line:
[email protected]55463aa62011-10-12 00:48:27285 problems.append(' %s:%d' % (f.LocalPath(), line_num))
[email protected]a11dbe9b2012-08-07 01:32:58286 allowWString = False
287 else:
288 allowWString = False
[email protected]8ea5d4b2011-09-13 21:49:22289
[email protected]55463aa62011-10-12 00:48:27290 if not problems:
291 return []
292 return [output_api.PresubmitPromptWarning('New code should not use wstrings.'
[email protected]a11dbe9b2012-08-07 01:32:58293 ' If you are calling a cross-platform API that accepts a wstring, '
294 'fix the API.\n' +
[email protected]55463aa62011-10-12 00:48:27295 '\n'.join(problems))]
[email protected]8ea5d4b2011-09-13 21:49:22296
297
[email protected]2a8ac9c2011-10-19 17:20:44298def _CheckNoDEPSGIT(input_api, output_api):
299 """Make sure .DEPS.git is never modified manually."""
300 if any(f.LocalPath().endswith('.DEPS.git') for f in
301 input_api.AffectedFiles()):
302 return [output_api.PresubmitError(
303 'Never commit changes to .DEPS.git. This file is maintained by an\n'
304 'automated system based on what\'s in DEPS and your changes will be\n'
305 'overwritten.\n'
306 'See http://code.google.com/p/chromium/wiki/UsingNewGit#Rolling_DEPS\n'
307 'for more information')]
308 return []
309
310
[email protected]127f18ec2012-06-16 05:05:59311def _CheckNoBannedFunctions(input_api, output_api):
312 """Make sure that banned functions are not used."""
313 warnings = []
314 errors = []
315
316 file_filter = lambda f: f.LocalPath().endswith(('.mm', '.m', '.h'))
317 for f in input_api.AffectedFiles(file_filter=file_filter):
318 for line_num, line in f.ChangedContents():
319 for func_name, message, error in _BANNED_OBJC_FUNCTIONS:
320 if func_name in line:
321 problems = warnings;
322 if error:
323 problems = errors;
324 problems.append(' %s:%d:' % (f.LocalPath(), line_num))
325 for message_line in message:
326 problems.append(' %s' % message_line)
327
328 file_filter = lambda f: f.LocalPath().endswith(('.cc', '.mm', '.h'))
329 for f in input_api.AffectedFiles(file_filter=file_filter):
330 for line_num, line in f.ChangedContents():
[email protected]7345da02012-11-27 14:31:49331 for func_name, message, error, excluded_paths in _BANNED_CPP_FUNCTIONS:
332 def IsBlacklisted(affected_file, blacklist):
333 local_path = affected_file.LocalPath()
334 for item in blacklist:
335 if input_api.re.match(item, local_path):
336 return True
337 return False
338 if IsBlacklisted(f, excluded_paths):
339 continue
[email protected]127f18ec2012-06-16 05:05:59340 if func_name in line:
341 problems = warnings;
342 if error:
343 problems = errors;
344 problems.append(' %s:%d:' % (f.LocalPath(), line_num))
345 for message_line in message:
346 problems.append(' %s' % message_line)
347
348 result = []
349 if (warnings):
350 result.append(output_api.PresubmitPromptWarning(
351 'Banned functions were used.\n' + '\n'.join(warnings)))
352 if (errors):
353 result.append(output_api.PresubmitError(
354 'Banned functions were used.\n' + '\n'.join(errors)))
355 return result
356
357
[email protected]6c063c62012-07-11 19:11:06358def _CheckNoPragmaOnce(input_api, output_api):
359 """Make sure that banned functions are not used."""
360 files = []
361 pattern = input_api.re.compile(r'^#pragma\s+once',
362 input_api.re.MULTILINE)
363 for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile):
364 if not f.LocalPath().endswith('.h'):
365 continue
366 contents = input_api.ReadFile(f)
367 if pattern.search(contents):
368 files.append(f)
369
370 if files:
371 return [output_api.PresubmitError(
372 'Do not use #pragma once in header files.\n'
373 'See http://www.chromium.org/developers/coding-style#TOC-File-headers',
374 files)]
375 return []
376
[email protected]127f18ec2012-06-16 05:05:59377
[email protected]e7479052012-09-19 00:26:12378def _CheckNoTrinaryTrueFalse(input_api, output_api):
379 """Checks to make sure we don't introduce use of foo ? true : false."""
380 problems = []
381 pattern = input_api.re.compile(r'\?\s*(true|false)\s*:\s*(true|false)')
382 for f in input_api.AffectedFiles():
383 if not f.LocalPath().endswith(('.cc', '.h', '.inl', '.m', '.mm')):
384 continue
385
386 for line_num, line in f.ChangedContents():
387 if pattern.match(line):
388 problems.append(' %s:%d' % (f.LocalPath(), line_num))
389
390 if not problems:
391 return []
392 return [output_api.PresubmitPromptWarning(
393 'Please consider avoiding the "? true : false" pattern if possible.\n' +
394 '\n'.join(problems))]
395
396
[email protected]55f9f382012-07-31 11:02:18397def _CheckUnwantedDependencies(input_api, output_api):
398 """Runs checkdeps on #include statements added in this
399 change. Breaking - rules is an error, breaking ! rules is a
400 warning.
401 """
402 # We need to wait until we have an input_api object and use this
403 # roundabout construct to import checkdeps because this file is
404 # eval-ed and thus doesn't have __file__.
405 original_sys_path = sys.path
406 try:
407 sys.path = sys.path + [input_api.os_path.join(
408 input_api.PresubmitLocalPath(), 'tools', 'checkdeps')]
409 import checkdeps
410 from cpp_checker import CppChecker
411 from rules import Rule
412 finally:
413 # Restore sys.path to what it was before.
414 sys.path = original_sys_path
415
416 added_includes = []
417 for f in input_api.AffectedFiles():
418 if not CppChecker.IsCppFile(f.LocalPath()):
419 continue
420
421 changed_lines = [line for line_num, line in f.ChangedContents()]
422 added_includes.append([f.LocalPath(), changed_lines])
423
424 deps_checker = checkdeps.DepsChecker()
425
426 error_descriptions = []
427 warning_descriptions = []
428 for path, rule_type, rule_description in deps_checker.CheckAddedCppIncludes(
429 added_includes):
430 description_with_path = '%s\n %s' % (path, rule_description)
431 if rule_type == Rule.DISALLOW:
432 error_descriptions.append(description_with_path)
433 else:
434 warning_descriptions.append(description_with_path)
435
436 results = []
437 if error_descriptions:
438 results.append(output_api.PresubmitError(
439 'You added one or more #includes that violate checkdeps rules.',
440 error_descriptions))
441 if warning_descriptions:
[email protected]2fdd1f362013-01-16 03:56:03442 if not input_api.is_committing:
443 warning_factory = output_api.PresubmitPromptWarning
444 else:
[email protected]779caa52012-08-21 17:05:59445 # We don't want to block use of the CQ when there is a warning
446 # of this kind, so we only show a message when committing.
447 warning_factory = output_api.PresubmitNotifyResult
448 results.append(warning_factory(
[email protected]55f9f382012-07-31 11:02:18449 'You added one or more #includes of files that are temporarily\n'
450 'allowed but being removed. Can you avoid introducing the\n'
451 '#include? See relevant DEPS file(s) for details and contacts.',
452 warning_descriptions))
453 return results
454
455
[email protected]fbcafe5a2012-08-08 15:31:22456def _CheckFilePermissions(input_api, output_api):
457 """Check that all files have their permissions properly set."""
458 args = [sys.executable, 'tools/checkperms/checkperms.py', '--root',
459 input_api.change.RepositoryRoot()]
460 for f in input_api.AffectedFiles():
461 args += ['--file', f.LocalPath()]
462 errors = []
463 (errors, stderrdata) = subprocess.Popen(args).communicate()
464
465 results = []
466 if errors:
[email protected]c8278b32012-10-30 20:35:49467 results.append(output_api.PresubmitError('checkperms.py failed.',
[email protected]fbcafe5a2012-08-08 15:31:22468 errors))
469 return results
470
471
[email protected]c8278b32012-10-30 20:35:49472def _CheckNoAuraWindowPropertyHInHeaders(input_api, output_api):
473 """Makes sure we don't include ui/aura/window_property.h
474 in header files.
475 """
476 pattern = input_api.re.compile(r'^#include\s*"ui/aura/window_property.h"')
477 errors = []
478 for f in input_api.AffectedFiles():
479 if not f.LocalPath().endswith('.h'):
480 continue
481 for line_num, line in f.ChangedContents():
482 if pattern.match(line):
483 errors.append(' %s:%d' % (f.LocalPath(), line_num))
484
485 results = []
486 if errors:
487 results.append(output_api.PresubmitError(
488 'Header files should not include ui/aura/window_property.h', errors))
489 return results
490
491
[email protected]cf9b78f2012-11-14 11:40:28492def _CheckIncludeOrderForScope(scope, input_api, file_path, changed_linenums):
493 """Checks that the lines in scope occur in the right order.
494
495 1. C system files in alphabetical order
496 2. C++ system files in alphabetical order
497 3. Project's .h files
498 """
499
500 c_system_include_pattern = input_api.re.compile(r'\s*#include <.*\.h>')
501 cpp_system_include_pattern = input_api.re.compile(r'\s*#include <.*>')
502 custom_include_pattern = input_api.re.compile(r'\s*#include ".*')
503
504 C_SYSTEM_INCLUDES, CPP_SYSTEM_INCLUDES, CUSTOM_INCLUDES = range(3)
505
506 state = C_SYSTEM_INCLUDES
507
508 previous_line = ''
[email protected]728b9bb2012-11-14 20:38:57509 previous_line_num = 0
[email protected]cf9b78f2012-11-14 11:40:28510 problem_linenums = []
511 for line_num, line in scope:
512 if c_system_include_pattern.match(line):
513 if state != C_SYSTEM_INCLUDES:
[email protected]728b9bb2012-11-14 20:38:57514 problem_linenums.append((line_num, previous_line_num))
[email protected]cf9b78f2012-11-14 11:40:28515 elif previous_line and previous_line > line:
[email protected]728b9bb2012-11-14 20:38:57516 problem_linenums.append((line_num, previous_line_num))
[email protected]cf9b78f2012-11-14 11:40:28517 elif cpp_system_include_pattern.match(line):
518 if state == C_SYSTEM_INCLUDES:
519 state = CPP_SYSTEM_INCLUDES
520 elif state == CUSTOM_INCLUDES:
[email protected]728b9bb2012-11-14 20:38:57521 problem_linenums.append((line_num, previous_line_num))
[email protected]cf9b78f2012-11-14 11:40:28522 elif previous_line and previous_line > line:
[email protected]728b9bb2012-11-14 20:38:57523 problem_linenums.append((line_num, previous_line_num))
[email protected]cf9b78f2012-11-14 11:40:28524 elif custom_include_pattern.match(line):
525 if state != CUSTOM_INCLUDES:
526 state = CUSTOM_INCLUDES
527 elif previous_line and previous_line > line:
[email protected]728b9bb2012-11-14 20:38:57528 problem_linenums.append((line_num, previous_line_num))
[email protected]cf9b78f2012-11-14 11:40:28529 else:
530 problem_linenums.append(line_num)
531 previous_line = line
[email protected]728b9bb2012-11-14 20:38:57532 previous_line_num = line_num
[email protected]cf9b78f2012-11-14 11:40:28533
534 warnings = []
[email protected]728b9bb2012-11-14 20:38:57535 for (line_num, previous_line_num) in problem_linenums:
536 if line_num in changed_linenums or previous_line_num in changed_linenums:
[email protected]cf9b78f2012-11-14 11:40:28537 warnings.append(' %s:%d' % (file_path, line_num))
538 return warnings
539
540
[email protected]ac294a12012-12-06 16:38:43541def _CheckIncludeOrderInFile(input_api, f, changed_linenums):
[email protected]cf9b78f2012-11-14 11:40:28542 """Checks the #include order for the given file f."""
543
[email protected]2299dcf2012-11-15 19:56:24544 system_include_pattern = input_api.re.compile(r'\s*#include \<.*')
[email protected]962f117e2012-11-22 18:11:56545 # Exclude #include <.../...> includes from the check; e.g., <sys/...> includes
546 # often need to appear in a specific order.
547 excluded_include_pattern = input_api.re.compile(r'\s*#include \<.*/.*')
[email protected]2299dcf2012-11-15 19:56:24548 custom_include_pattern = input_api.re.compile(r'\s*#include "(?P<FILE>.*)"')
[email protected]0e5c1852012-12-18 20:17:11549 if_pattern = input_api.re.compile(
550 r'\s*#\s*(if|elif|else|endif|define|undef).*')
551 # Some files need specialized order of includes; exclude such files from this
552 # check.
553 uncheckable_includes_pattern = input_api.re.compile(
554 r'\s*#include '
555 '("ipc/.*macros\.h"|<windows\.h>|".*gl.*autogen.h")\s*')
[email protected]cf9b78f2012-11-14 11:40:28556
557 contents = f.NewContents()
558 warnings = []
559 line_num = 0
560
[email protected]ac294a12012-12-06 16:38:43561 # Handle the special first include. If the first include file is
562 # some/path/file.h, the corresponding including file can be some/path/file.cc,
563 # some/other/path/file.cc, some/path/file_platform.cc, some/path/file-suffix.h
564 # etc. It's also possible that no special first include exists.
565 for line in contents:
566 line_num += 1
567 if system_include_pattern.match(line):
568 # No special first include -> process the line again along with normal
569 # includes.
570 line_num -= 1
571 break
572 match = custom_include_pattern.match(line)
573 if match:
574 match_dict = match.groupdict()
575 header_basename = input_api.os_path.basename(
576 match_dict['FILE']).replace('.h', '')
577 if header_basename not in input_api.os_path.basename(f.LocalPath()):
[email protected]2299dcf2012-11-15 19:56:24578 # No special first include -> process the line again along with normal
579 # includes.
580 line_num -= 1
[email protected]ac294a12012-12-06 16:38:43581 break
[email protected]cf9b78f2012-11-14 11:40:28582
583 # Split into scopes: Each region between #if and #endif is its own scope.
584 scopes = []
585 current_scope = []
586 for line in contents[line_num:]:
587 line_num += 1
[email protected]0e5c1852012-12-18 20:17:11588 if uncheckable_includes_pattern.match(line):
589 return []
[email protected]2309b0fa02012-11-16 12:18:27590 if if_pattern.match(line):
[email protected]cf9b78f2012-11-14 11:40:28591 scopes.append(current_scope)
592 current_scope = []
[email protected]962f117e2012-11-22 18:11:56593 elif ((system_include_pattern.match(line) or
594 custom_include_pattern.match(line)) and
595 not excluded_include_pattern.match(line)):
[email protected]cf9b78f2012-11-14 11:40:28596 current_scope.append((line_num, line))
597 scopes.append(current_scope)
598
599 for scope in scopes:
600 warnings.extend(_CheckIncludeOrderForScope(scope, input_api, f.LocalPath(),
601 changed_linenums))
602 return warnings
603
604
605def _CheckIncludeOrder(input_api, output_api):
606 """Checks that the #include order is correct.
607
608 1. The corresponding header for source files.
609 2. C system files in alphabetical order
610 3. C++ system files in alphabetical order
611 4. Project's .h files in alphabetical order
612
[email protected]ac294a12012-12-06 16:38:43613 Each region separated by #if, #elif, #else, #endif, #define and #undef follows
614 these rules separately.
[email protected]cf9b78f2012-11-14 11:40:28615 """
616
617 warnings = []
618 for f in input_api.AffectedFiles():
[email protected]ac294a12012-12-06 16:38:43619 if f.LocalPath().endswith(('.cc', '.h')):
620 changed_linenums = set(line_num for line_num, _ in f.ChangedContents())
621 warnings.extend(_CheckIncludeOrderInFile(input_api, f, changed_linenums))
[email protected]cf9b78f2012-11-14 11:40:28622
623 results = []
624 if warnings:
[email protected]2fdd1f362013-01-16 03:56:03625 if not input_api.is_committing:
626 results.append(output_api.PresubmitPromptWarning(_INCLUDE_ORDER_WARNING,
627 warnings))
628 else:
[email protected]120cf540d2012-12-10 17:55:53629 # We don't warn on commit, to avoid stopping commits going through CQ.
630 results.append(output_api.PresubmitNotifyResult(_INCLUDE_ORDER_WARNING,
631 warnings))
[email protected]cf9b78f2012-11-14 11:40:28632 return results
633
634
[email protected]70ca77752012-11-20 03:45:03635def _CheckForVersionControlConflictsInFile(input_api, f):
636 pattern = input_api.re.compile('^(?:<<<<<<<|>>>>>>>) |^=======$')
637 errors = []
638 for line_num, line in f.ChangedContents():
639 if pattern.match(line):
640 errors.append(' %s:%d %s' % (f.LocalPath(), line_num, line))
641 return errors
642
643
644def _CheckForVersionControlConflicts(input_api, output_api):
645 """Usually this is not intentional and will cause a compile failure."""
646 errors = []
647 for f in input_api.AffectedFiles():
648 errors.extend(_CheckForVersionControlConflictsInFile(input_api, f))
649
650 results = []
651 if errors:
652 results.append(output_api.PresubmitError(
653 'Version control conflict markers found, please resolve.', errors))
654 return results
655
656
[email protected]06e6d0ff2012-12-11 01:36:44657def _CheckHardcodedGoogleHostsInLowerLayers(input_api, output_api):
658 def FilterFile(affected_file):
659 """Filter function for use with input_api.AffectedSourceFiles,
660 below. This filters out everything except non-test files from
661 top-level directories that generally speaking should not hard-code
662 service URLs (e.g. src/android_webview/, src/content/ and others).
663 """
664 return input_api.FilterSourceFile(
665 affected_file,
[email protected]78bb39d62012-12-11 15:11:56666 white_list=(r'^(android_webview|base|content|net)[\\\/].*', ),
[email protected]06e6d0ff2012-12-11 01:36:44667 black_list=(_EXCLUDED_PATHS +
668 _TEST_CODE_EXCLUDED_PATHS +
669 input_api.DEFAULT_BLACK_LIST))
670
671 pattern = input_api.re.compile('"[^"]*google\.com[^"]*"')
672 problems = [] # items are (filename, line_number, line)
673 for f in input_api.AffectedSourceFiles(FilterFile):
674 for line_num, line in f.ChangedContents():
675 if pattern.search(line):
676 problems.append((f.LocalPath(), line_num, line))
677
678 if problems:
[email protected]2fdd1f362013-01-16 03:56:03679 if not input_api.is_committing:
680 warning_factory = output_api.PresubmitPromptWarning
681 else:
[email protected]06e6d0ff2012-12-11 01:36:44682 # We don't want to block use of the CQ when there is a warning
683 # of this kind, so we only show a message when committing.
684 warning_factory = output_api.PresubmitNotifyResult
685 return [warning_factory(
686 'Most layers below src/chrome/ should not hardcode service URLs.\n'
687 'Are you sure this is correct? (Contact: [email protected])',
688 [' %s:%d: %s' % (
689 problem[0], problem[1], problem[2]) for problem in problems])]
[email protected]2fdd1f362013-01-16 03:56:03690 else:
691 return []
[email protected]06e6d0ff2012-12-11 01:36:44692
693
[email protected]d2530012013-01-25 16:39:27694def _CheckNoAbbreviationInPngFileName(input_api, output_api):
695 """Makes sure there are no abbreviations in the name of PNG files.
696 """
[email protected]4053a48e2013-01-25 21:43:04697 pattern = input_api.re.compile(r'.*_[a-z]_.*\.png$|.*_[a-z]\.png$')
[email protected]d2530012013-01-25 16:39:27698 errors = []
699 for f in input_api.AffectedFiles(include_deletes=False):
700 if pattern.match(f.LocalPath()):
701 errors.append(' %s' % f.LocalPath())
702
703 results = []
704 if errors:
705 results.append(output_api.PresubmitError(
706 'The name of PNG files should not have abbreviations. \n'
707 'Use _hover.png, _center.png, instead of _h.png, _c.png.\n'
708 'Contact [email protected] if you have questions.', errors))
709 return results
710
711
[email protected]22c9bd72011-03-27 16:47:39712def _CommonChecks(input_api, output_api):
713 """Checks common to both upload and commit."""
714 results = []
715 results.extend(input_api.canned_checks.PanProjectChecks(
716 input_api, output_api, excluded_paths=_EXCLUDED_PATHS))
[email protected]66daa702011-05-28 14:41:46717 results.extend(_CheckAuthorizedAuthor(input_api, output_api))
[email protected]55459852011-08-10 15:17:19718 results.extend(
719 _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api))
[email protected]10689ca2011-09-02 02:31:54720 results.extend(_CheckNoIOStreamInHeaders(input_api, output_api))
[email protected]72df4e782012-06-21 16:28:18721 results.extend(_CheckNoUNIT_TESTInSourceFiles(input_api, output_api))
[email protected]8ea5d4b2011-09-13 21:49:22722 results.extend(_CheckNoNewWStrings(input_api, output_api))
[email protected]2a8ac9c2011-10-19 17:20:44723 results.extend(_CheckNoDEPSGIT(input_api, output_api))
[email protected]127f18ec2012-06-16 05:05:59724 results.extend(_CheckNoBannedFunctions(input_api, output_api))
[email protected]6c063c62012-07-11 19:11:06725 results.extend(_CheckNoPragmaOnce(input_api, output_api))
[email protected]e7479052012-09-19 00:26:12726 results.extend(_CheckNoTrinaryTrueFalse(input_api, output_api))
[email protected]55f9f382012-07-31 11:02:18727 results.extend(_CheckUnwantedDependencies(input_api, output_api))
[email protected]fbcafe5a2012-08-08 15:31:22728 results.extend(_CheckFilePermissions(input_api, output_api))
[email protected]c8278b32012-10-30 20:35:49729 results.extend(_CheckNoAuraWindowPropertyHInHeaders(input_api, output_api))
[email protected]2309b0fa02012-11-16 12:18:27730 results.extend(_CheckIncludeOrder(input_api, output_api))
[email protected]70ca77752012-11-20 03:45:03731 results.extend(_CheckForVersionControlConflicts(input_api, output_api))
[email protected]b8079ae4a2012-12-05 19:56:49732 results.extend(_CheckPatchFiles(input_api, output_api))
[email protected]06e6d0ff2012-12-11 01:36:44733 results.extend(_CheckHardcodedGoogleHostsInLowerLayers(input_api, output_api))
[email protected]d2530012013-01-25 16:39:27734 results.extend(_CheckNoAbbreviationInPngFileName(input_api, output_api))
[email protected]b00342e7f2013-03-26 16:21:54735 results.extend(_CheckForInvalidOSMacros(input_api, output_api))
[email protected]2299dcf2012-11-15 19:56:24736
737 if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()):
738 results.extend(input_api.canned_checks.RunUnitTestsInDirectory(
739 input_api, output_api,
740 input_api.PresubmitLocalPath(),
[email protected]6be63382013-01-21 15:42:38741 whitelist=[r'^PRESUBMIT_test\.py$']))
[email protected]22c9bd72011-03-27 16:47:39742 return results
[email protected]1f7b4172010-01-28 01:17:34743
[email protected]b337cb5b2011-01-23 21:24:05744
745def _CheckSubversionConfig(input_api, output_api):
746 """Verifies the subversion config file is correctly setup.
747
748 Checks that autoprops are enabled, returns an error otherwise.
749 """
750 join = input_api.os_path.join
751 if input_api.platform == 'win32':
752 appdata = input_api.environ.get('APPDATA', '')
753 if not appdata:
754 return [output_api.PresubmitError('%APPDATA% is not configured.')]
755 path = join(appdata, 'Subversion', 'config')
756 else:
757 home = input_api.environ.get('HOME', '')
758 if not home:
759 return [output_api.PresubmitError('$HOME is not configured.')]
760 path = join(home, '.subversion', 'config')
761
762 error_msg = (
763 'Please look at http://dev.chromium.org/developers/coding-style to\n'
764 'configure your subversion configuration file. This enables automatic\n'
[email protected]c6a3c10b2011-01-24 16:14:20765 'properties to simplify the project maintenance.\n'
766 'Pro-tip: just download and install\n'
767 'http://src.chromium.org/viewvc/chrome/trunk/tools/build/slave/config\n')
[email protected]b337cb5b2011-01-23 21:24:05768
769 try:
770 lines = open(path, 'r').read().splitlines()
771 # Make sure auto-props is enabled and check for 2 Chromium standard
772 # auto-prop.
773 if (not '*.cc = svn:eol-style=LF' in lines or
774 not '*.pdf = svn:mime-type=application/pdf' in lines or
775 not 'enable-auto-props = yes' in lines):
776 return [
[email protected]79ed7e62011-02-21 21:08:53777 output_api.PresubmitNotifyResult(
[email protected]b337cb5b2011-01-23 21:24:05778 'It looks like you have not configured your subversion config '
[email protected]b5359c02011-02-01 20:29:56779 'file or it is not up-to-date.\n' + error_msg)
[email protected]b337cb5b2011-01-23 21:24:05780 ]
781 except (OSError, IOError):
782 return [
[email protected]79ed7e62011-02-21 21:08:53783 output_api.PresubmitNotifyResult(
[email protected]b337cb5b2011-01-23 21:24:05784 'Can\'t find your subversion config file.\n' + error_msg)
785 ]
786 return []
787
788
[email protected]66daa702011-05-28 14:41:46789def _CheckAuthorizedAuthor(input_api, output_api):
790 """For non-googler/chromites committers, verify the author's email address is
791 in AUTHORS.
792 """
[email protected]9bb9cb82011-06-13 20:43:01793 # TODO(maruel): Add it to input_api?
794 import fnmatch
795
[email protected]66daa702011-05-28 14:41:46796 author = input_api.change.author_email
[email protected]9bb9cb82011-06-13 20:43:01797 if not author:
798 input_api.logging.info('No author, skipping AUTHOR check')
[email protected]66daa702011-05-28 14:41:46799 return []
[email protected]c99663292011-05-31 19:46:08800 authors_path = input_api.os_path.join(
[email protected]66daa702011-05-28 14:41:46801 input_api.PresubmitLocalPath(), 'AUTHORS')
802 valid_authors = (
803 input_api.re.match(r'[^#]+\s+\<(.+?)\>\s*$', line)
804 for line in open(authors_path))
[email protected]ac54b132011-06-06 18:11:18805 valid_authors = [item.group(1).lower() for item in valid_authors if item]
[email protected]d8b50be2011-06-15 14:19:44806 if not any(fnmatch.fnmatch(author.lower(), valid) for valid in valid_authors):
[email protected]5861efb2013-01-07 18:33:23807 input_api.logging.info('Valid authors are %s', ', '.join(valid_authors))
[email protected]66daa702011-05-28 14:41:46808 return [output_api.PresubmitPromptWarning(
809 ('%s is not in AUTHORS file. If you are a new contributor, please visit'
810 '\n'
811 'http://www.chromium.org/developers/contributing-code and read the '
812 '"Legal" section\n'
813 'If you are a chromite, verify the contributor signed the CLA.') %
814 author)]
815 return []
816
817
[email protected]b8079ae4a2012-12-05 19:56:49818def _CheckPatchFiles(input_api, output_api):
819 problems = [f.LocalPath() for f in input_api.AffectedFiles()
820 if f.LocalPath().endswith(('.orig', '.rej'))]
821 if problems:
822 return [output_api.PresubmitError(
823 "Don't commit .rej and .orig files.", problems)]
[email protected]2fdd1f362013-01-16 03:56:03824 else:
825 return []
[email protected]b8079ae4a2012-12-05 19:56:49826
827
[email protected]b00342e7f2013-03-26 16:21:54828def _DidYouMeanOSMacro(bad_macro):
829 try:
830 return {'A': 'OS_ANDROID',
831 'B': 'OS_BSD',
832 'C': 'OS_CHROMEOS',
833 'F': 'OS_FREEBSD',
834 'L': 'OS_LINUX',
835 'M': 'OS_MACOSX',
836 'N': 'OS_NACL',
837 'O': 'OS_OPENBSD',
838 'P': 'OS_POSIX',
839 'S': 'OS_SOLARIS',
840 'W': 'OS_WIN'}[bad_macro[3].upper()]
841 except KeyError:
842 return ''
843
844
845def _CheckForInvalidOSMacrosInFile(input_api, f):
846 """Check for sensible looking, totally invalid OS macros."""
847 preprocessor_statement = input_api.re.compile(r'^\s*#')
848 os_macro = input_api.re.compile(r'defined\((OS_[^)]+)\)')
849 results = []
850 for lnum, line in f.ChangedContents():
851 if preprocessor_statement.search(line):
852 for match in os_macro.finditer(line):
853 if not match.group(1) in _VALID_OS_MACROS:
854 good = _DidYouMeanOSMacro(match.group(1))
855 did_you_mean = ' (did you mean %s?)' % good if good else ''
856 results.append(' %s:%d %s%s' % (f.LocalPath(),
857 lnum,
858 match.group(1),
859 did_you_mean))
860 return results
861
862
863def _CheckForInvalidOSMacros(input_api, output_api):
864 """Check all affected files for invalid OS macros."""
865 bad_macros = []
866 for f in input_api.AffectedFiles():
867 if not f.LocalPath().endswith(('.py', '.js', '.html', '.css')):
868 bad_macros.extend(_CheckForInvalidOSMacrosInFile(input_api, f))
869
870 if not bad_macros:
871 return []
872
873 return [output_api.PresubmitError(
874 'Possibly invalid OS macro[s] found. Please fix your code\n'
875 'or add your macro to src/PRESUBMIT.py.', bad_macros)]
876
877
[email protected]1f7b4172010-01-28 01:17:34878def CheckChangeOnUpload(input_api, output_api):
879 results = []
880 results.extend(_CommonChecks(input_api, output_api))
[email protected]fe5f57c52009-06-05 14:25:54881 return results
[email protected]ca8d19842009-02-19 16:33:12882
883
884def CheckChangeOnCommit(input_api, output_api):
[email protected]fe5f57c52009-06-05 14:25:54885 results = []
[email protected]1f7b4172010-01-28 01:17:34886 results.extend(_CommonChecks(input_api, output_api))
[email protected]dd805fe2009-10-01 08:11:51887 # TODO(thestig) temporarily disabled, doesn't work in third_party/
888 #results.extend(input_api.canned_checks.CheckSvnModifiedDirectories(
889 # input_api, output_api, sources))
[email protected]fe5f57c52009-06-05 14:25:54890 # Make sure the tree is 'open'.
[email protected]806e98e2010-03-19 17:49:27891 results.extend(input_api.canned_checks.CheckTreeIsOpen(
[email protected]7f238152009-08-12 19:00:34892 input_api,
893 output_api,
[email protected]2fdd1f362013-01-16 03:56:03894 json_url='http://chromium-status.appspot.com/current?format=json'))
[email protected]806e98e2010-03-19 17:49:27895 results.extend(input_api.canned_checks.CheckRietveldTryJobExecution(input_api,
[email protected]2fdd1f362013-01-16 03:56:03896 output_api, 'http://codereview.chromium.org',
[email protected]c1ba4c52012-03-09 14:23:28897 ('win_rel', 'linux_rel', 'mac_rel, win:compile'),
898 '[email protected]'))
[email protected]806e98e2010-03-19 17:49:27899
[email protected]3e4eb112011-01-18 03:29:54900 results.extend(input_api.canned_checks.CheckChangeHasBugField(
901 input_api, output_api))
[email protected]c4b47562011-12-05 23:39:41902 results.extend(input_api.canned_checks.CheckChangeHasDescription(
903 input_api, output_api))
[email protected]b337cb5b2011-01-23 21:24:05904 results.extend(_CheckSubversionConfig(input_api, output_api))
[email protected]fe5f57c52009-06-05 14:25:54905 return results
[email protected]ca8d19842009-02-19 16:33:12906
907
[email protected]5efb2a822011-09-27 23:06:13908def GetPreferredTrySlaves(project, change):
[email protected]4ce995ea2012-06-27 02:13:10909 files = change.LocalPaths()
910
[email protected]751b05f2013-01-10 23:12:17911 if not files or all(re.search(r'[\\/]OWNERS$', f) for f in files):
[email protected]3019c902012-06-29 00:09:03912 return []
913
[email protected]d668899a2012-09-06 18:16:59914 if all(re.search('\.(m|mm)$|(^|[/_])mac[/_.]', f) for f in files):
[email protected]7fab6202013-02-21 17:54:35915 return ['mac_rel', 'mac_asan', 'mac:compile']
[email protected]d668899a2012-09-06 18:16:59916 if all(re.search('(^|[/_])win[/_.]', f) for f in files):
[email protected]7fab6202013-02-21 17:54:35917 return ['win_rel', 'win7_aura', 'win:compile']
[email protected]d668899a2012-09-06 18:16:59918 if all(re.search('(^|[/_])android[/_.]', f) for f in files):
[email protected]3e2f0402012-11-02 16:28:01919 return ['android_dbg', 'android_clang_dbg']
[email protected]356aa542012-09-19 23:31:29920 if all(re.search('^native_client_sdk', f) for f in files):
921 return ['linux_nacl_sdk', 'win_nacl_sdk', 'mac_nacl_sdk']
[email protected]de142152012-10-03 23:02:45922 if all(re.search('[/_]ios[/_.]', f) for f in files):
923 return ['ios_rel_device', 'ios_dbg_simulator']
[email protected]4ce995ea2012-06-27 02:13:10924
[email protected]3e2f0402012-11-02 16:28:01925 trybots = [
926 'android_clang_dbg',
927 'android_dbg',
928 'ios_dbg_simulator',
929 'ios_rel_device',
930 'linux_asan',
[email protected]95c989162012-11-29 05:58:25931 'linux_aura',
[email protected]3e2f0402012-11-02 16:28:01932 'linux_chromeos',
933 'linux_clang:compile',
934 'linux_rel',
935 'mac_asan',
936 'mac_rel',
[email protected]7fab6202013-02-21 17:54:35937 'mac:compile',
[email protected]aa85c8b2013-01-11 04:20:28938 'win7_aura',
[email protected]3e2f0402012-11-02 16:28:01939 'win_rel',
[email protected]7fab6202013-02-21 17:54:35940 'win:compile',
[email protected]3e2f0402012-11-02 16:28:01941 ]
[email protected]911753b2012-08-02 12:11:54942
943 # Match things like path/aura/file.cc and path/file_aura.cc.
[email protected]95c989162012-11-29 05:58:25944 # Same for chromeos.
945 if any(re.search('[/_](aura|chromeos)', f) for f in files):
[email protected]3e2f0402012-11-02 16:28:01946 trybots += ['linux_chromeos_clang:compile', 'linux_chromeos_asan']
[email protected]4ce995ea2012-06-27 02:13:10947
[email protected]4ce995ea2012-06-27 02:13:10948 return trybots