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.
19 r
"^native_client_sdk[\\\/]src[\\\/]build_tools[\\\/]make_rules.py",
20 r
"^native_client_sdk[\\\/]src[\\\/]build_tools[\\\/]make_simple.py",
21 r
"^native_client_sdk[\\\/]src[\\\/]tools[\\\/].*.mk",
22 r
"^net[\\\/]tools[\\\/]spdyshark[\\\/].*",
27 r
".+[\\\/]pnacl_shim\.c$",
28 r
"^gpu[\\\/]config[\\\/].*_list_json\.cc$",
31 # TestRunner library is temporarily excluded from pan-project checks until
32 # it's transitioned to chromium coding style.
34 r
"^content[\\\/]shell[\\\/]renderer[\\\/]test_runner[\\\/].*",
35 r
"^content[\\\/]shell[\\\/]common[\\\/]test_runner[\\\/].*",
38 # Fragment of a regular expression that matches C++ and Objective-C++
39 # implementation files.
40 _IMPLEMENTATION_EXTENSIONS
= r
'\.(cc|cpp|cxx|mm)$'
42 # Regular expression that matches code only used for test binaries
44 _TEST_CODE_EXCLUDED_PATHS
= (
45 r
'.*[/\\](fake_|test_|mock_).+%s' % _IMPLEMENTATION_EXTENSIONS
,
46 r
'.+_test_(base|support|util)%s' % _IMPLEMENTATION_EXTENSIONS
,
47 r
'.+_(api|browser|perf|pixel|unit|ui)?test(_[a-z]+)?%s' %
48 _IMPLEMENTATION_EXTENSIONS
,
49 r
'.+profile_sync_service_harness%s' % _IMPLEMENTATION_EXTENSIONS
,
50 r
'.*[/\\](test|tool(s)?)[/\\].*',
51 # content_shell is used for running layout tests.
52 r
'content[/\\]shell[/\\].*',
53 # At request of folks maintaining this folder.
54 r
'chrome[/\\]browser[/\\]automation[/\\].*',
55 # Non-production example code.
56 r
'mojo[/\\]examples[/\\].*',
59 _TEST_ONLY_WARNING
= (
60 'You might be calling functions intended only for testing from\n'
61 'production code. It is OK to ignore this warning if you know what\n'
62 'you are doing, as the heuristics used to detect the situation are\n'
63 'not perfect. The commit queue will not block on this warning.\n'
64 'Email joi@chromium.org if you have questions.')
67 _INCLUDE_ORDER_WARNING
= (
68 'Your #include order seems to be broken. Send mail to\n'
69 'marja@chromium.org if this is not the case.')
72 _BANNED_OBJC_FUNCTIONS
= (
76 'The use of -[NSView addTrackingRect:owner:userData:assumeInside:] is'
77 'prohibited. Please use CrTrackingArea instead.',
78 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
85 'The use of NSTrackingAreas is prohibited. Please use CrTrackingArea',
87 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
92 'convertPointFromBase:',
94 'The use of -[NSView convertPointFromBase:] is almost certainly wrong.',
95 'Please use |convertPoint:(point) fromView:nil| instead.',
96 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
101 'convertPointToBase:',
103 'The use of -[NSView convertPointToBase:] is almost certainly wrong.',
104 'Please use |convertPoint:(point) toView:nil| instead.',
105 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
110 'convertRectFromBase:',
112 'The use of -[NSView convertRectFromBase:] is almost certainly wrong.',
113 'Please use |convertRect:(point) fromView:nil| instead.',
114 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
119 'convertRectToBase:',
121 'The use of -[NSView convertRectToBase:] is almost certainly wrong.',
122 'Please use |convertRect:(point) toView:nil| instead.',
123 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
128 'convertSizeFromBase:',
130 'The use of -[NSView convertSizeFromBase:] is almost certainly wrong.',
131 'Please use |convertSize:(point) fromView:nil| instead.',
132 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
137 'convertSizeToBase:',
139 'The use of -[NSView convertSizeToBase:] is almost certainly wrong.',
140 'Please use |convertSize:(point) toView:nil| instead.',
141 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
148 _BANNED_CPP_FUNCTIONS
= (
149 # Make sure that gtest's FRIEND_TEST() macro is not used; the
150 # FRIEND_TEST_ALL_PREFIXES() macro from base/gtest_prod_util.h should be
151 # used instead since that allows for FLAKY_ and DISABLED_ prefixes.
155 'Chromium code should not use gtest\'s FRIEND_TEST() macro. Include',
156 'base/gtest_prod_util.h and use FRIEND_TEST_ALL_PREFIXES() instead.',
164 'New code should not use ScopedAllowIO. Post a task to the blocking',
165 'pool or the FILE thread instead.',
169 r
"^components[\\\/]breakpad[\\\/]app[\\\/]breakpad_mac\.mm$",
170 r
"^content[\\\/]shell[\\\/]browser[\\\/]shell_browser_main\.cc$",
171 r
"^content[\\\/]shell[\\\/]browser[\\\/]shell_message_filter\.cc$",
172 r
"^net[\\\/]disk_cache[\\\/]cache_util\.cc$",
178 'The use of SkRefPtr is prohibited. ',
179 'Please use skia::RefPtr instead.'
187 'The indirect use of SkRefPtr via SkAutoRef is prohibited. ',
188 'Please use skia::RefPtr instead.'
196 'The use of SkAutoTUnref is dangerous because it implicitly ',
197 'converts to a raw pointer. Please use skia::RefPtr instead.'
205 'The indirect use of SkAutoTUnref through SkAutoUnref is dangerous ',
206 'because it implicitly converts to a raw pointer. ',
207 'Please use skia::RefPtr instead.'
213 r
'/HANDLE_EINTR\(.*close',
215 'HANDLE_EINTR(close) is invalid. If close fails with EINTR, the file',
216 'descriptor will be closed, and it is incorrect to retry the close.',
217 'Either call close directly and ignore its return value, or wrap close',
218 'in IGNORE_EINTR to use its return value. See http://crbug.com/269623'
224 r
'/IGNORE_EINTR\((?!.*close)',
226 'IGNORE_EINTR is only valid when wrapping close. To wrap other system',
227 'calls, use HANDLE_EINTR. See http://crbug.com/269623',
231 # Files that #define IGNORE_EINTR.
232 r
'^base[\\\/]posix[\\\/]eintr_wrapper\.h$',
233 r
'^ppapi[\\\/]tests[\\\/]test_broker\.cc$',
240 # Please keep sorted.
243 'OS_CAT', # For testing.
257 def _CheckNoProductionCodeUsingTestOnlyFunctions(input_api
, output_api
):
258 """Attempts to prevent use of functions intended only for testing in
259 non-testing code. For now this is just a best-effort implementation
260 that ignores header files and may have some false positives. A
261 better implementation would probably need a proper C++ parser.
263 # We only scan .cc files and the like, as the declaration of
264 # for-testing functions in header files are hard to distinguish from
265 # calls to such functions without a proper C++ parser.
266 file_inclusion_pattern
= r
'.+%s' % _IMPLEMENTATION_EXTENSIONS
268 base_function_pattern
= r
'ForTest(ing)?|for_test(ing)?'
269 inclusion_pattern
= input_api
.re
.compile(r
'(%s)\s*\(' % base_function_pattern
)
270 comment_pattern
= input_api
.re
.compile(r
'//.*%s' % base_function_pattern
)
271 exclusion_pattern
= input_api
.re
.compile(
272 r
'::[A-Za-z0-9_]+(%s)|(%s)[^;]+\{' % (
273 base_function_pattern
, base_function_pattern
))
275 def FilterFile(affected_file
):
276 black_list
= (_EXCLUDED_PATHS
+
277 _TEST_CODE_EXCLUDED_PATHS
+
278 input_api
.DEFAULT_BLACK_LIST
)
279 return input_api
.FilterSourceFile(
281 white_list
=(file_inclusion_pattern
, ),
282 black_list
=black_list
)
285 for f
in input_api
.AffectedSourceFiles(FilterFile
):
286 local_path
= f
.LocalPath()
287 lines
= input_api
.ReadFile(f
).splitlines()
290 if (inclusion_pattern
.search(line
) and
291 not comment_pattern
.search(line
) and
292 not exclusion_pattern
.search(line
)):
294 '%s:%d\n %s' % (local_path
, line_number
, line
.strip()))
298 return [output_api
.PresubmitPromptOrNotify(_TEST_ONLY_WARNING
, problems
)]
303 def _CheckNoIOStreamInHeaders(input_api
, output_api
):
304 """Checks to make sure no .h files include <iostream>."""
306 pattern
= input_api
.re
.compile(r
'^#include\s*<iostream>',
307 input_api
.re
.MULTILINE
)
308 for f
in input_api
.AffectedSourceFiles(input_api
.FilterSourceFile
):
309 if not f
.LocalPath().endswith('.h'):
311 contents
= input_api
.ReadFile(f
)
312 if pattern
.search(contents
):
316 return [ output_api
.PresubmitError(
317 'Do not #include <iostream> in header files, since it inserts static '
318 'initialization into every file including the header. Instead, '
319 '#include <ostream>. See http://crbug.com/94794',
324 def _CheckNoUNIT_TESTInSourceFiles(input_api
, output_api
):
325 """Checks to make sure no source files use UNIT_TEST"""
327 for f
in input_api
.AffectedFiles():
328 if (not f
.LocalPath().endswith(('.cc', '.mm'))):
331 for line_num
, line
in f
.ChangedContents():
332 if 'UNIT_TEST ' in line
or line
.endswith('UNIT_TEST'):
333 problems
.append(' %s:%d' % (f
.LocalPath(), line_num
))
337 return [output_api
.PresubmitPromptWarning('UNIT_TEST is only for headers.\n' +
338 '\n'.join(problems
))]
341 def _CheckNoNewWStrings(input_api
, output_api
):
342 """Checks to make sure we don't introduce use of wstrings."""
344 for f
in input_api
.AffectedFiles():
345 if (not f
.LocalPath().endswith(('.cc', '.h')) or
346 f
.LocalPath().endswith(('test.cc', '_win.cc', '_win.h'))):
350 for line_num
, line
in f
.ChangedContents():
351 if 'presubmit: allow wstring' in line
:
353 elif not allowWString
and 'wstring' in line
:
354 problems
.append(' %s:%d' % (f
.LocalPath(), line_num
))
361 return [output_api
.PresubmitPromptWarning('New code should not use wstrings.'
362 ' If you are calling a cross-platform API that accepts a wstring, '
364 '\n'.join(problems
))]
367 def _CheckNoDEPSGIT(input_api
, output_api
):
368 """Make sure .DEPS.git is never modified manually."""
369 if any(f
.LocalPath().endswith('.DEPS.git') for f
in
370 input_api
.AffectedFiles()):
371 return [output_api
.PresubmitError(
372 'Never commit changes to .DEPS.git. This file is maintained by an\n'
373 'automated system based on what\'s in DEPS and your changes will be\n'
375 'See http://code.google.com/p/chromium/wiki/UsingNewGit#Rolling_DEPS\n'
376 'for more information')]
380 def _CheckNoBannedFunctions(input_api
, output_api
):
381 """Make sure that banned functions are not used."""
385 file_filter
= lambda f
: f
.LocalPath().endswith(('.mm', '.m', '.h'))
386 for f
in input_api
.AffectedFiles(file_filter
=file_filter
):
387 for line_num
, line
in f
.ChangedContents():
388 for func_name
, message
, error
in _BANNED_OBJC_FUNCTIONS
:
389 if func_name
in line
:
393 problems
.append(' %s:%d:' % (f
.LocalPath(), line_num
))
394 for message_line
in message
:
395 problems
.append(' %s' % message_line
)
397 file_filter
= lambda f
: f
.LocalPath().endswith(('.cc', '.mm', '.h'))
398 for f
in input_api
.AffectedFiles(file_filter
=file_filter
):
399 for line_num
, line
in f
.ChangedContents():
400 for func_name
, message
, error
, excluded_paths
in _BANNED_CPP_FUNCTIONS
:
401 def IsBlacklisted(affected_file
, blacklist
):
402 local_path
= affected_file
.LocalPath()
403 for item
in blacklist
:
404 if input_api
.re
.match(item
, local_path
):
407 if IsBlacklisted(f
, excluded_paths
):
410 if func_name
[0:1] == '/':
411 regex
= func_name
[1:]
412 if input_api
.re
.search(regex
, line
):
414 elif func_name
in line
:
420 problems
.append(' %s:%d:' % (f
.LocalPath(), line_num
))
421 for message_line
in message
:
422 problems
.append(' %s' % message_line
)
426 result
.append(output_api
.PresubmitPromptWarning(
427 'Banned functions were used.\n' + '\n'.join(warnings
)))
429 result
.append(output_api
.PresubmitError(
430 'Banned functions were used.\n' + '\n'.join(errors
)))
434 def _CheckNoPragmaOnce(input_api
, output_api
):
435 """Make sure that banned functions are not used."""
437 pattern
= input_api
.re
.compile(r
'^#pragma\s+once',
438 input_api
.re
.MULTILINE
)
439 for f
in input_api
.AffectedSourceFiles(input_api
.FilterSourceFile
):
440 if not f
.LocalPath().endswith('.h'):
442 contents
= input_api
.ReadFile(f
)
443 if pattern
.search(contents
):
447 return [output_api
.PresubmitError(
448 'Do not use #pragma once in header files.\n'
449 'See http://www.chromium.org/developers/coding-style#TOC-File-headers',
454 def _CheckNoTrinaryTrueFalse(input_api
, output_api
):
455 """Checks to make sure we don't introduce use of foo ? true : false."""
457 pattern
= input_api
.re
.compile(r
'\?\s*(true|false)\s*:\s*(true|false)')
458 for f
in input_api
.AffectedFiles():
459 if not f
.LocalPath().endswith(('.cc', '.h', '.inl', '.m', '.mm')):
462 for line_num
, line
in f
.ChangedContents():
463 if pattern
.match(line
):
464 problems
.append(' %s:%d' % (f
.LocalPath(), line_num
))
468 return [output_api
.PresubmitPromptWarning(
469 'Please consider avoiding the "? true : false" pattern if possible.\n' +
470 '\n'.join(problems
))]
473 def _CheckUnwantedDependencies(input_api
, output_api
):
474 """Runs checkdeps on #include statements added in this
475 change. Breaking - rules is an error, breaking ! rules is a
478 # We need to wait until we have an input_api object and use this
479 # roundabout construct to import checkdeps because this file is
480 # eval-ed and thus doesn't have __file__.
481 original_sys_path
= sys
.path
483 sys
.path
= sys
.path
+ [input_api
.os_path
.join(
484 input_api
.PresubmitLocalPath(), 'tools', 'checkdeps')]
486 from cpp_checker
import CppChecker
487 from rules
import Rule
489 # Restore sys.path to what it was before.
490 sys
.path
= original_sys_path
493 for f
in input_api
.AffectedFiles():
494 if not CppChecker
.IsCppFile(f
.LocalPath()):
497 changed_lines
= [line
for line_num
, line
in f
.ChangedContents()]
498 added_includes
.append([f
.LocalPath(), changed_lines
])
500 deps_checker
= checkdeps
.DepsChecker(input_api
.PresubmitLocalPath())
502 error_descriptions
= []
503 warning_descriptions
= []
504 for path
, rule_type
, rule_description
in deps_checker
.CheckAddedCppIncludes(
506 description_with_path
= '%s\n %s' % (path
, rule_description
)
507 if rule_type
== Rule
.DISALLOW
:
508 error_descriptions
.append(description_with_path
)
510 warning_descriptions
.append(description_with_path
)
513 if error_descriptions
:
514 results
.append(output_api
.PresubmitError(
515 'You added one or more #includes that violate checkdeps rules.',
517 if warning_descriptions
:
518 results
.append(output_api
.PresubmitPromptOrNotify(
519 'You added one or more #includes of files that are temporarily\n'
520 'allowed but being removed. Can you avoid introducing the\n'
521 '#include? See relevant DEPS file(s) for details and contacts.',
522 warning_descriptions
))
526 def _CheckFilePermissions(input_api
, output_api
):
527 """Check that all files have their permissions properly set."""
528 args
= [sys
.executable
, 'tools/checkperms/checkperms.py', '--root',
529 input_api
.change
.RepositoryRoot()]
530 for f
in input_api
.AffectedFiles():
531 args
+= ['--file', f
.LocalPath()]
533 (errors
, stderrdata
) = subprocess
.Popen(args
).communicate()
537 results
.append(output_api
.PresubmitError('checkperms.py failed.',
542 def _CheckNoAuraWindowPropertyHInHeaders(input_api
, output_api
):
543 """Makes sure we don't include ui/aura/window_property.h
546 pattern
= input_api
.re
.compile(r
'^#include\s*"ui/aura/window_property.h"')
548 for f
in input_api
.AffectedFiles():
549 if not f
.LocalPath().endswith('.h'):
551 for line_num
, line
in f
.ChangedContents():
552 if pattern
.match(line
):
553 errors
.append(' %s:%d' % (f
.LocalPath(), line_num
))
557 results
.append(output_api
.PresubmitError(
558 'Header files should not include ui/aura/window_property.h', errors
))
562 def _CheckIncludeOrderForScope(scope
, input_api
, file_path
, changed_linenums
):
563 """Checks that the lines in scope occur in the right order.
565 1. C system files in alphabetical order
566 2. C++ system files in alphabetical order
567 3. Project's .h files
570 c_system_include_pattern
= input_api
.re
.compile(r
'\s*#include <.*\.h>')
571 cpp_system_include_pattern
= input_api
.re
.compile(r
'\s*#include <.*>')
572 custom_include_pattern
= input_api
.re
.compile(r
'\s*#include ".*')
574 C_SYSTEM_INCLUDES
, CPP_SYSTEM_INCLUDES
, CUSTOM_INCLUDES
= range(3)
576 state
= C_SYSTEM_INCLUDES
579 previous_line_num
= 0
580 problem_linenums
= []
581 for line_num
, line
in scope
:
582 if c_system_include_pattern
.match(line
):
583 if state
!= C_SYSTEM_INCLUDES
:
584 problem_linenums
.append((line_num
, previous_line_num
))
585 elif previous_line
and previous_line
> line
:
586 problem_linenums
.append((line_num
, previous_line_num
))
587 elif cpp_system_include_pattern
.match(line
):
588 if state
== C_SYSTEM_INCLUDES
:
589 state
= CPP_SYSTEM_INCLUDES
590 elif state
== CUSTOM_INCLUDES
:
591 problem_linenums
.append((line_num
, previous_line_num
))
592 elif previous_line
and previous_line
> line
:
593 problem_linenums
.append((line_num
, previous_line_num
))
594 elif custom_include_pattern
.match(line
):
595 if state
!= CUSTOM_INCLUDES
:
596 state
= CUSTOM_INCLUDES
597 elif previous_line
and previous_line
> line
:
598 problem_linenums
.append((line_num
, previous_line_num
))
600 problem_linenums
.append(line_num
)
602 previous_line_num
= line_num
605 for (line_num
, previous_line_num
) in problem_linenums
:
606 if line_num
in changed_linenums
or previous_line_num
in changed_linenums
:
607 warnings
.append(' %s:%d' % (file_path
, line_num
))
611 def _CheckIncludeOrderInFile(input_api
, f
, changed_linenums
):
612 """Checks the #include order for the given file f."""
614 system_include_pattern
= input_api
.re
.compile(r
'\s*#include \<.*')
615 # Exclude the following includes from the check:
616 # 1) #include <.../...>, e.g., <sys/...> includes often need to appear in a
618 # 2) <atlbase.h>, "build/build_config.h"
619 excluded_include_pattern
= input_api
.re
.compile(
620 r
'\s*#include (\<.*/.*|\<atlbase\.h\>|"build/build_config.h")')
621 custom_include_pattern
= input_api
.re
.compile(r
'\s*#include "(?P<FILE>.*)"')
622 # Match the final or penultimate token if it is xxxtest so we can ignore it
623 # when considering the special first include.
624 test_file_tag_pattern
= input_api
.re
.compile(
625 r
'_[a-z]+test(?=(_[a-zA-Z0-9]+)?\.)')
626 if_pattern
= input_api
.re
.compile(
627 r
'\s*#\s*(if|elif|else|endif|define|undef).*')
628 # Some files need specialized order of includes; exclude such files from this
630 uncheckable_includes_pattern
= input_api
.re
.compile(
632 '("ipc/.*macros\.h"|<windows\.h>|".*gl.*autogen.h")\s*')
634 contents
= f
.NewContents()
638 # Handle the special first include. If the first include file is
639 # some/path/file.h, the corresponding including file can be some/path/file.cc,
640 # some/other/path/file.cc, some/path/file_platform.cc, some/path/file-suffix.h
641 # etc. It's also possible that no special first include exists.
642 # If the included file is some/path/file_platform.h the including file could
643 # also be some/path/file_xxxtest_platform.h.
644 including_file_base_name
= test_file_tag_pattern
.sub(
645 '', input_api
.os_path
.basename(f
.LocalPath()))
647 for line
in contents
:
649 if system_include_pattern
.match(line
):
650 # No special first include -> process the line again along with normal
654 match
= custom_include_pattern
.match(line
)
656 match_dict
= match
.groupdict()
657 header_basename
= test_file_tag_pattern
.sub(
658 '', input_api
.os_path
.basename(match_dict
['FILE'])).replace('.h', '')
660 if header_basename
not in including_file_base_name
:
661 # No special first include -> process the line again along with normal
666 # Split into scopes: Each region between #if and #endif is its own scope.
669 for line
in contents
[line_num
:]:
671 if uncheckable_includes_pattern
.match(line
):
673 if if_pattern
.match(line
):
674 scopes
.append(current_scope
)
676 elif ((system_include_pattern
.match(line
) or
677 custom_include_pattern
.match(line
)) and
678 not excluded_include_pattern
.match(line
)):
679 current_scope
.append((line_num
, line
))
680 scopes
.append(current_scope
)
683 warnings
.extend(_CheckIncludeOrderForScope(scope
, input_api
, f
.LocalPath(),
688 def _CheckIncludeOrder(input_api
, output_api
):
689 """Checks that the #include order is correct.
691 1. The corresponding header for source files.
692 2. C system files in alphabetical order
693 3. C++ system files in alphabetical order
694 4. Project's .h files in alphabetical order
696 Each region separated by #if, #elif, #else, #endif, #define and #undef follows
697 these rules separately.
701 for f
in input_api
.AffectedFiles():
702 if f
.LocalPath().endswith(('.cc', '.h')):
703 changed_linenums
= set(line_num
for line_num
, _
in f
.ChangedContents())
704 warnings
.extend(_CheckIncludeOrderInFile(input_api
, f
, changed_linenums
))
708 results
.append(output_api
.PresubmitPromptOrNotify(_INCLUDE_ORDER_WARNING
,
713 def _CheckForVersionControlConflictsInFile(input_api
, f
):
714 pattern
= input_api
.re
.compile('^(?:<<<<<<<|>>>>>>>) |^=======$')
716 for line_num
, line
in f
.ChangedContents():
717 if pattern
.match(line
):
718 errors
.append(' %s:%d %s' % (f
.LocalPath(), line_num
, line
))
722 def _CheckForVersionControlConflicts(input_api
, output_api
):
723 """Usually this is not intentional and will cause a compile failure."""
725 for f
in input_api
.AffectedFiles():
726 errors
.extend(_CheckForVersionControlConflictsInFile(input_api
, f
))
730 results
.append(output_api
.PresubmitError(
731 'Version control conflict markers found, please resolve.', errors
))
735 def _CheckHardcodedGoogleHostsInLowerLayers(input_api
, output_api
):
736 def FilterFile(affected_file
):
737 """Filter function for use with input_api.AffectedSourceFiles,
738 below. This filters out everything except non-test files from
739 top-level directories that generally speaking should not hard-code
740 service URLs (e.g. src/android_webview/, src/content/ and others).
742 return input_api
.FilterSourceFile(
744 white_list
=(r
'^(android_webview|base|content|net)[\\\/].*', ),
745 black_list
=(_EXCLUDED_PATHS
+
746 _TEST_CODE_EXCLUDED_PATHS
+
747 input_api
.DEFAULT_BLACK_LIST
))
749 base_pattern
= '"[^"]*google\.com[^"]*"'
750 comment_pattern
= input_api
.re
.compile('//.*%s' % base_pattern
)
751 pattern
= input_api
.re
.compile(base_pattern
)
752 problems
= [] # items are (filename, line_number, line)
753 for f
in input_api
.AffectedSourceFiles(FilterFile
):
754 for line_num
, line
in f
.ChangedContents():
755 if not comment_pattern
.search(line
) and pattern
.search(line
):
756 problems
.append((f
.LocalPath(), line_num
, line
))
759 return [output_api
.PresubmitPromptOrNotify(
760 'Most layers below src/chrome/ should not hardcode service URLs.\n'
761 'Are you sure this is correct? (Contact: joi@chromium.org)',
763 problem
[0], problem
[1], problem
[2]) for problem
in problems
])]
768 def _CheckNoAbbreviationInPngFileName(input_api
, output_api
):
769 """Makes sure there are no abbreviations in the name of PNG files.
771 pattern
= input_api
.re
.compile(r
'.*_[a-z]_.*\.png$|.*_[a-z]\.png$')
773 for f
in input_api
.AffectedFiles(include_deletes
=False):
774 if pattern
.match(f
.LocalPath()):
775 errors
.append(' %s' % f
.LocalPath())
779 results
.append(output_api
.PresubmitError(
780 'The name of PNG files should not have abbreviations. \n'
781 'Use _hover.png, _center.png, instead of _h.png, _c.png.\n'
782 'Contact oshima@chromium.org if you have questions.', errors
))
786 def _DepsFilesToCheck(re
, changed_lines
):
787 """Helper method for _CheckAddedDepsHaveTargetApprovals. Returns
788 a set of DEPS entries that we should look up."""
789 # We ignore deps entries on auto-generated directories.
790 AUTO_GENERATED_DIRS
= ['grit', 'jni']
792 # This pattern grabs the path without basename in the first
793 # parentheses, and the basename (if present) in the second. It
794 # relies on the simple heuristic that if there is a basename it will
795 # be a header file ending in ".h".
796 pattern
= re
.compile(
797 r
"""['"]\+([^'"]+?)(/[a-zA-Z0-9_]+\.h)?['"].*""")
799 for changed_line
in changed_lines
:
800 m
= pattern
.match(changed_line
)
803 if path
.split('/')[0] not in AUTO_GENERATED_DIRS
:
804 results
.add('%s/DEPS' % m
.group(1))
808 def _CheckAddedDepsHaveTargetApprovals(input_api
, output_api
):
809 """When a dependency prefixed with + is added to a DEPS file, we
810 want to make sure that the change is reviewed by an OWNER of the
811 target file or directory, to avoid layering violations from being
812 introduced. This check verifies that this happens.
814 changed_lines
= set()
815 for f
in input_api
.AffectedFiles():
816 filename
= input_api
.os_path
.basename(f
.LocalPath())
817 if filename
== 'DEPS':
818 changed_lines |
= set(line
.strip()
820 in f
.ChangedContents())
821 if not changed_lines
:
824 virtual_depended_on_files
= _DepsFilesToCheck(input_api
.re
, changed_lines
)
825 if not virtual_depended_on_files
:
828 if input_api
.is_committing
:
830 return [output_api
.PresubmitNotifyResult(
831 '--tbr was specified, skipping OWNERS check for DEPS additions')]
832 if not input_api
.change
.issue
:
833 return [output_api
.PresubmitError(
834 "DEPS approval by OWNERS check failed: this change has "
835 "no Rietveld issue number, so we can't check it for approvals.")]
836 output
= output_api
.PresubmitError
838 output
= output_api
.PresubmitNotifyResult
840 owners_db
= input_api
.owners_db
841 owner_email
, reviewers
= input_api
.canned_checks
._RietveldOwnerAndReviewers
(
843 owners_db
.email_regexp
,
844 approval_needed
=input_api
.is_committing
)
846 owner_email
= owner_email
or input_api
.change
.author_email
848 reviewers_plus_owner
= set(reviewers
)
850 reviewers_plus_owner
.add(owner_email
)
851 missing_files
= owners_db
.files_not_covered_by(virtual_depended_on_files
,
852 reviewers_plus_owner
)
853 unapproved_dependencies
= ["'+%s'," % path
[:-len('/DEPS')]
854 for path
in missing_files
]
856 if unapproved_dependencies
:
858 output('Missing LGTM from OWNERS of directories added to DEPS:\n %s' %
859 '\n '.join(sorted(unapproved_dependencies
)))]
860 if not input_api
.is_committing
:
861 suggested_owners
= owners_db
.reviewers_for(missing_files
, owner_email
)
862 output_list
.append(output(
863 'Suggested missing target path OWNERS:\n %s' %
864 '\n '.join(suggested_owners
or [])))
870 def _CheckSpamLogging(input_api
, output_api
):
871 file_inclusion_pattern
= r
'.+%s' % _IMPLEMENTATION_EXTENSIONS
872 black_list
= (_EXCLUDED_PATHS
+
873 _TEST_CODE_EXCLUDED_PATHS
+
874 input_api
.DEFAULT_BLACK_LIST
+
875 (r
"^base[\\\/]logging\.h$",
876 r
"^chrome[\\\/]app[\\\/]chrome_main_delegate\.cc$",
877 r
"^chrome[\\\/]browser[\\\/]chrome_browser_main\.cc$",
878 r
"^chrome[\\\/]browser[\\\/]ui[\\\/]startup[\\\/]"
879 r
"startup_browser_creator\.cc$",
880 r
"^chrome[\\\/]installer[\\\/]setup[\\\/].*",
881 r
"^chrome[\\\/]renderer[\\\/]extensions[\\\/]"
882 r
"logging_native_handler\.cc$",
883 r
"^remoting[\\\/]base[\\\/]logging\.h$",
884 r
"^remoting[\\\/]host[\\\/].*",
885 r
"^sandbox[\\\/]linux[\\\/].*",
886 r
"^ui[\\\/]aura[\\\/]bench[\\\/]bench_main\.cc$",))
887 source_file_filter
= lambda x
: input_api
.FilterSourceFile(
888 x
, white_list
=(file_inclusion_pattern
,), black_list
=black_list
)
893 for f
in input_api
.AffectedSourceFiles(source_file_filter
):
894 contents
= input_api
.ReadFile(f
, 'rb')
895 if re
.search(r
"\bD?LOG\s*\(\s*INFO\s*\)", contents
):
896 log_info
.append(f
.LocalPath())
897 elif re
.search(r
"\bD?LOG_IF\s*\(\s*INFO\s*,", contents
):
898 log_info
.append(f
.LocalPath())
900 if re
.search(r
"\bprintf\(", contents
):
901 printf
.append(f
.LocalPath())
902 elif re
.search(r
"\bfprintf\((stdout|stderr)", contents
):
903 printf
.append(f
.LocalPath())
906 return [output_api
.PresubmitError(
907 'These files spam the console log with LOG(INFO):',
910 return [output_api
.PresubmitError(
911 'These files spam the console log with printf/fprintf:',
916 def _CheckForAnonymousVariables(input_api
, output_api
):
917 """These types are all expected to hold locks while in scope and
918 so should never be anonymous (which causes them to be immediately
920 they_who_must_be_named
= [
924 'SkAutoAlphaRestore',
925 'SkAutoBitmapShaderInstall',
926 'SkAutoBlitterChoose',
927 'SkAutoBounderCommit',
929 'SkAutoCanvasRestore',
930 'SkAutoCommentBlock',
932 'SkAutoDisableDirectionCheck',
933 'SkAutoDisableOvalCheck',
940 'SkAutoMaskFreeImage',
941 'SkAutoMutexAcquire',
942 'SkAutoPathBoundsUpdate',
944 'SkAutoRasterClipValidate',
950 anonymous
= r
'(%s)\s*[({]' % '|'.join(they_who_must_be_named
)
951 # bad: base::AutoLock(lock.get());
952 # not bad: base::AutoLock lock(lock.get());
953 bad_pattern
= input_api
.re
.compile(anonymous
)
954 # good: new base::AutoLock(lock.get())
955 good_pattern
= input_api
.re
.compile(r
'\bnew\s*' + anonymous
)
958 for f
in input_api
.AffectedFiles():
959 if not f
.LocalPath().endswith(('.cc', '.h', '.inl', '.m', '.mm')):
961 for linenum
, line
in f
.ChangedContents():
962 if bad_pattern
.search(line
) and not good_pattern
.search(line
):
963 errors
.append('%s:%d' % (f
.LocalPath(), linenum
))
966 return [output_api
.PresubmitError(
967 'These lines create anonymous variables that need to be named:',
972 def _CheckCygwinShell(input_api
, output_api
):
973 source_file_filter
= lambda x
: input_api
.FilterSourceFile(
974 x
, white_list
=(r
'.+\.(gyp|gypi)$',))
977 for f
in input_api
.AffectedSourceFiles(source_file_filter
):
978 for linenum
, line
in f
.ChangedContents():
979 if 'msvs_cygwin_shell' in line
:
980 cygwin_shell
.append(f
.LocalPath())
984 return [output_api
.PresubmitError(
985 'These files should not use msvs_cygwin_shell (the default is 0):',
990 def _CheckJavaStyle(input_api
, output_api
):
991 """Runs checkstyle on changed java files and returns errors if any exist."""
992 original_sys_path
= sys
.path
994 sys
.path
= sys
.path
+ [input_api
.os_path
.join(
995 input_api
.PresubmitLocalPath(), 'tools', 'android', 'checkstyle')]
998 # Restore sys.path to what it was before.
999 sys
.path
= original_sys_path
1001 return checkstyle
.RunCheckstyle(
1002 input_api
, output_api
, 'tools/android/checkstyle/chromium-style-5.0.xml')
1005 def _CommonChecks(input_api
, output_api
):
1006 """Checks common to both upload and commit."""
1008 results
.extend(input_api
.canned_checks
.PanProjectChecks(
1009 input_api
, output_api
,
1010 excluded_paths
=_EXCLUDED_PATHS
+ _TESTRUNNER_PATHS
))
1011 results
.extend(_CheckAuthorizedAuthor(input_api
, output_api
))
1013 _CheckNoProductionCodeUsingTestOnlyFunctions(input_api
, output_api
))
1014 results
.extend(_CheckNoIOStreamInHeaders(input_api
, output_api
))
1015 results
.extend(_CheckNoUNIT_TESTInSourceFiles(input_api
, output_api
))
1016 results
.extend(_CheckNoNewWStrings(input_api
, output_api
))
1017 results
.extend(_CheckNoDEPSGIT(input_api
, output_api
))
1018 results
.extend(_CheckNoBannedFunctions(input_api
, output_api
))
1019 results
.extend(_CheckNoPragmaOnce(input_api
, output_api
))
1020 results
.extend(_CheckNoTrinaryTrueFalse(input_api
, output_api
))
1021 results
.extend(_CheckUnwantedDependencies(input_api
, output_api
))
1022 results
.extend(_CheckFilePermissions(input_api
, output_api
))
1023 results
.extend(_CheckNoAuraWindowPropertyHInHeaders(input_api
, output_api
))
1024 results
.extend(_CheckIncludeOrder(input_api
, output_api
))
1025 results
.extend(_CheckForVersionControlConflicts(input_api
, output_api
))
1026 results
.extend(_CheckPatchFiles(input_api
, output_api
))
1027 results
.extend(_CheckHardcodedGoogleHostsInLowerLayers(input_api
, output_api
))
1028 results
.extend(_CheckNoAbbreviationInPngFileName(input_api
, output_api
))
1029 results
.extend(_CheckForInvalidOSMacros(input_api
, output_api
))
1030 results
.extend(_CheckAddedDepsHaveTargetApprovals(input_api
, output_api
))
1032 input_api
.canned_checks
.CheckChangeHasNoTabs(
1035 source_file_filter
=lambda x
: x
.LocalPath().endswith('.grd')))
1036 results
.extend(_CheckSpamLogging(input_api
, output_api
))
1037 results
.extend(_CheckForAnonymousVariables(input_api
, output_api
))
1038 results
.extend(_CheckCygwinShell(input_api
, output_api
))
1039 results
.extend(_CheckJavaStyle(input_api
, output_api
))
1040 results
.extend(_CheckForString16(input_api
, output_api
))
1042 if any('PRESUBMIT.py' == f
.LocalPath() for f
in input_api
.AffectedFiles()):
1043 results
.extend(input_api
.canned_checks
.RunUnitTestsInDirectory(
1044 input_api
, output_api
,
1045 input_api
.PresubmitLocalPath(),
1046 whitelist
=[r
'^PRESUBMIT_test\.py$']))
1050 def _CheckSubversionConfig(input_api
, output_api
):
1051 """Verifies the subversion config file is correctly setup.
1053 Checks that autoprops are enabled, returns an error otherwise.
1055 join
= input_api
.os_path
.join
1056 if input_api
.platform
== 'win32':
1057 appdata
= input_api
.environ
.get('APPDATA', '')
1059 return [output_api
.PresubmitError('%APPDATA% is not configured.')]
1060 path
= join(appdata
, 'Subversion', 'config')
1062 home
= input_api
.environ
.get('HOME', '')
1064 return [output_api
.PresubmitError('$HOME is not configured.')]
1065 path
= join(home
, '.subversion', 'config')
1068 'Please look at http://dev.chromium.org/developers/coding-style to\n'
1069 'configure your subversion configuration file. This enables automatic\n'
1070 'properties to simplify the project maintenance.\n'
1071 'Pro-tip: just download and install\n'
1072 'http://src.chromium.org/viewvc/chrome/trunk/tools/build/slave/config\n')
1075 lines
= open(path
, 'r').read().splitlines()
1076 # Make sure auto-props is enabled and check for 2 Chromium standard
1078 if (not '*.cc = svn:eol-style=LF' in lines
or
1079 not '*.pdf = svn:mime-type=application/pdf' in lines
or
1080 not 'enable-auto-props = yes' in lines
):
1082 output_api
.PresubmitNotifyResult(
1083 'It looks like you have not configured your subversion config '
1084 'file or it is not up-to-date.\n' + error_msg
)
1086 except (OSError, IOError):
1088 output_api
.PresubmitNotifyResult(
1089 'Can\'t find your subversion config file.\n' + error_msg
)
1094 def _CheckAuthorizedAuthor(input_api
, output_api
):
1095 """For non-googler/chromites committers, verify the author's email address is
1098 # TODO(maruel): Add it to input_api?
1101 author
= input_api
.change
.author_email
1103 input_api
.logging
.info('No author, skipping AUTHOR check')
1105 authors_path
= input_api
.os_path
.join(
1106 input_api
.PresubmitLocalPath(), 'AUTHORS')
1108 input_api
.re
.match(r
'[^#]+\s+\<(.+?)\>\s*$', line
)
1109 for line
in open(authors_path
))
1110 valid_authors
= [item
.group(1).lower() for item
in valid_authors
if item
]
1111 if not any(fnmatch
.fnmatch(author
.lower(), valid
) for valid
in valid_authors
):
1112 input_api
.logging
.info('Valid authors are %s', ', '.join(valid_authors
))
1113 return [output_api
.PresubmitPromptWarning(
1114 ('%s is not in AUTHORS file. If you are a new contributor, please visit'
1116 'http://www.chromium.org/developers/contributing-code and read the '
1118 'If you are a chromite, verify the contributor signed the CLA.') %
1123 def _CheckPatchFiles(input_api
, output_api
):
1124 problems
= [f
.LocalPath() for f
in input_api
.AffectedFiles()
1125 if f
.LocalPath().endswith(('.orig', '.rej'))]
1127 return [output_api
.PresubmitError(
1128 "Don't commit .rej and .orig files.", problems
)]
1133 def _DidYouMeanOSMacro(bad_macro
):
1135 return {'A': 'OS_ANDROID',
1145 'W': 'OS_WIN'}[bad_macro
[3].upper()]
1150 def _CheckForInvalidOSMacrosInFile(input_api
, f
):
1151 """Check for sensible looking, totally invalid OS macros."""
1152 preprocessor_statement
= input_api
.re
.compile(r
'^\s*#')
1153 os_macro
= input_api
.re
.compile(r
'defined\((OS_[^)]+)\)')
1155 for lnum
, line
in f
.ChangedContents():
1156 if preprocessor_statement
.search(line
):
1157 for match
in os_macro
.finditer(line
):
1158 if not match
.group(1) in _VALID_OS_MACROS
:
1159 good
= _DidYouMeanOSMacro(match
.group(1))
1160 did_you_mean
= ' (did you mean %s?)' % good
if good
else ''
1161 results
.append(' %s:%d %s%s' % (f
.LocalPath(),
1168 def _CheckForInvalidOSMacros(input_api
, output_api
):
1169 """Check all affected files for invalid OS macros."""
1171 for f
in input_api
.AffectedFiles():
1172 if not f
.LocalPath().endswith(('.py', '.js', '.html', '.css')):
1173 bad_macros
.extend(_CheckForInvalidOSMacrosInFile(input_api
, f
))
1178 return [output_api
.PresubmitError(
1179 'Possibly invalid OS macro[s] found. Please fix your code\n'
1180 'or add your macro to src/PRESUBMIT.py.', bad_macros
)]
1183 def _CheckForString16InFile(input_api
, f
):
1184 """Check for string16 without base:: in front."""
1185 reg
= input_api
.re
.compile(r
'\b(?<!base::)string16\b')
1186 use
= 'using base::string16;'
1187 include
= '#include "base/strings/string16.h"'
1189 for lnum
, line
in f
.ChangedContents():
1190 if reg
.search(line
) and not include
in line
and not use
in f
.NewContents():
1191 results
.append(' %s:%d' % (f
.LocalPath(), lnum
))
1195 def _CheckForString16(input_api
, output_api
):
1196 file_filter
= lambda f
: input_api
.FilterSourceFile(f
,
1198 r
'^android_webview[\\\/]',
1202 r
'^chrome_frame[\\\/]',
1204 r
'^components[\\\/]',
1218 black_list
=(_EXCLUDED_PATHS
+ _TEST_CODE_EXCLUDED_PATHS
+
1219 input_api
.DEFAULT_BLACK_LIST
))
1222 for f
in input_api
.AffectedFiles(file_filter
=file_filter
):
1223 unprefixed
.extend(_CheckForString16InFile(input_api
, f
))
1228 return [output_api
.PresubmitPromptWarning(
1229 'string16 should be prefixed with base:: namespace.', unprefixed
)]
1232 def CheckChangeOnUpload(input_api
, output_api
):
1234 results
.extend(_CommonChecks(input_api
, output_api
))
1238 def GetDefaultTryConfigs(bots
=None):
1239 """Returns a list of ('bot', set(['tests']), optionally filtered by [bots].
1241 To add tests to this list, they MUST be in the the corresponding master's
1242 gatekeeper config. For example, anything on master.chromium would be closed by
1243 tools/build/masters/master.chromium/master_gatekeeper_cfg.py.
1245 If 'bots' is specified, will only return configurations for bots in that list.
1251 'cacheinvalidation_unittests',
1254 'content_browsertests',
1255 'content_unittests',
1259 'interactive_ui_tests',
1265 'printing_unittests',
1269 # Broken in release.
1271 #'webkit_unit_tests',
1274 linux_aura_tests
= [
1275 'app_list_unittests',
1278 'compositor_unittests',
1279 'content_browsertests',
1280 'content_unittests',
1282 'interactive_ui_tests',
1285 builders_and_tests
= {
1286 # TODO(maruel): Figure out a way to run 'sizes' where people can
1287 # effectively update the perf expectation correctly. This requires a
1288 # clobber=True build running 'sizes'. 'sizes' is not accurate with
1289 # incremental build. Reference:
1290 # http://chromium.org/developers/tree-sheriffs/perf-sheriffs.
1291 # TODO(maruel): An option would be to run 'sizes' but not count a failure
1292 # of this step as a try job failure.
1293 'android_aosp': ['compile'],
1294 'android_clang_dbg': ['slave_steps'],
1295 'android_dbg': ['slave_steps'],
1296 'cros_x86': ['defaulttests'],
1297 'ios_dbg_simulator': [
1300 'content_unittests',
1307 'ios_rel_device': ['compile'],
1308 'linux_asan': ['defaulttests'],
1309 #TODO(stip): Change the name of this builder to reflect that it's release.
1310 'linux_aura': linux_aura_tests
,
1311 'linux_chromeos_asan': ['defaulttests'],
1312 'linux_chromeos_clang': ['compile'],
1313 # Note: It is a Release builder even if its name convey otherwise.
1314 'linux_chromeos': standard_tests
+ [
1315 'app_list_unittests',
1318 'chromeos_unittests',
1319 'components_unittests',
1323 'google_apis_unittests',
1324 'sandbox_linux_unittests',
1326 'linux_clang': ['compile'],
1327 'linux_rel': standard_tests
+ [
1329 'chromedriver2_unittests',
1330 'components_unittests',
1331 'google_apis_unittests',
1333 'remoting_unittests',
1334 'sandbox_linux_unittests',
1335 'sync_integration_tests',
1338 'mac_rel': standard_tests
+ [
1339 'app_list_unittests',
1341 'chromedriver2_unittests',
1342 'components_unittests',
1343 'google_apis_unittests',
1344 'message_center_unittests',
1346 'remoting_unittests',
1347 'sync_integration_tests',
1348 'telemetry_unittests',
1351 'win_rel': standard_tests
+ [
1352 'app_list_unittests',
1356 'chrome_elf_unittests',
1357 'chromedriver2_unittests',
1358 'components_unittests',
1359 'compositor_unittests',
1361 'google_apis_unittests',
1362 'installer_util_unittests',
1363 'mini_installer_test',
1365 'remoting_unittests',
1366 'sync_integration_tests',
1367 'telemetry_unittests',
1375 swarm_enabled_builders
= (
1381 swarm_enabled_tests
= (
1384 'interactive_ui_tests',
1389 for bot
in builders_and_tests
:
1390 if bot
in swarm_enabled_builders
:
1391 builders_and_tests
[bot
] = [x
+ '_swarm' if x
in swarm_enabled_tests
else x
1392 for x
in builders_and_tests
[bot
]]
1395 return [(bot
, set(builders_and_tests
[bot
])) for bot
in bots
]
1397 return [(bot
, set(tests
)) for bot
, tests
in builders_and_tests
.iteritems()]
1400 def CheckChangeOnCommit(input_api
, output_api
):
1402 results
.extend(_CommonChecks(input_api
, output_api
))
1403 # TODO(thestig) temporarily disabled, doesn't work in third_party/
1404 #results.extend(input_api.canned_checks.CheckSvnModifiedDirectories(
1405 # input_api, output_api, sources))
1406 # Make sure the tree is 'open'.
1407 results
.extend(input_api
.canned_checks
.CheckTreeIsOpen(
1410 json_url
='http://chromium-status.appspot.com/current?format=json'))
1411 results
.extend(input_api
.canned_checks
.CheckRietveldTryJobExecution(input_api
,
1412 output_api
, 'http://codereview.chromium.org',
1413 ('win_rel', 'linux_rel', 'mac_rel, win:compile'),
1414 'tryserver@chromium.org'))
1416 results
.extend(input_api
.canned_checks
.CheckChangeHasBugField(
1417 input_api
, output_api
))
1418 results
.extend(input_api
.canned_checks
.CheckChangeHasDescription(
1419 input_api
, output_api
))
1420 results
.extend(_CheckSubversionConfig(input_api
, output_api
))
1424 def GetPreferredTrySlaves(project
, change
):
1425 files
= change
.LocalPaths()
1427 if not files
or all(re
.search(r
'[\\/]OWNERS$', f
) for f
in files
):
1430 if all(re
.search('\.(m|mm)$|(^|[/_])mac[/_.]', f
) for f
in files
):
1431 return GetDefaultTryConfigs(['mac', 'mac_rel'])
1432 if all(re
.search('(^|[/_])win[/_.]', f
) for f
in files
):
1433 return GetDefaultTryConfigs(['win', 'win_rel'])
1434 if all(re
.search('(^|[/_])android[/_.]', f
) for f
in files
):
1435 return GetDefaultTryConfigs([
1437 'android_clang_dbg',
1440 if all(re
.search('^native_client_sdk', f
) for f
in files
):
1441 return GetDefaultTryConfigs([
1446 if all(re
.search('[/_]ios[/_.]', f
) for f
in files
):
1447 return GetDefaultTryConfigs(['ios_rel_device', 'ios_dbg_simulator'])
1449 trybots
= GetDefaultTryConfigs([
1450 'android_clang_dbg',
1452 'ios_dbg_simulator',
1466 # Match things like path/aura/file.cc and path/file_aura.cc.
1467 # Same for chromeos.
1468 if any(re
.search('[/_](aura|chromeos)', f
) for f
in files
):
1469 trybots
.extend(GetDefaultTryConfigs([
1470 'linux_chromeos_asan', 'linux_chromeos_clang']))
1472 # If there are gyp changes to base, build, or chromeos, run a full cros build
1473 # in addition to the shorter linux_chromeos build. Changes to high level gyp
1474 # files have a much higher chance of breaking the cros build, which is
1475 # differnt from the linux_chromeos build that most chrome developers test
1477 if any(re
.search('^(base|build|chromeos).*\.gypi?$', f
) for f
in files
):
1478 trybots
.extend(GetDefaultTryConfigs(['cros_x86']))
1480 # The AOSP bot doesn't build the chrome/ layer, so ignore any changes to it
1481 # unless they're .gyp(i) files as changes to those files can break the gyp
1483 if (not all(re
.search('^chrome', f
) for f
in files
) or
1484 any(re
.search('\.gypi?$', f
) for f
in files
)):
1485 trybots
.extend(GetDefaultTryConfigs(['android_aosp']))