Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(423)

Side by Side Diff: PRESUBMIT.py

Issue 518863002: Support both \ and / as path separators in regexes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Top-level presubmit script for Chromium. 5 """Top-level presubmit script for Chromium.
6 6
7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
8 for more details about the presubmit API built into gcl. 8 for more details about the presubmit API built into gcl.
9 """ 9 """
10 10
(...skipping 24 matching lines...) Expand all
35 r"^content[\\\/]shell[\\\/]tools[\\\/]plugin[\\\/].*", 35 r"^content[\\\/]shell[\\\/]tools[\\\/]plugin[\\\/].*",
36 ) 36 )
37 37
38 # Fragment of a regular expression that matches C++ and Objective-C++ 38 # Fragment of a regular expression that matches C++ and Objective-C++
39 # implementation files. 39 # implementation files.
40 _IMPLEMENTATION_EXTENSIONS = r'\.(cc|cpp|cxx|mm)$' 40 _IMPLEMENTATION_EXTENSIONS = r'\.(cc|cpp|cxx|mm)$'
41 41
42 # Regular expression that matches code only used for test binaries 42 # Regular expression that matches code only used for test binaries
43 # (best effort). 43 # (best effort).
44 _TEST_CODE_EXCLUDED_PATHS = ( 44 _TEST_CODE_EXCLUDED_PATHS = (
45 r'.*[/\\](fake_|test_|mock_).+%s' % _IMPLEMENTATION_EXTENSIONS, 45 r'.*[\\\/](fake_|test_|mock_).+%s' % _IMPLEMENTATION_EXTENSIONS,
46 r'.+_test_(base|support|util)%s' % _IMPLEMENTATION_EXTENSIONS, 46 r'.+_test_(base|support|util)%s' % _IMPLEMENTATION_EXTENSIONS,
47 r'.+_(api|browser|kif|perf|pixel|unit|ui)?test(_[a-z]+)?%s' % 47 r'.+_(api|browser|kif|perf|pixel|unit|ui)?test(_[a-z]+)?%s' %
48 _IMPLEMENTATION_EXTENSIONS, 48 _IMPLEMENTATION_EXTENSIONS,
49 r'.+profile_sync_service_harness%s' % _IMPLEMENTATION_EXTENSIONS, 49 r'.+profile_sync_service_harness%s' % _IMPLEMENTATION_EXTENSIONS,
50 r'.*[/\\](test|tool(s)?)[/\\].*', 50 r'.*[\\\/](test|tool(s)?)[\\\/].*',
51 # content_shell is used for running layout tests. 51 # content_shell is used for running layout tests.
52 r'content[/\\]shell[/\\].*', 52 r'content[\\\/]shell[\\\/].*',
53 # At request of folks maintaining this folder. 53 # At request of folks maintaining this folder.
54 r'chrome[/\\]browser[/\\]automation[/\\].*', 54 r'chrome[\\\/]browser[\\\/]automation[\\\/].*',
55 # Non-production example code. 55 # Non-production example code.
56 r'mojo[/\\]examples[/\\].*', 56 r'mojo[\\\/]examples[\\\/].*',
57 # Launcher for running iOS tests on the simulator. 57 # Launcher for running iOS tests on the simulator.
58 r'testing[/\\]iossim[/\\]iossim\.mm$', 58 r'testing[\\\/]iossim[\\\/]iossim\.mm$',
59 ) 59 )
60 60
61 _TEST_ONLY_WARNING = ( 61 _TEST_ONLY_WARNING = (
62 'You might be calling functions intended only for testing from\n' 62 'You might be calling functions intended only for testing from\n'
63 'production code. It is OK to ignore this warning if you know what\n' 63 'production code. It is OK to ignore this warning if you know what\n'
64 'you are doing, as the heuristics used to detect the situation are\n' 64 'you are doing, as the heuristics used to detect the situation are\n'
65 'not perfect. The commit queue will not block on this warning.') 65 'not perfect. The commit queue will not block on this warning.')
66 66
67 67
68 _INCLUDE_ORDER_WARNING = ( 68 _INCLUDE_ORDER_WARNING = (
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 ), 238 ),
239 ), 239 ),
240 ( 240 (
241 r'/v8::Extension\(', 241 r'/v8::Extension\(',
242 ( 242 (
243 'Do not introduce new v8::Extensions into the code base, use', 243 'Do not introduce new v8::Extensions into the code base, use',
244 'gin::Wrappable instead. See http://crbug.com/334679', 244 'gin::Wrappable instead. See http://crbug.com/334679',
245 ), 245 ),
246 True, 246 True,
247 ( 247 (
248 r'extensions[/\\]renderer[/\\]safe_builtins\.*', 248 r'extensions[\\\/]renderer[\\\/]safe_builtins\.*',
249 ), 249 ),
250 ), 250 ),
251 ) 251 )
252 252
253 253
254 _VALID_OS_MACROS = ( 254 _VALID_OS_MACROS = (
255 # Please keep sorted. 255 # Please keep sorted.
256 'OS_ANDROID', 256 'OS_ANDROID',
257 'OS_ANDROID_HOST', 257 'OS_ANDROID_HOST',
258 'OS_BSD', 258 'OS_BSD',
(...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after
1111 1111
1112 1112
1113 def _CheckParseErrors(input_api, output_api): 1113 def _CheckParseErrors(input_api, output_api):
1114 """Check that IDL and JSON files do not contain syntax errors.""" 1114 """Check that IDL and JSON files do not contain syntax errors."""
1115 actions = { 1115 actions = {
1116 '.idl': _GetIDLParseError, 1116 '.idl': _GetIDLParseError,
1117 '.json': _GetJSONParseError, 1117 '.json': _GetJSONParseError,
1118 } 1118 }
1119 # These paths contain test data and other known invalid JSON files. 1119 # These paths contain test data and other known invalid JSON files.
1120 excluded_patterns = [ 1120 excluded_patterns = [
1121 'test/data/', 1121 r'test[\\\/]data[\\\/]',
1122 '^components/policy/resources/policy_templates.json$', 1122 r'^components[\\\/]policy[\\\/]resources[\\\/]policy_templates\.json$',
1123 ] 1123 ]
1124 # Most JSON files are preprocessed and support comments, but these do not. 1124 # Most JSON files are preprocessed and support comments, but these do not.
1125 json_no_comments_patterns = [ 1125 json_no_comments_patterns = [
1126 '^testing/', 1126 r'^testing[\\\/]',
1127 ] 1127 ]
1128 # Only run IDL checker on files in these directories. 1128 # Only run IDL checker on files in these directories.
1129 idl_included_patterns = [ 1129 idl_included_patterns = [
1130 '^chrome/common/extensions/api/', 1130 r'^chrome[\\\/]common[\\\/]extensions[\\\/]api[\\\/]',
1131 '^extensions/common/api/', 1131 r'^extensions[\\\/]common[\\\/]api[\\\/]',
1132 ] 1132 ]
1133 1133
1134 def get_action(affected_file): 1134 def get_action(affected_file):
1135 filename = affected_file.LocalPath() 1135 filename = affected_file.LocalPath()
1136 return actions.get(input_api.os_path.splitext(filename)[1]) 1136 return actions.get(input_api.os_path.splitext(filename)[1])
1137 1137
1138 def MatchesFile(patterns, path): 1138 def MatchesFile(patterns, path):
1139 for pattern in patterns: 1139 for pattern in patterns:
1140 if input_api.re.search(pattern, path): 1140 if input_api.re.search(pattern, path):
1141 return True 1141 return True
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
1519 results.extend(input_api.canned_checks.CheckChangeHasBugField( 1519 results.extend(input_api.canned_checks.CheckChangeHasBugField(
1520 input_api, output_api)) 1520 input_api, output_api))
1521 results.extend(input_api.canned_checks.CheckChangeHasDescription( 1521 results.extend(input_api.canned_checks.CheckChangeHasDescription(
1522 input_api, output_api)) 1522 input_api, output_api))
1523 return results 1523 return results
1524 1524
1525 1525
1526 def GetPreferredTryMasters(project, change): 1526 def GetPreferredTryMasters(project, change):
1527 files = change.LocalPaths() 1527 files = change.LocalPaths()
1528 1528
1529 if not files or all(re.search(r'[\\/]OWNERS$', f) for f in files): 1529 if not files or all(re.search(r'[\\\/]OWNERS$', f) for f in files):
1530 return {} 1530 return {}
1531 1531
1532 if all(re.search('\.(m|mm)$|(^|[/_])mac[/_.]', f) for f in files): 1532 if all(re.search(r'\.(m|mm)$|(^|[\\\/_])mac[\\\/_.]', f) for f in files):
1533 return GetDefaultTryConfigs([ 1533 return GetDefaultTryConfigs([
1534 'mac_chromium_compile_dbg', 1534 'mac_chromium_compile_dbg',
1535 'mac_chromium_rel_swarming', 1535 'mac_chromium_rel_swarming',
1536 ]) 1536 ])
1537 if all(re.search('(^|[/_])win[/_.]', f) for f in files): 1537 if all(re.search('(^|[/_])win[/_.]', f) for f in files):
1538 return GetDefaultTryConfigs([ 1538 return GetDefaultTryConfigs([
1539 'win_chromium_dbg', 1539 'win_chromium_dbg',
1540 'win_chromium_rel_swarming', 1540 'win_chromium_rel_swarming',
1541 ]) 1541 ])
1542 if all(re.search('(^|[/_])android[/_.]', f) for f in files): 1542 if all(re.search(r'(^|[\\\/_])android[\\\/_.]', f) for f in files):
1543 return GetDefaultTryConfigs([ 1543 return GetDefaultTryConfigs([
1544 'android_aosp', 1544 'android_aosp',
1545 'android_clang_dbg', 1545 'android_clang_dbg',
1546 'android_dbg_tests_recipe', 1546 'android_dbg_tests_recipe',
1547 ]) 1547 ])
1548 if all(re.search('[/_]ios[/_.]', f) for f in files): 1548 if all(re.search(r'[\\\/_]ios[\\\/_.]', f) for f in files):
1549 return GetDefaultTryConfigs(['ios_rel_device', 'ios_dbg_simulator']) 1549 return GetDefaultTryConfigs(['ios_rel_device', 'ios_dbg_simulator'])
1550 1550
1551 builders = [ 1551 builders = [
1552 'android_chromium_gn_compile_rel', 1552 'android_chromium_gn_compile_rel',
1553 'android_clang_dbg', 1553 'android_clang_dbg',
1554 'android_dbg_tests_recipe', 1554 'android_dbg_tests_recipe',
1555 'ios_dbg_simulator', 1555 'ios_dbg_simulator',
1556 'ios_rel_device', 1556 'ios_rel_device',
1557 'linux_chromium_chromeos_rel_swarming', 1557 'linux_chromium_chromeos_rel_swarming',
1558 'linux_chromium_clang_dbg', 1558 'linux_chromium_clang_dbg',
1559 'linux_chromium_gn_rel', 1559 'linux_chromium_gn_rel',
1560 'linux_chromium_rel_swarming', 1560 'linux_chromium_rel_swarming',
1561 'linux_gpu', 1561 'linux_gpu',
1562 'mac_chromium_compile_dbg', 1562 'mac_chromium_compile_dbg',
1563 'mac_chromium_rel_swarming', 1563 'mac_chromium_rel_swarming',
1564 'mac_gpu', 1564 'mac_gpu',
1565 'win_chromium_compile_dbg', 1565 'win_chromium_compile_dbg',
1566 'win_chromium_rel_swarming', 1566 'win_chromium_rel_swarming',
1567 'win_chromium_x64_rel_swarming', 1567 'win_chromium_x64_rel_swarming',
1568 'win_gpu', 1568 'win_gpu',
1569 ] 1569 ]
1570 1570
1571 # Match things like path/aura/file.cc and path/file_aura.cc. 1571 # Match things like path/aura/file.cc and path/file_aura.cc.
1572 # Same for chromeos. 1572 # Same for chromeos.
1573 if any(re.search('[/_](aura|chromeos)', f) for f in files): 1573 if any(re.search(r'[\\\/_](aura|chromeos)', f) for f in files):
1574 builders.extend([ 1574 builders.extend([
1575 'linux_chromeos_asan', 1575 'linux_chromeos_asan',
1576 'linux_chromium_chromeos_clang_dbg' 1576 'linux_chromium_chromeos_clang_dbg'
1577 ]) 1577 ])
1578 1578
1579 # If there are gyp changes to base, build, or chromeos, run a full cros build 1579 # If there are gyp changes to base, build, or chromeos, run a full cros build
1580 # in addition to the shorter linux_chromeos build. Changes to high level gyp 1580 # in addition to the shorter linux_chromeos build. Changes to high level gyp
1581 # files have a much higher chance of breaking the cros build, which is 1581 # files have a much higher chance of breaking the cros build, which is
1582 # differnt from the linux_chromeos build that most chrome developers test 1582 # differnt from the linux_chromeos build that most chrome developers test
1583 # with. 1583 # with.
1584 if any(re.search('^(base|build|chromeos).*\.gypi?$', f) for f in files): 1584 if any(re.search('^(base|build|chromeos).*\.gypi?$', f) for f in files):
1585 builders.extend(['cros_x86']) 1585 builders.extend(['cros_x86'])
1586 1586
1587 # The AOSP bot doesn't build the chrome/ layer, so ignore any changes to it 1587 # The AOSP bot doesn't build the chrome/ layer, so ignore any changes to it
1588 # unless they're .gyp(i) files as changes to those files can break the gyp 1588 # unless they're .gyp(i) files as changes to those files can break the gyp
1589 # step on that bot. 1589 # step on that bot.
1590 if (not all(re.search('^chrome', f) for f in files) or 1590 if (not all(re.search('^chrome', f) for f in files) or
1591 any(re.search('\.gypi?$', f) for f in files)): 1591 any(re.search('\.gypi?$', f) for f in files)):
1592 builders.extend(['android_aosp']) 1592 builders.extend(['android_aosp'])
1593 1593
1594 return GetDefaultTryConfigs(builders) 1594 return GetDefaultTryConfigs(builders)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698