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.
18 r
"^native_client_sdk[\\\/]src[\\\/]build_tools[\\\/]make_rules.py",
19 r
"^native_client_sdk[\\\/]src[\\\/]build_tools[\\\/]make_simple.py",
20 r
"^native_client_sdk[\\\/]src[\\\/]tools[\\\/].*.mk",
21 r
"^net[\\\/]tools[\\\/]spdyshark[\\\/].*",
26 r
".+[\\\/]pnacl_shim\.c$",
27 r
"^gpu[\\\/]config[\\\/].*_list_json\.cc$",
28 r
"^chrome[\\\/]browser[\\\/]resources[\\\/]pdf[\\\/]index.js"
31 # TestRunner and NetscapePlugIn library is temporarily excluded from pan-project
32 # checks until it's transitioned to chromium coding style.
34 r
"^content[\\\/]shell[\\\/]renderer[\\\/]test_runner[\\\/].*",
35 r
"^content[\\\/]shell[\\\/]common[\\\/]test_runner[\\\/].*",
36 r
"^content[\\\/]shell[\\\/]tools[\\\/]plugin[\\\/].*",
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|kif|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.')
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
"^mojo[\\\/]system[\\\/]raw_shared_buffer_posix\.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.
245 'OS_CAT', # For testing.
260 def _CheckNoProductionCodeUsingTestOnlyFunctions(input_api
, output_api
):
261 """Attempts to prevent use of functions intended only for testing in
262 non-testing code. For now this is just a best-effort implementation
263 that ignores header files and may have some false positives. A
264 better implementation would probably need a proper C++ parser.
266 # We only scan .cc files and the like, as the declaration of
267 # for-testing functions in header files are hard to distinguish from
268 # calls to such functions without a proper C++ parser.
269 file_inclusion_pattern
= r
'.+%s' % _IMPLEMENTATION_EXTENSIONS
271 base_function_pattern
= r
'ForTest(ing)?|for_test(ing)?'
272 inclusion_pattern
= input_api
.re
.compile(r
'(%s)\s*\(' % base_function_pattern
)
273 comment_pattern
= input_api
.re
.compile(r
'//.*%s' % base_function_pattern
)
274 exclusion_pattern
= input_api
.re
.compile(
275 r
'::[A-Za-z0-9_]+(%s)|(%s)[^;]+\{' % (
276 base_function_pattern
, base_function_pattern
))
278 def FilterFile(affected_file
):
279 black_list
= (_EXCLUDED_PATHS
+
280 _TEST_CODE_EXCLUDED_PATHS
+
281 input_api
.DEFAULT_BLACK_LIST
)
282 return input_api
.FilterSourceFile(
284 white_list
=(file_inclusion_pattern
, ),
285 black_list
=black_list
)
288 for f
in input_api
.AffectedSourceFiles(FilterFile
):
289 local_path
= f
.LocalPath()
290 for line_number
, line
in f
.ChangedContents():
291 if (inclusion_pattern
.search(line
) and
292 not comment_pattern
.search(line
) and
293 not exclusion_pattern
.search(line
)):
295 '%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 if input_api
.platform
== 'win32':
530 args
= [sys
.executable
, 'tools/checkperms/checkperms.py', '--root',
531 input_api
.change
.RepositoryRoot()]
532 for f
in input_api
.AffectedFiles():
533 args
+= ['--file', f
.LocalPath()]
534 checkperms
= input_api
.subprocess
.Popen(args
,
535 stdout
=input_api
.subprocess
.PIPE
)
536 errors
= checkperms
.communicate()[0].strip()
538 return [output_api
.PresubmitError('checkperms.py failed.',
539 errors
.splitlines())]
543 def _CheckNoAuraWindowPropertyHInHeaders(input_api
, output_api
):
544 """Makes sure we don't include ui/aura/window_property.h
547 pattern
= input_api
.re
.compile(r
'^#include\s*"ui/aura/window_property.h"')
549 for f
in input_api
.AffectedFiles():
550 if not f
.LocalPath().endswith('.h'):
552 for line_num
, line
in f
.ChangedContents():
553 if pattern
.match(line
):
554 errors
.append(' %s:%d' % (f
.LocalPath(), line_num
))
558 results
.append(output_api
.PresubmitError(
559 'Header files should not include ui/aura/window_property.h', errors
))
563 def _CheckIncludeOrderForScope(scope
, input_api
, file_path
, changed_linenums
):
564 """Checks that the lines in scope occur in the right order.
566 1. C system files in alphabetical order
567 2. C++ system files in alphabetical order
568 3. Project's .h files
571 c_system_include_pattern
= input_api
.re
.compile(r
'\s*#include <.*\.h>')
572 cpp_system_include_pattern
= input_api
.re
.compile(r
'\s*#include <.*>')
573 custom_include_pattern
= input_api
.re
.compile(r
'\s*#include ".*')
575 C_SYSTEM_INCLUDES
, CPP_SYSTEM_INCLUDES
, CUSTOM_INCLUDES
= range(3)
577 state
= C_SYSTEM_INCLUDES
580 previous_line_num
= 0
581 problem_linenums
= []
582 for line_num
, line
in scope
:
583 if c_system_include_pattern
.match(line
):
584 if state
!= C_SYSTEM_INCLUDES
:
585 problem_linenums
.append((line_num
, previous_line_num
))
586 elif previous_line
and previous_line
> line
:
587 problem_linenums
.append((line_num
, previous_line_num
))
588 elif cpp_system_include_pattern
.match(line
):
589 if state
== C_SYSTEM_INCLUDES
:
590 state
= CPP_SYSTEM_INCLUDES
591 elif state
== CUSTOM_INCLUDES
:
592 problem_linenums
.append((line_num
, previous_line_num
))
593 elif previous_line
and previous_line
> line
:
594 problem_linenums
.append((line_num
, previous_line_num
))
595 elif custom_include_pattern
.match(line
):
596 if state
!= CUSTOM_INCLUDES
:
597 state
= CUSTOM_INCLUDES
598 elif previous_line
and previous_line
> line
:
599 problem_linenums
.append((line_num
, previous_line_num
))
601 problem_linenums
.append(line_num
)
603 previous_line_num
= line_num
606 for (line_num
, previous_line_num
) in problem_linenums
:
607 if line_num
in changed_linenums
or previous_line_num
in changed_linenums
:
608 warnings
.append(' %s:%d' % (file_path
, line_num
))
612 def _CheckIncludeOrderInFile(input_api
, f
, changed_linenums
):
613 """Checks the #include order for the given file f."""
615 system_include_pattern
= input_api
.re
.compile(r
'\s*#include \<.*')
616 # Exclude the following includes from the check:
617 # 1) #include <.../...>, e.g., <sys/...> includes often need to appear in a
619 # 2) <atlbase.h>, "build/build_config.h"
620 excluded_include_pattern
= input_api
.re
.compile(
621 r
'\s*#include (\<.*/.*|\<atlbase\.h\>|"build/build_config.h")')
622 custom_include_pattern
= input_api
.re
.compile(r
'\s*#include "(?P<FILE>.*)"')
623 # Match the final or penultimate token if it is xxxtest so we can ignore it
624 # when considering the special first include.
625 test_file_tag_pattern
= input_api
.re
.compile(
626 r
'_[a-z]+test(?=(_[a-zA-Z0-9]+)?\.)')
627 if_pattern
= input_api
.re
.compile(
628 r
'\s*#\s*(if|elif|else|endif|define|undef).*')
629 # Some files need specialized order of includes; exclude such files from this
631 uncheckable_includes_pattern
= input_api
.re
.compile(
633 '("ipc/.*macros\.h"|<windows\.h>|".*gl.*autogen.h")\s*')
635 contents
= f
.NewContents()
639 # Handle the special first include. If the first include file is
640 # some/path/file.h, the corresponding including file can be some/path/file.cc,
641 # some/other/path/file.cc, some/path/file_platform.cc, some/path/file-suffix.h
642 # etc. It's also possible that no special first include exists.
643 # If the included file is some/path/file_platform.h the including file could
644 # also be some/path/file_xxxtest_platform.h.
645 including_file_base_name
= test_file_tag_pattern
.sub(
646 '', input_api
.os_path
.basename(f
.LocalPath()))
648 for line
in contents
:
650 if system_include_pattern
.match(line
):
651 # No special first include -> process the line again along with normal
655 match
= custom_include_pattern
.match(line
)
657 match_dict
= match
.groupdict()
658 header_basename
= test_file_tag_pattern
.sub(
659 '', input_api
.os_path
.basename(match_dict
['FILE'])).replace('.h', '')
661 if header_basename
not in including_file_base_name
:
662 # No special first include -> process the line again along with normal
667 # Split into scopes: Each region between #if and #endif is its own scope.
670 for line
in contents
[line_num
:]:
672 if uncheckable_includes_pattern
.match(line
):
674 if if_pattern
.match(line
):
675 scopes
.append(current_scope
)
677 elif ((system_include_pattern
.match(line
) or
678 custom_include_pattern
.match(line
)) and
679 not excluded_include_pattern
.match(line
)):
680 current_scope
.append((line_num
, line
))
681 scopes
.append(current_scope
)
684 warnings
.extend(_CheckIncludeOrderForScope(scope
, input_api
, f
.LocalPath(),
689 def _CheckIncludeOrder(input_api
, output_api
):
690 """Checks that the #include order is correct.
692 1. The corresponding header for source files.
693 2. C system files in alphabetical order
694 3. C++ system files in alphabetical order
695 4. Project's .h files in alphabetical order
697 Each region separated by #if, #elif, #else, #endif, #define and #undef follows
698 these rules separately.
702 for f
in input_api
.AffectedFiles():
703 if f
.LocalPath().endswith(('.cc', '.h')):
704 changed_linenums
= set(line_num
for line_num
, _
in f
.ChangedContents())
705 warnings
.extend(_CheckIncludeOrderInFile(input_api
, f
, changed_linenums
))
709 results
.append(output_api
.PresubmitPromptOrNotify(_INCLUDE_ORDER_WARNING
,
714 def _CheckForVersionControlConflictsInFile(input_api
, f
):
715 pattern
= input_api
.re
.compile('^(?:<<<<<<<|>>>>>>>) |^=======$')
717 for line_num
, line
in f
.ChangedContents():
718 if pattern
.match(line
):
719 errors
.append(' %s:%d %s' % (f
.LocalPath(), line_num
, line
))
723 def _CheckForVersionControlConflicts(input_api
, output_api
):
724 """Usually this is not intentional and will cause a compile failure."""
726 for f
in input_api
.AffectedFiles():
727 errors
.extend(_CheckForVersionControlConflictsInFile(input_api
, f
))
731 results
.append(output_api
.PresubmitError(
732 'Version control conflict markers found, please resolve.', errors
))
736 def _CheckHardcodedGoogleHostsInLowerLayers(input_api
, output_api
):
737 def FilterFile(affected_file
):
738 """Filter function for use with input_api.AffectedSourceFiles,
739 below. This filters out everything except non-test files from
740 top-level directories that generally speaking should not hard-code
741 service URLs (e.g. src/android_webview/, src/content/ and others).
743 return input_api
.FilterSourceFile(
745 white_list
=(r
'^(android_webview|base|content|net)[\\\/].*', ),
746 black_list
=(_EXCLUDED_PATHS
+
747 _TEST_CODE_EXCLUDED_PATHS
+
748 input_api
.DEFAULT_BLACK_LIST
))
750 base_pattern
= '"[^"]*google\.com[^"]*"'
751 comment_pattern
= input_api
.re
.compile('//.*%s' % base_pattern
)
752 pattern
= input_api
.re
.compile(base_pattern
)
753 problems
= [] # items are (filename, line_number, line)
754 for f
in input_api
.AffectedSourceFiles(FilterFile
):
755 for line_num
, line
in f
.ChangedContents():
756 if not comment_pattern
.search(line
) and pattern
.search(line
):
757 problems
.append((f
.LocalPath(), line_num
, line
))
760 return [output_api
.PresubmitPromptOrNotify(
761 'Most layers below src/chrome/ should not hardcode service URLs.\n'
762 'Are you sure this is correct?',
764 problem
[0], problem
[1], problem
[2]) for problem
in problems
])]
769 def _CheckNoAbbreviationInPngFileName(input_api
, output_api
):
770 """Makes sure there are no abbreviations in the name of PNG files.
772 pattern
= input_api
.re
.compile(r
'.*_[a-z]_.*\.png$|.*_[a-z]\.png$')
774 for f
in input_api
.AffectedFiles(include_deletes
=False):
775 if pattern
.match(f
.LocalPath()):
776 errors
.append(' %s' % f
.LocalPath())
780 results
.append(output_api
.PresubmitError(
781 'The name of PNG files should not have abbreviations. \n'
782 'Use _hover.png, _center.png, instead of _h.png, _c.png.\n'
783 'Contact oshima@chromium.org if you have questions.', errors
))
787 def _FilesToCheckForIncomingDeps(re
, changed_lines
):
788 """Helper method for _CheckAddedDepsHaveTargetApprovals. Returns
789 a set of DEPS entries that we should look up.
791 For a directory (rather than a specific filename) we fake a path to
792 a specific filename by adding /DEPS. This is chosen as a file that
793 will seldom or never be subject to per-file include_rules.
795 # We ignore deps entries on auto-generated directories.
796 AUTO_GENERATED_DIRS
= ['grit', 'jni']
798 # This pattern grabs the path without basename in the first
799 # parentheses, and the basename (if present) in the second. It
800 # relies on the simple heuristic that if there is a basename it will
801 # be a header file ending in ".h".
802 pattern
= re
.compile(
803 r
"""['"]\+([^'"]+?)(/[a-zA-Z0-9_]+\.h)?['"].*""")
805 for changed_line
in changed_lines
:
806 m
= pattern
.match(changed_line
)
809 if path
.split('/')[0] not in AUTO_GENERATED_DIRS
:
811 results
.add('%s%s' % (path
, m
.group(2)))
813 results
.add('%s/DEPS' % path
)
817 def _CheckAddedDepsHaveTargetApprovals(input_api
, output_api
):
818 """When a dependency prefixed with + is added to a DEPS file, we
819 want to make sure that the change is reviewed by an OWNER of the
820 target file or directory, to avoid layering violations from being
821 introduced. This check verifies that this happens.
823 changed_lines
= set()
824 for f
in input_api
.AffectedFiles():
825 filename
= input_api
.os_path
.basename(f
.LocalPath())
826 if filename
== 'DEPS':
827 changed_lines |
= set(line
.strip()
829 in f
.ChangedContents())
830 if not changed_lines
:
833 virtual_depended_on_files
= _FilesToCheckForIncomingDeps(input_api
.re
,
835 if not virtual_depended_on_files
:
838 if input_api
.is_committing
:
840 return [output_api
.PresubmitNotifyResult(
841 '--tbr was specified, skipping OWNERS check for DEPS additions')]
842 if not input_api
.change
.issue
:
843 return [output_api
.PresubmitError(
844 "DEPS approval by OWNERS check failed: this change has "
845 "no Rietveld issue number, so we can't check it for approvals.")]
846 output
= output_api
.PresubmitError
848 output
= output_api
.PresubmitNotifyResult
850 owners_db
= input_api
.owners_db
851 owner_email
, reviewers
= input_api
.canned_checks
._RietveldOwnerAndReviewers
(
853 owners_db
.email_regexp
,
854 approval_needed
=input_api
.is_committing
)
856 owner_email
= owner_email
or input_api
.change
.author_email
858 reviewers_plus_owner
= set(reviewers
)
860 reviewers_plus_owner
.add(owner_email
)
861 missing_files
= owners_db
.files_not_covered_by(virtual_depended_on_files
,
862 reviewers_plus_owner
)
864 # We strip the /DEPS part that was added by
865 # _FilesToCheckForIncomingDeps to fake a path to a file in a
868 start_deps
= path
.rfind('/DEPS')
870 return path
[:start_deps
]
873 unapproved_dependencies
= ["'+%s'," % StripDeps(path
)
874 for path
in missing_files
]
876 if unapproved_dependencies
:
878 output('Missing LGTM from OWNERS of dependencies added to DEPS:\n %s' %
879 '\n '.join(sorted(unapproved_dependencies
)))]
880 if not input_api
.is_committing
:
881 suggested_owners
= owners_db
.reviewers_for(missing_files
, owner_email
)
882 output_list
.append(output(
883 'Suggested missing target path OWNERS:\n %s' %
884 '\n '.join(suggested_owners
or [])))
890 def _CheckSpamLogging(input_api
, output_api
):
891 file_inclusion_pattern
= r
'.+%s' % _IMPLEMENTATION_EXTENSIONS
892 black_list
= (_EXCLUDED_PATHS
+
893 _TEST_CODE_EXCLUDED_PATHS
+
894 input_api
.DEFAULT_BLACK_LIST
+
895 (r
"^base[\\\/]logging\.h$",
896 r
"^base[\\\/]logging\.cc$",
897 r
"^cloud_print[\\\/]",
898 r
"^chrome_elf[\\\/]dll_hash[\\\/]dll_hash_main\.cc$",
899 r
"^chrome[\\\/]app[\\\/]chrome_main_delegate\.cc$",
900 r
"^chrome[\\\/]browser[\\\/]chrome_browser_main\.cc$",
901 r
"^chrome[\\\/]browser[\\\/]ui[\\\/]startup[\\\/]"
902 r
"startup_browser_creator\.cc$",
903 r
"^chrome[\\\/]installer[\\\/]setup[\\\/].*",
904 r
"^chrome[\\\/]renderer[\\\/]extensions[\\\/]"
905 r
"logging_native_handler\.cc$",
906 r
"^content[\\\/]common[\\\/]gpu[\\\/]client[\\\/]"
907 r
"gl_helper_benchmark\.cc$",
908 r
"^native_client_sdk[\\\/]",
909 r
"^remoting[\\\/]base[\\\/]logging\.h$",
910 r
"^remoting[\\\/]host[\\\/].*",
911 r
"^sandbox[\\\/]linux[\\\/].*",
913 r
"^ui[\\\/]aura[\\\/]bench[\\\/]bench_main\.cc$",))
914 source_file_filter
= lambda x
: input_api
.FilterSourceFile(
915 x
, white_list
=(file_inclusion_pattern
,), black_list
=black_list
)
920 for f
in input_api
.AffectedSourceFiles(source_file_filter
):
921 contents
= input_api
.ReadFile(f
, 'rb')
922 if re
.search(r
"\bD?LOG\s*\(\s*INFO\s*\)", contents
):
923 log_info
.append(f
.LocalPath())
924 elif re
.search(r
"\bD?LOG_IF\s*\(\s*INFO\s*,", contents
):
925 log_info
.append(f
.LocalPath())
927 if re
.search(r
"\bprintf\(", contents
):
928 printf
.append(f
.LocalPath())
929 elif re
.search(r
"\bfprintf\((stdout|stderr)", contents
):
930 printf
.append(f
.LocalPath())
933 return [output_api
.PresubmitError(
934 'These files spam the console log with LOG(INFO):',
937 return [output_api
.PresubmitError(
938 'These files spam the console log with printf/fprintf:',
943 def _CheckForAnonymousVariables(input_api
, output_api
):
944 """These types are all expected to hold locks while in scope and
945 so should never be anonymous (which causes them to be immediately
947 they_who_must_be_named
= [
951 'SkAutoAlphaRestore',
952 'SkAutoBitmapShaderInstall',
953 'SkAutoBlitterChoose',
954 'SkAutoBounderCommit',
956 'SkAutoCanvasRestore',
957 'SkAutoCommentBlock',
959 'SkAutoDisableDirectionCheck',
960 'SkAutoDisableOvalCheck',
967 'SkAutoMaskFreeImage',
968 'SkAutoMutexAcquire',
969 'SkAutoPathBoundsUpdate',
971 'SkAutoRasterClipValidate',
977 anonymous
= r
'(%s)\s*[({]' % '|'.join(they_who_must_be_named
)
978 # bad: base::AutoLock(lock.get());
979 # not bad: base::AutoLock lock(lock.get());
980 bad_pattern
= input_api
.re
.compile(anonymous
)
981 # good: new base::AutoLock(lock.get())
982 good_pattern
= input_api
.re
.compile(r
'\bnew\s*' + anonymous
)
985 for f
in input_api
.AffectedFiles():
986 if not f
.LocalPath().endswith(('.cc', '.h', '.inl', '.m', '.mm')):
988 for linenum
, line
in f
.ChangedContents():
989 if bad_pattern
.search(line
) and not good_pattern
.search(line
):
990 errors
.append('%s:%d' % (f
.LocalPath(), linenum
))
993 return [output_api
.PresubmitError(
994 'These lines create anonymous variables that need to be named:',
999 def _CheckCygwinShell(input_api
, output_api
):
1000 source_file_filter
= lambda x
: input_api
.FilterSourceFile(
1001 x
, white_list
=(r
'.+\.(gyp|gypi)$',))
1004 for f
in input_api
.AffectedSourceFiles(source_file_filter
):
1005 for linenum
, line
in f
.ChangedContents():
1006 if 'msvs_cygwin_shell' in line
:
1007 cygwin_shell
.append(f
.LocalPath())
1011 return [output_api
.PresubmitError(
1012 'These files should not use msvs_cygwin_shell (the default is 0):',
1013 items
=cygwin_shell
)]
1017 def _CheckUserActionUpdate(input_api
, output_api
):
1018 """Checks if any new user action has been added."""
1019 if any('actions.xml' == input_api
.os_path
.basename(f
) for f
in
1020 input_api
.LocalPaths()):
1021 # If actions.xml is already included in the changelist, the PRESUBMIT
1022 # for actions.xml will do a more complete presubmit check.
1025 file_filter
= lambda f
: f
.LocalPath().endswith(('.cc', '.mm'))
1026 action_re
= r
'[^a-zA-Z]UserMetricsAction\("([^"]*)'
1027 current_actions
= None
1028 for f
in input_api
.AffectedFiles(file_filter
=file_filter
):
1029 for line_num
, line
in f
.ChangedContents():
1030 match
= input_api
.re
.search(action_re
, line
)
1032 # Loads contents in tools/metrics/actions/actions.xml to memory. It's
1034 if not current_actions
:
1035 with
open('tools/metrics/actions/actions.xml') as actions_f
:
1036 current_actions
= actions_f
.read()
1037 # Search for the matched user action name in |current_actions|.
1038 for action_name
in match
.groups():
1039 action
= 'name="{0}"'.format(action_name
)
1040 if action
not in current_actions
:
1041 return [output_api
.PresubmitPromptWarning(
1042 'File %s line %d: %s is missing in '
1043 'tools/metrics/actions/actions.xml. Please run '
1044 'tools/metrics/actions/extract_actions.py to update.'
1045 % (f
.LocalPath(), line_num
, action_name
))]
1049 def _CheckJavaStyle(input_api
, output_api
):
1050 """Runs checkstyle on changed java files and returns errors if any exist."""
1051 original_sys_path
= sys
.path
1053 sys
.path
= sys
.path
+ [input_api
.os_path
.join(
1054 input_api
.PresubmitLocalPath(), 'tools', 'android', 'checkstyle')]
1057 # Restore sys.path to what it was before.
1058 sys
.path
= original_sys_path
1060 return checkstyle
.RunCheckstyle(
1061 input_api
, output_api
, 'tools/android/checkstyle/chromium-style-5.0.xml')
1064 def _CommonChecks(input_api
, output_api
):
1065 """Checks common to both upload and commit."""
1067 results
.extend(input_api
.canned_checks
.PanProjectChecks(
1068 input_api
, output_api
,
1069 excluded_paths
=_EXCLUDED_PATHS
+ _TESTRUNNER_PATHS
))
1070 results
.extend(_CheckAuthorizedAuthor(input_api
, output_api
))
1072 _CheckNoProductionCodeUsingTestOnlyFunctions(input_api
, output_api
))
1073 results
.extend(_CheckNoIOStreamInHeaders(input_api
, output_api
))
1074 results
.extend(_CheckNoUNIT_TESTInSourceFiles(input_api
, output_api
))
1075 results
.extend(_CheckNoNewWStrings(input_api
, output_api
))
1076 results
.extend(_CheckNoDEPSGIT(input_api
, output_api
))
1077 results
.extend(_CheckNoBannedFunctions(input_api
, output_api
))
1078 results
.extend(_CheckNoPragmaOnce(input_api
, output_api
))
1079 results
.extend(_CheckNoTrinaryTrueFalse(input_api
, output_api
))
1080 results
.extend(_CheckUnwantedDependencies(input_api
, output_api
))
1081 results
.extend(_CheckFilePermissions(input_api
, output_api
))
1082 results
.extend(_CheckNoAuraWindowPropertyHInHeaders(input_api
, output_api
))
1083 results
.extend(_CheckIncludeOrder(input_api
, output_api
))
1084 results
.extend(_CheckForVersionControlConflicts(input_api
, output_api
))
1085 results
.extend(_CheckPatchFiles(input_api
, output_api
))
1086 results
.extend(_CheckHardcodedGoogleHostsInLowerLayers(input_api
, output_api
))
1087 results
.extend(_CheckNoAbbreviationInPngFileName(input_api
, output_api
))
1088 results
.extend(_CheckForInvalidOSMacros(input_api
, output_api
))
1089 results
.extend(_CheckAddedDepsHaveTargetApprovals(input_api
, output_api
))
1091 input_api
.canned_checks
.CheckChangeHasNoTabs(
1094 source_file_filter
=lambda x
: x
.LocalPath().endswith('.grd')))
1095 results
.extend(_CheckSpamLogging(input_api
, output_api
))
1096 results
.extend(_CheckForAnonymousVariables(input_api
, output_api
))
1097 results
.extend(_CheckCygwinShell(input_api
, output_api
))
1098 results
.extend(_CheckUserActionUpdate(input_api
, output_api
))
1100 if any('PRESUBMIT.py' == f
.LocalPath() for f
in input_api
.AffectedFiles()):
1101 results
.extend(input_api
.canned_checks
.RunUnitTestsInDirectory(
1102 input_api
, output_api
,
1103 input_api
.PresubmitLocalPath(),
1104 whitelist
=[r
'^PRESUBMIT_test\.py$']))
1108 def _CheckSubversionConfig(input_api
, output_api
):
1109 """Verifies the subversion config file is correctly setup.
1111 Checks that autoprops are enabled, returns an error otherwise.
1113 join
= input_api
.os_path
.join
1114 if input_api
.platform
== 'win32':
1115 appdata
= input_api
.environ
.get('APPDATA', '')
1117 return [output_api
.PresubmitError('%APPDATA% is not configured.')]
1118 path
= join(appdata
, 'Subversion', 'config')
1120 home
= input_api
.environ
.get('HOME', '')
1122 return [output_api
.PresubmitError('$HOME is not configured.')]
1123 path
= join(home
, '.subversion', 'config')
1126 'Please look at http://dev.chromium.org/developers/coding-style to\n'
1127 'configure your subversion configuration file. This enables automatic\n'
1128 'properties to simplify the project maintenance.\n'
1129 'Pro-tip: just download and install\n'
1130 'http://src.chromium.org/viewvc/chrome/trunk/tools/build/slave/config\n')
1133 lines
= open(path
, 'r').read().splitlines()
1134 # Make sure auto-props is enabled and check for 2 Chromium standard
1136 if (not '*.cc = svn:eol-style=LF' in lines
or
1137 not '*.pdf = svn:mime-type=application/pdf' in lines
or
1138 not 'enable-auto-props = yes' in lines
):
1140 output_api
.PresubmitNotifyResult(
1141 'It looks like you have not configured your subversion config '
1142 'file or it is not up-to-date.\n' + error_msg
)
1144 except (OSError, IOError):
1146 output_api
.PresubmitNotifyResult(
1147 'Can\'t find your subversion config file.\n' + error_msg
)
1152 def _CheckAuthorizedAuthor(input_api
, output_api
):
1153 """For non-googler/chromites committers, verify the author's email address is
1156 # TODO(maruel): Add it to input_api?
1159 author
= input_api
.change
.author_email
1161 input_api
.logging
.info('No author, skipping AUTHOR check')
1163 authors_path
= input_api
.os_path
.join(
1164 input_api
.PresubmitLocalPath(), 'AUTHORS')
1166 input_api
.re
.match(r
'[^#]+\s+\<(.+?)\>\s*$', line
)
1167 for line
in open(authors_path
))
1168 valid_authors
= [item
.group(1).lower() for item
in valid_authors
if item
]
1169 if not any(fnmatch
.fnmatch(author
.lower(), valid
) for valid
in valid_authors
):
1170 input_api
.logging
.info('Valid authors are %s', ', '.join(valid_authors
))
1171 return [output_api
.PresubmitPromptWarning(
1172 ('%s is not in AUTHORS file. If you are a new contributor, please visit'
1174 'http://www.chromium.org/developers/contributing-code and read the '
1176 'If you are a chromite, verify the contributor signed the CLA.') %
1181 def _CheckPatchFiles(input_api
, output_api
):
1182 problems
= [f
.LocalPath() for f
in input_api
.AffectedFiles()
1183 if f
.LocalPath().endswith(('.orig', '.rej'))]
1185 return [output_api
.PresubmitError(
1186 "Don't commit .rej and .orig files.", problems
)]
1191 def _DidYouMeanOSMacro(bad_macro
):
1193 return {'A': 'OS_ANDROID',
1203 'W': 'OS_WIN'}[bad_macro
[3].upper()]
1208 def _CheckForInvalidOSMacrosInFile(input_api
, f
):
1209 """Check for sensible looking, totally invalid OS macros."""
1210 preprocessor_statement
= input_api
.re
.compile(r
'^\s*#')
1211 os_macro
= input_api
.re
.compile(r
'defined\((OS_[^)]+)\)')
1213 for lnum
, line
in f
.ChangedContents():
1214 if preprocessor_statement
.search(line
):
1215 for match
in os_macro
.finditer(line
):
1216 if not match
.group(1) in _VALID_OS_MACROS
:
1217 good
= _DidYouMeanOSMacro(match
.group(1))
1218 did_you_mean
= ' (did you mean %s?)' % good
if good
else ''
1219 results
.append(' %s:%d %s%s' % (f
.LocalPath(),
1226 def _CheckForInvalidOSMacros(input_api
, output_api
):
1227 """Check all affected files for invalid OS macros."""
1229 for f
in input_api
.AffectedFiles():
1230 if not f
.LocalPath().endswith(('.py', '.js', '.html', '.css')):
1231 bad_macros
.extend(_CheckForInvalidOSMacrosInFile(input_api
, f
))
1236 return [output_api
.PresubmitError(
1237 'Possibly invalid OS macro[s] found. Please fix your code\n'
1238 'or add your macro to src/PRESUBMIT.py.', bad_macros
)]
1241 def CheckChangeOnUpload(input_api
, output_api
):
1243 results
.extend(_CommonChecks(input_api
, output_api
))
1244 results
.extend(_CheckJavaStyle(input_api
, output_api
))
1248 def GetDefaultTryConfigs(bots
=None):
1249 """Returns a list of ('bot', set(['tests']), optionally filtered by [bots].
1251 To add tests to this list, they MUST be in the the corresponding master's
1252 gatekeeper config. For example, anything on master.chromium would be closed by
1253 tools/build/masters/master.chromium/master_gatekeeper_cfg.py.
1255 If 'bots' is specified, will only return configurations for bots in that list.
1261 'cacheinvalidation_unittests',
1264 'content_browsertests',
1265 'content_unittests',
1268 'interactive_ui_tests',
1274 'printing_unittests',
1278 # Broken in release.
1280 #'webkit_unit_tests',
1283 builders_and_tests
= {
1284 # TODO(maruel): Figure out a way to run 'sizes' where people can
1285 # effectively update the perf expectation correctly. This requires a
1286 # clobber=True build running 'sizes'. 'sizes' is not accurate with
1287 # incremental build. Reference:
1288 # http://chromium.org/developers/tree-sheriffs/perf-sheriffs.
1289 # TODO(maruel): An option would be to run 'sizes' but not count a failure
1290 # of this step as a try job failure.
1291 'android_aosp': ['compile'],
1292 'android_clang_dbg': ['slave_steps'],
1293 'android_dbg': ['slave_steps'],
1294 'cros_x86': ['defaulttests'],
1295 'ios_dbg_simulator': [
1298 'content_unittests',
1305 'ios_rel_device': ['compile'],
1306 'linux_asan': ['compile'],
1307 'mac_asan': ['compile'],
1308 #TODO(stip): Change the name of this builder to reflect that it's release.
1309 'linux_gtk': standard_tests
,
1310 'linux_chromeos_asan': ['compile'],
1311 'linux_chromium_chromeos_clang_dbg': ['defaulttests'],
1312 'linux_chromium_chromeos_rel': ['defaulttests'],
1313 'linux_chromium_compile_dbg': ['defaulttests'],
1314 'linux_chromium_rel': ['defaulttests'],
1315 'linux_chromium_clang_dbg': ['defaulttests'],
1316 'linux_nacl_sdk_build': ['compile'],
1318 'telemetry_perf_unittests',
1319 'telemetry_unittests',
1321 'mac_chromium_compile_dbg': ['defaulttests'],
1322 'mac_chromium_rel': ['defaulttests'],
1323 'mac_nacl_sdk_build': ['compile'],
1325 'telemetry_perf_unittests',
1326 'telemetry_unittests',
1329 'win_chromium_compile_dbg': ['defaulttests'],
1330 'win_nacl_sdk_build': ['compile'],
1331 'win_rel': standard_tests
+ [
1332 'app_list_unittests',
1336 'chrome_elf_unittests',
1337 'chromedriver_unittests',
1338 'components_unittests',
1339 'compositor_unittests',
1342 'google_apis_unittests',
1343 'installer_util_unittests',
1344 'mini_installer_test',
1346 'remoting_unittests',
1347 'sync_integration_tests',
1348 'telemetry_perf_unittests',
1349 'telemetry_unittests',
1357 swarm_enabled_builders
= (
1358 # http://crbug.com/354263
1364 swarm_enabled_tests
= (
1367 'interactive_ui_tests',
1372 for bot
in builders_and_tests
:
1373 if bot
in swarm_enabled_builders
:
1374 builders_and_tests
[bot
] = [x
+ '_swarm' if x
in swarm_enabled_tests
else x
1375 for x
in builders_and_tests
[bot
]]
1379 'tryserver.chromium': dict((bot
, set(builders_and_tests
[bot
]))
1384 'tryserver.chromium': dict(
1386 for bot
, tests
in builders_and_tests
.iteritems())
1390 def CheckChangeOnCommit(input_api
, output_api
):
1392 results
.extend(_CommonChecks(input_api
, output_api
))
1393 # TODO(thestig) temporarily disabled, doesn't work in third_party/
1394 #results.extend(input_api.canned_checks.CheckSvnModifiedDirectories(
1395 # input_api, output_api, sources))
1396 # Make sure the tree is 'open'.
1397 results
.extend(input_api
.canned_checks
.CheckTreeIsOpen(
1400 json_url
='http://chromium-status.appspot.com/current?format=json'))
1402 results
.extend(input_api
.canned_checks
.CheckChangeHasBugField(
1403 input_api
, output_api
))
1404 results
.extend(input_api
.canned_checks
.CheckChangeHasDescription(
1405 input_api
, output_api
))
1406 results
.extend(_CheckSubversionConfig(input_api
, output_api
))
1410 def GetPreferredTryMasters(project
, change
):
1411 files
= change
.LocalPaths()
1413 if not files
or all(re
.search(r
'[\\/]OWNERS$', f
) for f
in files
):
1416 if all(re
.search('\.(m|mm)$|(^|[/_])mac[/_.]', f
) for f
in files
):
1417 return GetDefaultTryConfigs([
1418 'mac_chromium_compile_dbg',
1421 if all(re
.search('(^|[/_])win[/_.]', f
) for f
in files
):
1422 return GetDefaultTryConfigs(['win', 'win_rel'])
1423 if all(re
.search('(^|[/_])android[/_.]', f
) for f
in files
):
1424 return GetDefaultTryConfigs([
1426 'android_clang_dbg',
1429 if all(re
.search('[/_]ios[/_.]', f
) for f
in files
):
1430 return GetDefaultTryConfigs(['ios_rel_device', 'ios_dbg_simulator'])
1433 'android_clang_dbg',
1435 'ios_dbg_simulator',
1437 'linux_chromium_chromeos_rel',
1438 'linux_chromium_clang_dbg',
1439 'linux_chromium_rel',
1440 'mac_chromium_compile_dbg',
1442 'win_chromium_compile_dbg',
1447 # Match things like path/aura/file.cc and path/file_aura.cc.
1448 # Same for chromeos.
1449 if any(re
.search('[/_](aura|chromeos)', f
) for f
in files
):
1451 'linux_chromeos_asan',
1452 'linux_chromium_chromeos_clang_dbg'
1455 # If there are gyp changes to base, build, or chromeos, run a full cros build
1456 # in addition to the shorter linux_chromeos build. Changes to high level gyp
1457 # files have a much higher chance of breaking the cros build, which is
1458 # differnt from the linux_chromeos build that most chrome developers test
1460 if any(re
.search('^(base|build|chromeos).*\.gypi?$', f
) for f
in files
):
1461 builders
.extend(['cros_x86'])
1463 # The AOSP bot doesn't build the chrome/ layer, so ignore any changes to it
1464 # unless they're .gyp(i) files as changes to those files can break the gyp
1466 if (not all(re
.search('^chrome', f
) for f
in files
) or
1467 any(re
.search('\.gypi?$', f
) for f
in files
)):
1468 builders
.extend(['android_aosp'])
1470 return GetDefaultTryConfigs(builders
)