1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 """Top-level presubmit script for Chromium.
7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
8 for more details about the presubmit API built into gcl.
20 r
"^native_client_sdk[\\\/]src[\\\/]build_tools[\\\/]make_rules.py",
21 r
"^native_client_sdk[\\\/]src[\\\/]build_tools[\\\/]make_simple.py",
22 r
"^native_client_sdk[\\\/]src[\\\/]tools[\\\/].*.mk",
23 r
"^net[\\\/]tools[\\\/]spdyshark[\\\/].*",
28 r
".+[\\\/]pnacl_shim\.c$",
29 r
"^gpu[\\\/]config[\\\/].*_list_json\.cc$",
32 # TestRunner library is temporarily excluded from pan-project checks until
33 # it's transitioned to chromium coding style.
35 r
"^content[\\\/]shell[\\\/]renderer[\\\/]test_runner[\\\/].*",
36 r
"^content[\\\/]shell[\\\/]common[\\\/]test_runner[\\\/].*",
39 # Fragment of a regular expression that matches C++ and Objective-C++
40 # implementation files.
41 _IMPLEMENTATION_EXTENSIONS
= r
'\.(cc|cpp|cxx|mm)$'
43 # Regular expression that matches code only used for test binaries
45 _TEST_CODE_EXCLUDED_PATHS
= (
46 r
'.*[/\\](fake_|test_|mock_).+%s' % _IMPLEMENTATION_EXTENSIONS
,
47 r
'.+_test_(base|support|util)%s' % _IMPLEMENTATION_EXTENSIONS
,
48 r
'.+_(api|browser|perf|pixel|unit|ui)?test(_[a-z]+)?%s' %
49 _IMPLEMENTATION_EXTENSIONS
,
50 r
'.+profile_sync_service_harness%s' % _IMPLEMENTATION_EXTENSIONS
,
51 r
'.*[/\\](test|tool(s)?)[/\\].*',
52 # content_shell is used for running layout tests.
53 r
'content[/\\]shell[/\\].*',
54 # At request of folks maintaining this folder.
55 r
'chrome[/\\]browser[/\\]automation[/\\].*',
56 # Non-production example code.
57 r
'mojo[/\\]examples[/\\].*',
60 _TEST_ONLY_WARNING
= (
61 'You might be calling functions intended only for testing from\n'
62 'production code. It is OK to ignore this warning if you know what\n'
63 'you are doing, as the heuristics used to detect the situation are\n'
64 'not perfect. The commit queue will not block on this warning.\n'
65 'Email joi@chromium.org if you have questions.')
68 _INCLUDE_ORDER_WARNING
= (
69 'Your #include order seems to be broken. Send mail to\n'
70 'marja@chromium.org if this is not the case.')
73 _BANNED_OBJC_FUNCTIONS
= (
77 'The use of -[NSView addTrackingRect:owner:userData:assumeInside:] is'
78 'prohibited. Please use CrTrackingArea instead.',
79 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
86 'The use of NSTrackingAreas is prohibited. Please use CrTrackingArea',
88 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
93 'convertPointFromBase:',
95 'The use of -[NSView convertPointFromBase:] is almost certainly wrong.',
96 'Please use |convertPoint:(point) fromView:nil| instead.',
97 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
102 'convertPointToBase:',
104 'The use of -[NSView convertPointToBase:] is almost certainly wrong.',
105 'Please use |convertPoint:(point) toView:nil| instead.',
106 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
111 'convertRectFromBase:',
113 'The use of -[NSView convertRectFromBase:] is almost certainly wrong.',
114 'Please use |convertRect:(point) fromView:nil| instead.',
115 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
120 'convertRectToBase:',
122 'The use of -[NSView convertRectToBase:] is almost certainly wrong.',
123 'Please use |convertRect:(point) toView:nil| instead.',
124 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
129 'convertSizeFromBase:',
131 'The use of -[NSView convertSizeFromBase:] is almost certainly wrong.',
132 'Please use |convertSize:(point) fromView:nil| instead.',
133 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
138 'convertSizeToBase:',
140 'The use of -[NSView convertSizeToBase:] is almost certainly wrong.',
141 'Please use |convertSize:(point) toView:nil| instead.',
142 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
149 _BANNED_CPP_FUNCTIONS
= (
150 # Make sure that gtest's FRIEND_TEST() macro is not used; the
151 # FRIEND_TEST_ALL_PREFIXES() macro from base/gtest_prod_util.h should be
152 # used instead since that allows for FLAKY_ and DISABLED_ prefixes.
156 'Chromium code should not use gtest\'s FRIEND_TEST() macro. Include',
157 'base/gtest_prod_util.h and use FRIEND_TEST_ALL_PREFIXES() instead.',
165 'New code should not use ScopedAllowIO. Post a task to the blocking',
166 'pool or the FILE thread instead.',
170 r
"^components[\\\/]breakpad[\\\/]app[\\\/]breakpad_mac\.mm$",
171 r
"^content[\\\/]shell[\\\/]browser[\\\/]shell_browser_main\.cc$",
172 r
"^content[\\\/]shell[\\\/]browser[\\\/]shell_message_filter\.cc$",
173 r
"^net[\\\/]disk_cache[\\\/]cache_util\.cc$",
179 'The use of SkRefPtr is prohibited. ',
180 'Please use skia::RefPtr instead.'
188 'The indirect use of SkRefPtr via SkAutoRef is prohibited. ',
189 'Please use skia::RefPtr instead.'
197 'The use of SkAutoTUnref is dangerous because it implicitly ',
198 'converts to a raw pointer. Please use skia::RefPtr instead.'
206 'The indirect use of SkAutoTUnref through SkAutoUnref is dangerous ',
207 'because it implicitly converts to a raw pointer. ',
208 'Please use skia::RefPtr instead.'
214 r
'/HANDLE_EINTR\(.*close',
216 'HANDLE_EINTR(close) is invalid. If close fails with EINTR, the file',
217 'descriptor will be closed, and it is incorrect to retry the close.',
218 'Either call close directly and ignore its return value, or wrap close',
219 'in IGNORE_EINTR to use its return value. See http://crbug.com/269623'
225 r
'/IGNORE_EINTR\((?!.*close)',
227 'IGNORE_EINTR is only valid when wrapping close. To wrap other system',
228 'calls, use HANDLE_EINTR. See http://crbug.com/269623',
232 # Files that #define IGNORE_EINTR.
233 r
'^base[\\\/]posix[\\\/]eintr_wrapper\.h$',
234 r
'^ppapi[\\\/]tests[\\\/]test_broker\.cc$',
241 # Please keep sorted.
244 'OS_CAT', # For testing.
258 def _CheckNoProductionCodeUsingTestOnlyFunctions(input_api
, output_api
):
259 """Attempts to prevent use of functions intended only for testing in
260 non-testing code. For now this is just a best-effort implementation
261 that ignores header files and may have some false positives. A
262 better implementation would probably need a proper C++ parser.
264 # We only scan .cc files and the like, as the declaration of
265 # for-testing functions in header files are hard to distinguish from
266 # calls to such functions without a proper C++ parser.
267 file_inclusion_pattern
= r
'.+%s' % _IMPLEMENTATION_EXTENSIONS
269 base_function_pattern
= r
'ForTest(ing)?|for_test(ing)?'
270 inclusion_pattern
= input_api
.re
.compile(r
'(%s)\s*\(' % base_function_pattern
)
271 comment_pattern
= input_api
.re
.compile(r
'//.*%s' % base_function_pattern
)
272 exclusion_pattern
= input_api
.re
.compile(
273 r
'::[A-Za-z0-9_]+(%s)|(%s)[^;]+\{' % (
274 base_function_pattern
, base_function_pattern
))
276 def FilterFile(affected_file
):
277 black_list
= (_EXCLUDED_PATHS
+
278 _TEST_CODE_EXCLUDED_PATHS
+
279 input_api
.DEFAULT_BLACK_LIST
)
280 return input_api
.FilterSourceFile(
282 white_list
=(file_inclusion_pattern
, ),
283 black_list
=black_list
)
286 for f
in input_api
.AffectedSourceFiles(FilterFile
):
287 local_path
= f
.LocalPath()
288 for line_number
, line
in f
.ChangedContents():
289 if (inclusion_pattern
.search(line
) and
290 not comment_pattern
.search(line
) and
291 not exclusion_pattern
.search(line
)):
293 '%s:%d\n %s' % (local_path
, line_number
, line
.strip()))
296 return [output_api
.PresubmitPromptOrNotify(_TEST_ONLY_WARNING
, problems
)]
301 def _CheckNoIOStreamInHeaders(input_api
, output_api
):
302 """Checks to make sure no .h files include <iostream>."""
304 pattern
= input_api
.re
.compile(r
'^#include\s*<iostream>',
305 input_api
.re
.MULTILINE
)
306 for f
in input_api
.AffectedSourceFiles(input_api
.FilterSourceFile
):
307 if not f
.LocalPath().endswith('.h'):
309 contents
= input_api
.ReadFile(f
)
310 if pattern
.search(contents
):
314 return [ output_api
.PresubmitError(
315 'Do not #include <iostream> in header files, since it inserts static '
316 'initialization into every file including the header. Instead, '
317 '#include <ostream>. See http://crbug.com/94794',
322 def _CheckNoUNIT_TESTInSourceFiles(input_api
, output_api
):
323 """Checks to make sure no source files use UNIT_TEST"""
325 for f
in input_api
.AffectedFiles():
326 if (not f
.LocalPath().endswith(('.cc', '.mm'))):
329 for line_num
, line
in f
.ChangedContents():
330 if 'UNIT_TEST ' in line
or line
.endswith('UNIT_TEST'):
331 problems
.append(' %s:%d' % (f
.LocalPath(), line_num
))
335 return [output_api
.PresubmitPromptWarning('UNIT_TEST is only for headers.\n' +
336 '\n'.join(problems
))]
339 def _CheckNoNewWStrings(input_api
, output_api
):
340 """Checks to make sure we don't introduce use of wstrings."""
342 for f
in input_api
.AffectedFiles():
343 if (not f
.LocalPath().endswith(('.cc', '.h')) or
344 f
.LocalPath().endswith(('test.cc', '_win.cc', '_win.h'))):
348 for line_num
, line
in f
.ChangedContents():
349 if 'presubmit: allow wstring' in line
:
351 elif not allowWString
and 'wstring' in line
:
352 problems
.append(' %s:%d' % (f
.LocalPath(), line_num
))
359 return [output_api
.PresubmitPromptWarning('New code should not use wstrings.'
360 ' If you are calling a cross-platform API that accepts a wstring, '
362 '\n'.join(problems
))]
365 def _CheckNoDEPSGIT(input_api
, output_api
):
366 """Make sure .DEPS.git is never modified manually."""
367 if any(f
.LocalPath().endswith('.DEPS.git') for f
in
368 input_api
.AffectedFiles()):
369 return [output_api
.PresubmitError(
370 'Never commit changes to .DEPS.git. This file is maintained by an\n'
371 'automated system based on what\'s in DEPS and your changes will be\n'
373 'See http://code.google.com/p/chromium/wiki/UsingNewGit#Rolling_DEPS\n'
374 'for more information')]
378 def _CheckNoBannedFunctions(input_api
, output_api
):
379 """Make sure that banned functions are not used."""
383 file_filter
= lambda f
: f
.LocalPath().endswith(('.mm', '.m', '.h'))
384 for f
in input_api
.AffectedFiles(file_filter
=file_filter
):
385 for line_num
, line
in f
.ChangedContents():
386 for func_name
, message
, error
in _BANNED_OBJC_FUNCTIONS
:
387 if func_name
in line
:
391 problems
.append(' %s:%d:' % (f
.LocalPath(), line_num
))
392 for message_line
in message
:
393 problems
.append(' %s' % message_line
)
395 file_filter
= lambda f
: f
.LocalPath().endswith(('.cc', '.mm', '.h'))
396 for f
in input_api
.AffectedFiles(file_filter
=file_filter
):
397 for line_num
, line
in f
.ChangedContents():
398 for func_name
, message
, error
, excluded_paths
in _BANNED_CPP_FUNCTIONS
:
399 def IsBlacklisted(affected_file
, blacklist
):
400 local_path
= affected_file
.LocalPath()
401 for item
in blacklist
:
402 if input_api
.re
.match(item
, local_path
):
405 if IsBlacklisted(f
, excluded_paths
):
408 if func_name
[0:1] == '/':
409 regex
= func_name
[1:]
410 if input_api
.re
.search(regex
, line
):
412 elif func_name
in line
:
418 problems
.append(' %s:%d:' % (f
.LocalPath(), line_num
))
419 for message_line
in message
:
420 problems
.append(' %s' % message_line
)
424 result
.append(output_api
.PresubmitPromptWarning(
425 'Banned functions were used.\n' + '\n'.join(warnings
)))
427 result
.append(output_api
.PresubmitError(
428 'Banned functions were used.\n' + '\n'.join(errors
)))
432 def _CheckNoPragmaOnce(input_api
, output_api
):
433 """Make sure that banned functions are not used."""
435 pattern
= input_api
.re
.compile(r
'^#pragma\s+once',
436 input_api
.re
.MULTILINE
)
437 for f
in input_api
.AffectedSourceFiles(input_api
.FilterSourceFile
):
438 if not f
.LocalPath().endswith('.h'):
440 contents
= input_api
.ReadFile(f
)
441 if pattern
.search(contents
):
445 return [output_api
.PresubmitError(
446 'Do not use #pragma once in header files.\n'
447 'See http://www.chromium.org/developers/coding-style#TOC-File-headers',
452 def _CheckNoTrinaryTrueFalse(input_api
, output_api
):
453 """Checks to make sure we don't introduce use of foo ? true : false."""
455 pattern
= input_api
.re
.compile(r
'\?\s*(true|false)\s*:\s*(true|false)')
456 for f
in input_api
.AffectedFiles():
457 if not f
.LocalPath().endswith(('.cc', '.h', '.inl', '.m', '.mm')):
460 for line_num
, line
in f
.ChangedContents():
461 if pattern
.match(line
):
462 problems
.append(' %s:%d' % (f
.LocalPath(), line_num
))
466 return [output_api
.PresubmitPromptWarning(
467 'Please consider avoiding the "? true : false" pattern if possible.\n' +
468 '\n'.join(problems
))]
471 def _CheckUnwantedDependencies(input_api
, output_api
):
472 """Runs checkdeps on #include statements added in this
473 change. Breaking - rules is an error, breaking ! rules is a
476 # We need to wait until we have an input_api object and use this
477 # roundabout construct to import checkdeps because this file is
478 # eval-ed and thus doesn't have __file__.
479 original_sys_path
= sys
.path
481 sys
.path
= sys
.path
+ [input_api
.os_path
.join(
482 input_api
.PresubmitLocalPath(), 'tools', 'checkdeps')]
484 from cpp_checker
import CppChecker
485 from rules
import Rule
487 # Restore sys.path to what it was before.
488 sys
.path
= original_sys_path
491 for f
in input_api
.AffectedFiles():
492 if not CppChecker
.IsCppFile(f
.LocalPath()):
495 changed_lines
= [line
for line_num
, line
in f
.ChangedContents()]
496 added_includes
.append([f
.LocalPath(), changed_lines
])
498 deps_checker
= checkdeps
.DepsChecker(input_api
.PresubmitLocalPath())
500 error_descriptions
= []
501 warning_descriptions
= []
502 for path
, rule_type
, rule_description
in deps_checker
.CheckAddedCppIncludes(
504 description_with_path
= '%s\n %s' % (path
, rule_description
)
505 if rule_type
== Rule
.DISALLOW
:
506 error_descriptions
.append(description_with_path
)
508 warning_descriptions
.append(description_with_path
)
511 if error_descriptions
:
512 results
.append(output_api
.PresubmitError(
513 'You added one or more #includes that violate checkdeps rules.',
515 if warning_descriptions
:
516 results
.append(output_api
.PresubmitPromptOrNotify(
517 'You added one or more #includes of files that are temporarily\n'
518 'allowed but being removed. Can you avoid introducing the\n'
519 '#include? See relevant DEPS file(s) for details and contacts.',
520 warning_descriptions
))
524 def _CheckFilePermissions(input_api
, output_api
):
525 """Check that all files have their permissions properly set."""
526 args
= [sys
.executable
, 'tools/checkperms/checkperms.py', '--root',
527 input_api
.change
.RepositoryRoot()]
528 for f
in input_api
.AffectedFiles():
529 args
+= ['--file', f
.LocalPath()]
531 (errors
, stderrdata
) = subprocess
.Popen(args
).communicate()
535 results
.append(output_api
.PresubmitError('checkperms.py failed.',
540 def _CheckNoAuraWindowPropertyHInHeaders(input_api
, output_api
):
541 """Makes sure we don't include ui/aura/window_property.h
544 pattern
= input_api
.re
.compile(r
'^#include\s*"ui/aura/window_property.h"')
546 for f
in input_api
.AffectedFiles():
547 if not f
.LocalPath().endswith('.h'):
549 for line_num
, line
in f
.ChangedContents():
550 if pattern
.match(line
):
551 errors
.append(' %s:%d' % (f
.LocalPath(), line_num
))
555 results
.append(output_api
.PresubmitError(
556 'Header files should not include ui/aura/window_property.h', errors
))
560 def _CheckIncludeOrderForScope(scope
, input_api
, file_path
, changed_linenums
):
561 """Checks that the lines in scope occur in the right order.
563 1. C system files in alphabetical order
564 2. C++ system files in alphabetical order
565 3. Project's .h files
568 c_system_include_pattern
= input_api
.re
.compile(r
'\s*#include <.*\.h>')
569 cpp_system_include_pattern
= input_api
.re
.compile(r
'\s*#include <.*>')
570 custom_include_pattern
= input_api
.re
.compile(r
'\s*#include ".*')
572 C_SYSTEM_INCLUDES
, CPP_SYSTEM_INCLUDES
, CUSTOM_INCLUDES
= range(3)
574 state
= C_SYSTEM_INCLUDES
577 previous_line_num
= 0
578 problem_linenums
= []
579 for line_num
, line
in scope
:
580 if c_system_include_pattern
.match(line
):
581 if state
!= C_SYSTEM_INCLUDES
:
582 problem_linenums
.append((line_num
, previous_line_num
))
583 elif previous_line
and previous_line
> line
:
584 problem_linenums
.append((line_num
, previous_line_num
))
585 elif cpp_system_include_pattern
.match(line
):
586 if state
== C_SYSTEM_INCLUDES
:
587 state
= CPP_SYSTEM_INCLUDES
588 elif state
== CUSTOM_INCLUDES
:
589 problem_linenums
.append((line_num
, previous_line_num
))
590 elif previous_line
and previous_line
> line
:
591 problem_linenums
.append((line_num
, previous_line_num
))
592 elif custom_include_pattern
.match(line
):
593 if state
!= CUSTOM_INCLUDES
:
594 state
= CUSTOM_INCLUDES
595 elif previous_line
and previous_line
> line
:
596 problem_linenums
.append((line_num
, previous_line_num
))
598 problem_linenums
.append(line_num
)
600 previous_line_num
= line_num
603 for (line_num
, previous_line_num
) in problem_linenums
:
604 if line_num
in changed_linenums
or previous_line_num
in changed_linenums
:
605 warnings
.append(' %s:%d' % (file_path
, line_num
))
609 def _CheckIncludeOrderInFile(input_api
, f
, changed_linenums
):
610 """Checks the #include order for the given file f."""
612 system_include_pattern
= input_api
.re
.compile(r
'\s*#include \<.*')
613 # Exclude the following includes from the check:
614 # 1) #include <.../...>, e.g., <sys/...> includes often need to appear in a
616 # 2) <atlbase.h>, "build/build_config.h"
617 excluded_include_pattern
= input_api
.re
.compile(
618 r
'\s*#include (\<.*/.*|\<atlbase\.h\>|"build/build_config.h")')
619 custom_include_pattern
= input_api
.re
.compile(r
'\s*#include "(?P<FILE>.*)"')
620 # Match the final or penultimate token if it is xxxtest so we can ignore it
621 # when considering the special first include.
622 test_file_tag_pattern
= input_api
.re
.compile(
623 r
'_[a-z]+test(?=(_[a-zA-Z0-9]+)?\.)')
624 if_pattern
= input_api
.re
.compile(
625 r
'\s*#\s*(if|elif|else|endif|define|undef).*')
626 # Some files need specialized order of includes; exclude such files from this
628 uncheckable_includes_pattern
= input_api
.re
.compile(
630 '("ipc/.*macros\.h"|<windows\.h>|".*gl.*autogen.h")\s*')
632 contents
= f
.NewContents()
636 # Handle the special first include. If the first include file is
637 # some/path/file.h, the corresponding including file can be some/path/file.cc,
638 # some/other/path/file.cc, some/path/file_platform.cc, some/path/file-suffix.h
639 # etc. It's also possible that no special first include exists.
640 # If the included file is some/path/file_platform.h the including file could
641 # also be some/path/file_xxxtest_platform.h.
642 including_file_base_name
= test_file_tag_pattern
.sub(
643 '', input_api
.os_path
.basename(f
.LocalPath()))
645 for line
in contents
:
647 if system_include_pattern
.match(line
):
648 # No special first include -> process the line again along with normal
652 match
= custom_include_pattern
.match(line
)
654 match_dict
= match
.groupdict()
655 header_basename
= test_file_tag_pattern
.sub(
656 '', input_api
.os_path
.basename(match_dict
['FILE'])).replace('.h', '')
658 if header_basename
not in including_file_base_name
:
659 # No special first include -> process the line again along with normal
664 # Split into scopes: Each region between #if and #endif is its own scope.
667 for line
in contents
[line_num
:]:
669 if uncheckable_includes_pattern
.match(line
):
671 if if_pattern
.match(line
):
672 scopes
.append(current_scope
)
674 elif ((system_include_pattern
.match(line
) or
675 custom_include_pattern
.match(line
)) and
676 not excluded_include_pattern
.match(line
)):
677 current_scope
.append((line_num
, line
))
678 scopes
.append(current_scope
)
681 warnings
.extend(_CheckIncludeOrderForScope(scope
, input_api
, f
.LocalPath(),
686 def _CheckIncludeOrder(input_api
, output_api
):
687 """Checks that the #include order is correct.
689 1. The corresponding header for source files.
690 2. C system files in alphabetical order
691 3. C++ system files in alphabetical order
692 4. Project's .h files in alphabetical order
694 Each region separated by #if, #elif, #else, #endif, #define and #undef follows
695 these rules separately.
699 for f
in input_api
.AffectedFiles():
700 if f
.LocalPath().endswith(('.cc', '.h')):
701 changed_linenums
= set(line_num
for line_num
, _
in f
.ChangedContents())
702 warnings
.extend(_CheckIncludeOrderInFile(input_api
, f
, changed_linenums
))
706 results
.append(output_api
.PresubmitPromptOrNotify(_INCLUDE_ORDER_WARNING
,
711 def _CheckForVersionControlConflictsInFile(input_api
, f
):
712 pattern
= input_api
.re
.compile('^(?:<<<<<<<|>>>>>>>) |^=======$')
714 for line_num
, line
in f
.ChangedContents():
715 if pattern
.match(line
):
716 errors
.append(' %s:%d %s' % (f
.LocalPath(), line_num
, line
))
720 def _CheckForVersionControlConflicts(input_api
, output_api
):
721 """Usually this is not intentional and will cause a compile failure."""
723 for f
in input_api
.AffectedFiles():
724 errors
.extend(_CheckForVersionControlConflictsInFile(input_api
, f
))
728 results
.append(output_api
.PresubmitError(
729 'Version control conflict markers found, please resolve.', errors
))
733 def _CheckHardcodedGoogleHostsInLowerLayers(input_api
, output_api
):
734 def FilterFile(affected_file
):
735 """Filter function for use with input_api.AffectedSourceFiles,
736 below. This filters out everything except non-test files from
737 top-level directories that generally speaking should not hard-code
738 service URLs (e.g. src/android_webview/, src/content/ and others).
740 return input_api
.FilterSourceFile(
742 white_list
=(r
'^(android_webview|base|content|net)[\\\/].*', ),
743 black_list
=(_EXCLUDED_PATHS
+
744 _TEST_CODE_EXCLUDED_PATHS
+
745 input_api
.DEFAULT_BLACK_LIST
))
747 base_pattern
= '"[^"]*google\.com[^"]*"'
748 comment_pattern
= input_api
.re
.compile('//.*%s' % base_pattern
)
749 pattern
= input_api
.re
.compile(base_pattern
)
750 problems
= [] # items are (filename, line_number, line)
751 for f
in input_api
.AffectedSourceFiles(FilterFile
):
752 for line_num
, line
in f
.ChangedContents():
753 if not comment_pattern
.search(line
) and pattern
.search(line
):
754 problems
.append((f
.LocalPath(), line_num
, line
))
757 return [output_api
.PresubmitPromptOrNotify(
758 'Most layers below src/chrome/ should not hardcode service URLs.\n'
759 'Are you sure this is correct? (Contact: joi@chromium.org)',
761 problem
[0], problem
[1], problem
[2]) for problem
in problems
])]
766 def _CheckNoAbbreviationInPngFileName(input_api
, output_api
):
767 """Makes sure there are no abbreviations in the name of PNG files.
769 pattern
= input_api
.re
.compile(r
'.*_[a-z]_.*\.png$|.*_[a-z]\.png$')
771 for f
in input_api
.AffectedFiles(include_deletes
=False):
772 if pattern
.match(f
.LocalPath()):
773 errors
.append(' %s' % f
.LocalPath())
777 results
.append(output_api
.PresubmitError(
778 'The name of PNG files should not have abbreviations. \n'
779 'Use _hover.png, _center.png, instead of _h.png, _c.png.\n'
780 'Contact oshima@chromium.org if you have questions.', errors
))
784 def _FilesToCheckForIncomingDeps(re
, changed_lines
):
785 """Helper method for _CheckAddedDepsHaveTargetApprovals. Returns
786 a set of DEPS entries that we should look up.
788 For a directory (rather than a specific filename) we fake a path to
789 a specific filename by adding /DEPS. This is chosen as a file that
790 will seldom or never be subject to per-file include_rules.
792 # We ignore deps entries on auto-generated directories.
793 AUTO_GENERATED_DIRS
= ['grit', 'jni']
795 # This pattern grabs the path without basename in the first
796 # parentheses, and the basename (if present) in the second. It
797 # relies on the simple heuristic that if there is a basename it will
798 # be a header file ending in ".h".
799 pattern
= re
.compile(
800 r
"""['"]\+([^'"]+?)(/[a-zA-Z0-9_]+\.h)?['"].*""")
802 for changed_line
in changed_lines
:
803 m
= pattern
.match(changed_line
)
806 if path
.split('/')[0] not in AUTO_GENERATED_DIRS
:
808 results
.add('%s%s' % (path
, m
.group(2)))
810 results
.add('%s/DEPS' % path
)
814 def _CheckAddedDepsHaveTargetApprovals(input_api
, output_api
):
815 """When a dependency prefixed with + is added to a DEPS file, we
816 want to make sure that the change is reviewed by an OWNER of the
817 target file or directory, to avoid layering violations from being
818 introduced. This check verifies that this happens.
820 changed_lines
= set()
821 for f
in input_api
.AffectedFiles():
822 filename
= input_api
.os_path
.basename(f
.LocalPath())
823 if filename
== 'DEPS':
824 changed_lines |
= set(line
.strip()
826 in f
.ChangedContents())
827 if not changed_lines
:
830 virtual_depended_on_files
= _FilesToCheckForIncomingDeps(input_api
.re
,
832 if not virtual_depended_on_files
:
835 if input_api
.is_committing
:
837 return [output_api
.PresubmitNotifyResult(
838 '--tbr was specified, skipping OWNERS check for DEPS additions')]
839 if not input_api
.change
.issue
:
840 return [output_api
.PresubmitError(
841 "DEPS approval by OWNERS check failed: this change has "
842 "no Rietveld issue number, so we can't check it for approvals.")]
843 output
= output_api
.PresubmitError
845 output
= output_api
.PresubmitNotifyResult
847 owners_db
= input_api
.owners_db
848 owner_email
, reviewers
= input_api
.canned_checks
._RietveldOwnerAndReviewers
(
850 owners_db
.email_regexp
,
851 approval_needed
=input_api
.is_committing
)
853 owner_email
= owner_email
or input_api
.change
.author_email
855 reviewers_plus_owner
= set(reviewers
)
857 reviewers_plus_owner
.add(owner_email
)
858 missing_files
= owners_db
.files_not_covered_by(virtual_depended_on_files
,
859 reviewers_plus_owner
)
861 # We strip the /DEPS part that was added by
862 # _FilesToCheckForIncomingDeps to fake a path to a file in a
865 start_deps
= path
.rfind('/DEPS')
867 return path
[:start_deps
]
870 unapproved_dependencies
= ["'+%s'," % StripDeps(path
)
871 for path
in missing_files
]
873 if unapproved_dependencies
:
875 output('Missing LGTM from OWNERS of dependencies added to DEPS:\n %s' %
876 '\n '.join(sorted(unapproved_dependencies
)))]
877 if not input_api
.is_committing
:
878 suggested_owners
= owners_db
.reviewers_for(missing_files
, owner_email
)
879 output_list
.append(output(
880 'Suggested missing target path OWNERS:\n %s' %
881 '\n '.join(suggested_owners
or [])))
887 def _CheckSpamLogging(input_api
, output_api
):
888 file_inclusion_pattern
= r
'.+%s' % _IMPLEMENTATION_EXTENSIONS
889 black_list
= (_EXCLUDED_PATHS
+
890 _TEST_CODE_EXCLUDED_PATHS
+
891 input_api
.DEFAULT_BLACK_LIST
+
892 (r
"^base[\\\/]logging\.h$",
893 r
"^chrome[\\\/]app[\\\/]chrome_main_delegate\.cc$",
894 r
"^chrome[\\\/]browser[\\\/]chrome_browser_main\.cc$",
895 r
"^chrome[\\\/]browser[\\\/]ui[\\\/]startup[\\\/]"
896 r
"startup_browser_creator\.cc$",
897 r
"^chrome[\\\/]installer[\\\/]setup[\\\/].*",
898 r
"^chrome[\\\/]renderer[\\\/]extensions[\\\/]"
899 r
"logging_native_handler\.cc$",
900 r
"^content[\\\/]common[\\\/]gpu[\\\/]client[\\\/]"
901 r
"gl_helper_benchmark\.cc$",
902 r
"^remoting[\\\/]base[\\\/]logging\.h$",
903 r
"^remoting[\\\/]host[\\\/].*",
904 r
"^sandbox[\\\/]linux[\\\/].*",
905 r
"^ui[\\\/]aura[\\\/]bench[\\\/]bench_main\.cc$",))
906 source_file_filter
= lambda x
: input_api
.FilterSourceFile(
907 x
, white_list
=(file_inclusion_pattern
,), black_list
=black_list
)
912 for f
in input_api
.AffectedSourceFiles(source_file_filter
):
913 contents
= input_api
.ReadFile(f
, 'rb')
914 if re
.search(r
"\bD?LOG\s*\(\s*INFO\s*\)", contents
):
915 log_info
.append(f
.LocalPath())
916 elif re
.search(r
"\bD?LOG_IF\s*\(\s*INFO\s*,", contents
):
917 log_info
.append(f
.LocalPath())
919 if re
.search(r
"\bprintf\(", contents
):
920 printf
.append(f
.LocalPath())
921 elif re
.search(r
"\bfprintf\((stdout|stderr)", contents
):
922 printf
.append(f
.LocalPath())
925 return [output_api
.PresubmitError(
926 'These files spam the console log with LOG(INFO):',
929 return [output_api
.PresubmitError(
930 'These files spam the console log with printf/fprintf:',
935 def _CheckForAnonymousVariables(input_api
, output_api
):
936 """These types are all expected to hold locks while in scope and
937 so should never be anonymous (which causes them to be immediately
939 they_who_must_be_named
= [
943 'SkAutoAlphaRestore',
944 'SkAutoBitmapShaderInstall',
945 'SkAutoBlitterChoose',
946 'SkAutoBounderCommit',
948 'SkAutoCanvasRestore',
949 'SkAutoCommentBlock',
951 'SkAutoDisableDirectionCheck',
952 'SkAutoDisableOvalCheck',
959 'SkAutoMaskFreeImage',
960 'SkAutoMutexAcquire',
961 'SkAutoPathBoundsUpdate',
963 'SkAutoRasterClipValidate',
969 anonymous
= r
'(%s)\s*[({]' % '|'.join(they_who_must_be_named
)
970 # bad: base::AutoLock(lock.get());
971 # not bad: base::AutoLock lock(lock.get());
972 bad_pattern
= input_api
.re
.compile(anonymous
)
973 # good: new base::AutoLock(lock.get())
974 good_pattern
= input_api
.re
.compile(r
'\bnew\s*' + anonymous
)
977 for f
in input_api
.AffectedFiles():
978 if not f
.LocalPath().endswith(('.cc', '.h', '.inl', '.m', '.mm')):
980 for linenum
, line
in f
.ChangedContents():
981 if bad_pattern
.search(line
) and not good_pattern
.search(line
):
982 errors
.append('%s:%d' % (f
.LocalPath(), linenum
))
985 return [output_api
.PresubmitError(
986 'These lines create anonymous variables that need to be named:',
991 def _CheckCygwinShell(input_api
, output_api
):
992 source_file_filter
= lambda x
: input_api
.FilterSourceFile(
993 x
, white_list
=(r
'.+\.(gyp|gypi)$',))
996 for f
in input_api
.AffectedSourceFiles(source_file_filter
):
997 for linenum
, line
in f
.ChangedContents():
998 if 'msvs_cygwin_shell' in line
:
999 cygwin_shell
.append(f
.LocalPath())
1003 return [output_api
.PresubmitError(
1004 'These files should not use msvs_cygwin_shell (the default is 0):',
1005 items
=cygwin_shell
)]
1009 def _CheckJavaStyle(input_api
, output_api
):
1010 """Runs checkstyle on changed java files and returns errors if any exist."""
1011 original_sys_path
= sys
.path
1013 sys
.path
= sys
.path
+ [input_api
.os_path
.join(
1014 input_api
.PresubmitLocalPath(), 'tools', 'android', 'checkstyle')]
1017 # Restore sys.path to what it was before.
1018 sys
.path
= original_sys_path
1020 return checkstyle
.RunCheckstyle(
1021 input_api
, output_api
, 'tools/android/checkstyle/chromium-style-5.0.xml')
1024 def _CommonChecks(input_api
, output_api
):
1025 """Checks common to both upload and commit."""
1027 results
.extend(input_api
.canned_checks
.PanProjectChecks(
1028 input_api
, output_api
,
1029 excluded_paths
=_EXCLUDED_PATHS
+ _TESTRUNNER_PATHS
))
1030 results
.extend(_CheckAuthorizedAuthor(input_api
, output_api
))
1032 _CheckNoProductionCodeUsingTestOnlyFunctions(input_api
, output_api
))
1033 results
.extend(_CheckNoIOStreamInHeaders(input_api
, output_api
))
1034 results
.extend(_CheckNoUNIT_TESTInSourceFiles(input_api
, output_api
))
1035 results
.extend(_CheckNoNewWStrings(input_api
, output_api
))
1036 results
.extend(_CheckNoDEPSGIT(input_api
, output_api
))
1037 results
.extend(_CheckNoBannedFunctions(input_api
, output_api
))
1038 results
.extend(_CheckNoPragmaOnce(input_api
, output_api
))
1039 results
.extend(_CheckNoTrinaryTrueFalse(input_api
, output_api
))
1040 results
.extend(_CheckUnwantedDependencies(input_api
, output_api
))
1041 results
.extend(_CheckFilePermissions(input_api
, output_api
))
1042 results
.extend(_CheckNoAuraWindowPropertyHInHeaders(input_api
, output_api
))
1043 results
.extend(_CheckIncludeOrder(input_api
, output_api
))
1044 results
.extend(_CheckForVersionControlConflicts(input_api
, output_api
))
1045 results
.extend(_CheckPatchFiles(input_api
, output_api
))
1046 results
.extend(_CheckHardcodedGoogleHostsInLowerLayers(input_api
, output_api
))
1047 results
.extend(_CheckNoAbbreviationInPngFileName(input_api
, output_api
))
1048 results
.extend(_CheckForInvalidOSMacros(input_api
, output_api
))
1049 results
.extend(_CheckAddedDepsHaveTargetApprovals(input_api
, output_api
))
1051 input_api
.canned_checks
.CheckChangeHasNoTabs(
1054 source_file_filter
=lambda x
: x
.LocalPath().endswith('.grd')))
1055 results
.extend(_CheckSpamLogging(input_api
, output_api
))
1056 results
.extend(_CheckForAnonymousVariables(input_api
, output_api
))
1057 results
.extend(_CheckCygwinShell(input_api
, output_api
))
1058 results
.extend(_CheckJavaStyle(input_api
, output_api
))
1060 if any('PRESUBMIT.py' == f
.LocalPath() for f
in input_api
.AffectedFiles()):
1061 results
.extend(input_api
.canned_checks
.RunUnitTestsInDirectory(
1062 input_api
, output_api
,
1063 input_api
.PresubmitLocalPath(),
1064 whitelist
=[r
'^PRESUBMIT_test\.py$']))
1068 def _CheckSubversionConfig(input_api
, output_api
):
1069 """Verifies the subversion config file is correctly setup.
1071 Checks that autoprops are enabled, returns an error otherwise.
1073 join
= input_api
.os_path
.join
1074 if input_api
.platform
== 'win32':
1075 appdata
= input_api
.environ
.get('APPDATA', '')
1077 return [output_api
.PresubmitError('%APPDATA% is not configured.')]
1078 path
= join(appdata
, 'Subversion', 'config')
1080 home
= input_api
.environ
.get('HOME', '')
1082 return [output_api
.PresubmitError('$HOME is not configured.')]
1083 path
= join(home
, '.subversion', 'config')
1086 'Please look at http://dev.chromium.org/developers/coding-style to\n'
1087 'configure your subversion configuration file. This enables automatic\n'
1088 'properties to simplify the project maintenance.\n'
1089 'Pro-tip: just download and install\n'
1090 'http://src.chromium.org/viewvc/chrome/trunk/tools/build/slave/config\n')
1093 lines
= open(path
, 'r').read().splitlines()
1094 # Make sure auto-props is enabled and check for 2 Chromium standard
1096 if (not '*.cc = svn:eol-style=LF' in lines
or
1097 not '*.pdf = svn:mime-type=application/pdf' in lines
or
1098 not 'enable-auto-props = yes' in lines
):
1100 output_api
.PresubmitNotifyResult(
1101 'It looks like you have not configured your subversion config '
1102 'file or it is not up-to-date.\n' + error_msg
)
1104 except (OSError, IOError):
1106 output_api
.PresubmitNotifyResult(
1107 'Can\'t find your subversion config file.\n' + error_msg
)
1112 def _CheckAuthorizedAuthor(input_api
, output_api
):
1113 """For non-googler/chromites committers, verify the author's email address is
1116 # TODO(maruel): Add it to input_api?
1119 author
= input_api
.change
.author_email
1121 input_api
.logging
.info('No author, skipping AUTHOR check')
1123 authors_path
= input_api
.os_path
.join(
1124 input_api
.PresubmitLocalPath(), 'AUTHORS')
1126 input_api
.re
.match(r
'[^#]+\s+\<(.+?)\>\s*$', line
)
1127 for line
in open(authors_path
))
1128 valid_authors
= [item
.group(1).lower() for item
in valid_authors
if item
]
1129 if not any(fnmatch
.fnmatch(author
.lower(), valid
) for valid
in valid_authors
):
1130 input_api
.logging
.info('Valid authors are %s', ', '.join(valid_authors
))
1131 return [output_api
.PresubmitPromptWarning(
1132 ('%s is not in AUTHORS file. If you are a new contributor, please visit'
1134 'http://www.chromium.org/developers/contributing-code and read the '
1136 'If you are a chromite, verify the contributor signed the CLA.') %
1141 def _CheckPatchFiles(input_api
, output_api
):
1142 problems
= [f
.LocalPath() for f
in input_api
.AffectedFiles()
1143 if f
.LocalPath().endswith(('.orig', '.rej'))]
1145 return [output_api
.PresubmitError(
1146 "Don't commit .rej and .orig files.", problems
)]
1151 def _DidYouMeanOSMacro(bad_macro
):
1153 return {'A': 'OS_ANDROID',
1163 'W': 'OS_WIN'}[bad_macro
[3].upper()]
1168 def _CheckForInvalidOSMacrosInFile(input_api
, f
):
1169 """Check for sensible looking, totally invalid OS macros."""
1170 preprocessor_statement
= input_api
.re
.compile(r
'^\s*#')
1171 os_macro
= input_api
.re
.compile(r
'defined\((OS_[^)]+)\)')
1173 for lnum
, line
in f
.ChangedContents():
1174 if preprocessor_statement
.search(line
):
1175 for match
in os_macro
.finditer(line
):
1176 if not match
.group(1) in _VALID_OS_MACROS
:
1177 good
= _DidYouMeanOSMacro(match
.group(1))
1178 did_you_mean
= ' (did you mean %s?)' % good
if good
else ''
1179 results
.append(' %s:%d %s%s' % (f
.LocalPath(),
1186 def _CheckForInvalidOSMacros(input_api
, output_api
):
1187 """Check all affected files for invalid OS macros."""
1189 for f
in input_api
.AffectedFiles():
1190 if not f
.LocalPath().endswith(('.py', '.js', '.html', '.css')):
1191 bad_macros
.extend(_CheckForInvalidOSMacrosInFile(input_api
, f
))
1196 return [output_api
.PresubmitError(
1197 'Possibly invalid OS macro[s] found. Please fix your code\n'
1198 'or add your macro to src/PRESUBMIT.py.', bad_macros
)]
1201 def CheckChangeOnUpload(input_api
, output_api
):
1203 results
.extend(_CommonChecks(input_api
, output_api
))
1207 def GetDefaultTryConfigs(bots
=None):
1208 """Returns a list of ('bot', set(['tests']), optionally filtered by [bots].
1210 To add tests to this list, they MUST be in the the corresponding master's
1211 gatekeeper config. For example, anything on master.chromium would be closed by
1212 tools/build/masters/master.chromium/master_gatekeeper_cfg.py.
1214 If 'bots' is specified, will only return configurations for bots in that list.
1220 'cacheinvalidation_unittests',
1223 'content_browsertests',
1224 'content_unittests',
1228 'interactive_ui_tests',
1234 'printing_unittests',
1238 # Broken in release.
1240 #'webkit_unit_tests',
1243 linux_aura_tests
= [
1244 'app_list_unittests',
1247 'compositor_unittests',
1248 'content_browsertests',
1249 'content_unittests',
1251 'interactive_ui_tests',
1254 builders_and_tests
= {
1255 # TODO(maruel): Figure out a way to run 'sizes' where people can
1256 # effectively update the perf expectation correctly. This requires a
1257 # clobber=True build running 'sizes'. 'sizes' is not accurate with
1258 # incremental build. Reference:
1259 # http://chromium.org/developers/tree-sheriffs/perf-sheriffs.
1260 # TODO(maruel): An option would be to run 'sizes' but not count a failure
1261 # of this step as a try job failure.
1262 'android_aosp': ['compile'],
1263 'android_clang_dbg': ['slave_steps'],
1264 'android_dbg': ['slave_steps'],
1265 'cros_x86': ['defaulttests'],
1266 'ios_dbg_simulator': [
1269 'content_unittests',
1276 'ios_rel_device': ['compile'],
1277 'linux_asan': ['defaulttests'],
1278 #TODO(stip): Change the name of this builder to reflect that it's release.
1279 'linux_aura': linux_aura_tests
,
1280 'linux_chromeos_asan': ['defaulttests'],
1281 'linux_chromeos_clang': ['compile'],
1282 # Note: It is a Release builder even if its name convey otherwise.
1283 'linux_chromeos': standard_tests
+ [
1284 'app_list_unittests',
1287 'chromeos_unittests',
1288 'components_unittests',
1292 'google_apis_unittests',
1293 'sandbox_linux_unittests',
1295 'linux_chromium_dbg': ['defaulttests'],
1296 'linux_chromium_rel': ['defaulttests'],
1297 'linux_clang': ['compile'],
1298 'linux_nacl_sdk_build': ['compile'],
1299 'linux_rel': standard_tests
+ [
1301 'chromedriver_unittests',
1302 'components_unittests',
1303 'google_apis_unittests',
1305 'remoting_unittests',
1306 'sandbox_linux_unittests',
1307 'sync_integration_tests',
1310 'mac_chromium_dbg': ['defaulttests'],
1311 'mac_chromium_rel': ['defaulttests'],
1312 'mac_nacl_sdk_build': ['compile'],
1313 'mac_rel': standard_tests
+ [
1314 'app_list_unittests',
1316 'chromedriver_unittests',
1317 'components_unittests',
1318 'google_apis_unittests',
1319 'message_center_unittests',
1321 'remoting_unittests',
1322 'sync_integration_tests',
1323 'telemetry_unittests',
1326 'win_nacl_sdk_build': ['compile'],
1327 'win_rel': standard_tests
+ [
1328 'app_list_unittests',
1332 'chrome_elf_unittests',
1333 'chromedriver_unittests',
1334 'components_unittests',
1335 'compositor_unittests',
1337 'google_apis_unittests',
1338 'installer_util_unittests',
1339 'mini_installer_test',
1341 'remoting_unittests',
1342 'sync_integration_tests',
1343 'telemetry_unittests',
1351 swarm_enabled_builders
= (
1357 swarm_enabled_tests
= (
1360 'interactive_ui_tests',
1365 for bot
in builders_and_tests
:
1366 if bot
in swarm_enabled_builders
:
1367 builders_and_tests
[bot
] = [x
+ '_swarm' if x
in swarm_enabled_tests
else x
1368 for x
in builders_and_tests
[bot
]]
1371 return [(bot
, set(builders_and_tests
[bot
])) for bot
in bots
]
1373 return [(bot
, set(tests
)) for bot
, tests
in builders_and_tests
.iteritems()]
1376 def CheckChangeOnCommit(input_api
, output_api
):
1378 results
.extend(_CommonChecks(input_api
, output_api
))
1379 # TODO(thestig) temporarily disabled, doesn't work in third_party/
1380 #results.extend(input_api.canned_checks.CheckSvnModifiedDirectories(
1381 # input_api, output_api, sources))
1382 # Make sure the tree is 'open'.
1383 results
.extend(input_api
.canned_checks
.CheckTreeIsOpen(
1386 json_url
='http://chromium-status.appspot.com/current?format=json'))
1387 results
.extend(input_api
.canned_checks
.CheckRietveldTryJobExecution(input_api
,
1388 output_api
, 'http://codereview.chromium.org',
1389 ('win_rel', 'linux_rel', 'mac_rel, win:compile'),
1390 'tryserver@chromium.org'))
1392 results
.extend(input_api
.canned_checks
.CheckChangeHasBugField(
1393 input_api
, output_api
))
1394 results
.extend(input_api
.canned_checks
.CheckChangeHasDescription(
1395 input_api
, output_api
))
1396 results
.extend(_CheckSubversionConfig(input_api
, output_api
))
1400 def GetPreferredTrySlaves(project
, change
):
1401 files
= change
.LocalPaths()
1403 if not files
or all(re
.search(r
'[\\/]OWNERS$', f
) for f
in files
):
1406 if all(re
.search('\.(m|mm)$|(^|[/_])mac[/_.]', f
) for f
in files
):
1407 return GetDefaultTryConfigs(['mac', 'mac_rel'])
1408 if all(re
.search('(^|[/_])win[/_.]', f
) for f
in files
):
1409 return GetDefaultTryConfigs(['win', 'win_rel'])
1410 if all(re
.search('(^|[/_])android[/_.]', f
) for f
in files
):
1411 return GetDefaultTryConfigs([
1413 'android_clang_dbg',
1416 if all(re
.search('[/_]ios[/_.]', f
) for f
in files
):
1417 return GetDefaultTryConfigs(['ios_rel_device', 'ios_dbg_simulator'])
1419 trybots
= GetDefaultTryConfigs([
1420 'android_clang_dbg',
1422 'ios_dbg_simulator',
1428 'linux_nacl_sdk_build',
1431 'mac_nacl_sdk_build',
1434 'win_nacl_sdk_build',
1439 # Match things like path/aura/file.cc and path/file_aura.cc.
1440 # Same for chromeos.
1441 if any(re
.search('[/_](aura|chromeos)', f
) for f
in files
):
1442 trybots
.extend(GetDefaultTryConfigs([
1443 'linux_chromeos_asan', 'linux_chromeos_clang']))
1445 # If there are gyp changes to base, build, or chromeos, run a full cros build
1446 # in addition to the shorter linux_chromeos build. Changes to high level gyp
1447 # files have a much higher chance of breaking the cros build, which is
1448 # differnt from the linux_chromeos build that most chrome developers test
1450 if any(re
.search('^(base|build|chromeos).*\.gypi?$', f
) for f
in files
):
1451 trybots
.extend(GetDefaultTryConfigs(['cros_x86']))
1453 # The AOSP bot doesn't build the chrome/ layer, so ignore any changes to it
1454 # unless they're .gyp(i) files as changes to those files can break the gyp
1456 if (not all(re
.search('^chrome', f
) for f
in files
) or
1457 any(re
.search('\.gypi?$', f
) for f
in files
)):
1458 trybots
.extend(GetDefaultTryConfigs(['android_aosp']))
1460 # Experimental recipe-based Chromium trybots. To avoid possible capacity
1461 # problems, only enable for a small percentage of try runs.
1462 if random
.random() < 0.25:
1463 trybots
.extend(GetDefaultTryConfigs([
1464 'linux_chromium_dbg',
1465 'linux_chromium_rel',