blob: 2c07248b8ae82a935b7b7d882e9a665620c91ce5 [file] [log] [blame]
[email protected]a18130a2012-01-03 17:52:081# Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]ca8d1982009-02-19 16:33:122# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5"""Top-level presubmit script for Chromium.
6
[email protected]f1293792009-07-31 18:09:567See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
[email protected]50d7d721e2009-11-15 17:56:188for more details about the presubmit API built into gcl.
[email protected]ca8d1982009-02-19 16:33:129"""
10
[email protected]eea609a2011-11-18 13:10:1211
[email protected]9d16ad12011-12-14 20:49:4712import re
13
14
[email protected]379e7dd2010-01-28 17:39:2115_EXCLUDED_PATHS = (
[email protected]3e4eb112011-01-18 03:29:5416 r"^breakpad[\\\/].*",
[email protected]a18130a2012-01-03 17:52:0817 r"^native_client_sdk[\\\/].*",
18 r"^net[\\\/]tools[\\\/]spdyshark[\\\/].*",
[email protected]3e4eb112011-01-18 03:29:5419 r"^skia[\\\/].*",
20 r"^v8[\\\/].*",
21 r".*MakeFile$",
[email protected]1084ccc2012-03-14 03:22:5322 r".+_autogen\.h$",
[email protected]4306417642009-06-11 00:33:4023)
[email protected]ca8d1982009-02-19 16:33:1224
[email protected]ca8d1982009-02-19 16:33:1225
[email protected]eea609a2011-11-18 13:10:1226_TEST_ONLY_WARNING = (
27 'You might be calling functions intended only for testing from\n'
28 'production code. It is OK to ignore this warning if you know what\n'
29 'you are doing, as the heuristics used to detect the situation are\n'
30 'not perfect. The commit queue will not block on this warning.\n'
31 'Email [email protected] if you have questions.')
32
33
[email protected]127f18ec2012-06-16 05:05:5934_BANNED_OBJC_FUNCTIONS = (
35 (
36 'addTrackingRect:',
[email protected]23e6cbc2012-06-16 18:51:2037 (
38 'The use of -[NSView addTrackingRect:owner:userData:assumeInside:] is'
[email protected]127f18ec2012-06-16 05:05:5939 'prohibited. Please use CrTrackingArea instead.',
40 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
41 ),
42 False,
43 ),
44 (
45 'NSTrackingArea',
[email protected]23e6cbc2012-06-16 18:51:2046 (
47 'The use of NSTrackingAreas is prohibited. Please use CrTrackingArea',
[email protected]127f18ec2012-06-16 05:05:5948 'instead.',
49 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
50 ),
51 False,
52 ),
53 (
54 'convertPointFromBase:',
[email protected]23e6cbc2012-06-16 18:51:2055 (
56 'The use of -[NSView convertPointFromBase:] is almost certainly wrong.',
[email protected]127f18ec2012-06-16 05:05:5957 'Please use |convertPoint:(point) fromView:nil| instead.',
58 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
59 ),
60 True,
61 ),
62 (
63 'convertPointToBase:',
[email protected]23e6cbc2012-06-16 18:51:2064 (
65 'The use of -[NSView convertPointToBase:] is almost certainly wrong.',
[email protected]127f18ec2012-06-16 05:05:5966 'Please use |convertPoint:(point) toView:nil| instead.',
67 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
68 ),
69 True,
70 ),
71 (
72 'convertRectFromBase:',
[email protected]23e6cbc2012-06-16 18:51:2073 (
74 'The use of -[NSView convertRectFromBase:] is almost certainly wrong.',
[email protected]127f18ec2012-06-16 05:05:5975 'Please use |convertRect:(point) fromView:nil| instead.',
76 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
77 ),
78 True,
79 ),
80 (
81 'convertRectToBase:',
[email protected]23e6cbc2012-06-16 18:51:2082 (
83 'The use of -[NSView convertRectToBase:] is almost certainly wrong.',
[email protected]127f18ec2012-06-16 05:05:5984 'Please use |convertRect:(point) toView:nil| instead.',
85 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
86 ),
87 True,
88 ),
89 (
90 'convertSizeFromBase:',
[email protected]23e6cbc2012-06-16 18:51:2091 (
92 'The use of -[NSView convertSizeFromBase:] is almost certainly wrong.',
[email protected]127f18ec2012-06-16 05:05:5993 'Please use |convertSize:(point) fromView:nil| instead.',
94 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
95 ),
96 True,
97 ),
98 (
99 'convertSizeToBase:',
[email protected]23e6cbc2012-06-16 18:51:20100 (
101 'The use of -[NSView convertSizeToBase:] is almost certainly wrong.',
[email protected]127f18ec2012-06-16 05:05:59102 'Please use |convertSize:(point) toView:nil| instead.',
103 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
104 ),
105 True,
106 ),
107)
108
109
110_BANNED_CPP_FUNCTIONS = (
[email protected]23e6cbc2012-06-16 18:51:20111 # Make sure that gtest's FRIEND_TEST() macro is not used; the
112 # FRIEND_TEST_ALL_PREFIXES() macro from base/gtest_prod_util.h should be
113 # used instead since that allows for FLAKY_, FAILS_ and DISABLED_ prefixes.
114 (
115 'FRIEND_TEST(',
116 (
[email protected]e3c945502012-06-26 20:01:49117 'Chromium code should not use gtest\'s FRIEND_TEST() macro. Include',
[email protected]23e6cbc2012-06-16 18:51:20118 'base/gtest_prod_util.h and use FRIEND_TEST_ALL_PREFIXES() instead.',
119 ),
120 False,
121 ),
122 (
123 'ScopedAllowIO',
124 (
[email protected]e3c945502012-06-26 20:01:49125 'New code should not use ScopedAllowIO. Post a task to the blocking',
126 'pool or the FILE thread instead.',
[email protected]23e6cbc2012-06-16 18:51:20127 ),
[email protected]e3c945502012-06-26 20:01:49128 True,
[email protected]23e6cbc2012-06-16 18:51:20129 ),
130 (
131 'FilePathWatcher::Delegate',
132 (
[email protected]e3c945502012-06-26 20:01:49133 'New code should not use FilePathWatcher::Delegate. Use the callback',
[email protected]23e6cbc2012-06-16 18:51:20134 'interface instead.',
135 ),
136 False,
137 ),
[email protected]e3c945502012-06-26 20:01:49138 (
139 'browser::FindLastActiveWithProfile',
140 (
141 'This function is deprecated and we\'re working on removing it. Pass',
142 'more context to get a Browser*, like a WebContents, window, or session',
143 'id. Talk to ben@ or jam@ for more information.',
144 ),
145 True,
146 ),
147 (
148 'browser::FindBrowserWithProfile',
149 (
150 'This function is deprecated and we\'re working on removing it. Pass',
151 'more context to get a Browser*, like a WebContents, window, or session',
152 'id. Talk to ben@ or jam@ for more information.',
153 ),
154 True,
155 ),
156 (
157 'browser::FindAnyBrowser',
158 (
159 'This function is deprecated and we\'re working on removing it. Pass',
160 'more context to get a Browser*, like a WebContents, window, or session',
161 'id. Talk to ben@ or jam@ for more information.',
162 ),
163 True,
164 ),
165 (
166 'browser::FindOrCreateTabbedBrowser',
167 (
168 'This function is deprecated and we\'re working on removing it. Pass',
169 'more context to get a Browser*, like a WebContents, window, or session',
170 'id. Talk to ben@ or jam@ for more information.',
171 ),
172 True,
173 ),
174 (
175 'browser::FindTabbedBrowser',
176 (
177 'This function is deprecated and we\'re working on removing it. Pass',
178 'more context to get a Browser*, like a WebContents, window, or session',
179 'id. Talk to ben@ or jam@ for more information.',
180 ),
181 True,
182 ),
[email protected]127f18ec2012-06-16 05:05:59183)
184
185
[email protected]eea609a2011-11-18 13:10:12186
[email protected]55459852011-08-10 15:17:19187def _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api):
188 """Attempts to prevent use of functions intended only for testing in
189 non-testing code. For now this is just a best-effort implementation
190 that ignores header files and may have some false positives. A
191 better implementation would probably need a proper C++ parser.
192 """
193 # We only scan .cc files and the like, as the declaration of
194 # for-testing functions in header files are hard to distinguish from
195 # calls to such functions without a proper C++ parser.
[email protected]403bfbc92012-06-11 23:30:09196 platform_specifiers = r'(_(android|chromeos|gtk|mac|posix|win))?'
[email protected]55459852011-08-10 15:17:19197 source_extensions = r'\.(cc|cpp|cxx|mm)$'
198 file_inclusion_pattern = r'.+%s' % source_extensions
[email protected]19e77fd2011-10-20 05:24:05199 file_exclusion_patterns = (
[email protected]e21ce382012-01-04 18:48:25200 r'.*[/\\](test_|mock_).+%s' % source_extensions,
[email protected]c762d252012-02-28 02:07:24201 r'.+_test_(base|support|util)%s' % source_extensions,
[email protected]403bfbc92012-06-11 23:30:09202 r'.+_(api|browser|perf|unit|ui)?test%s%s' % (platform_specifiers,
203 source_extensions),
[email protected]19e77fd2011-10-20 05:24:05204 r'.+profile_sync_service_harness%s' % source_extensions,
205 )
206 path_exclusion_patterns = (
207 r'.*[/\\](test|tool(s)?)[/\\].*',
208 # At request of folks maintaining this folder.
209 r'chrome[/\\]browser[/\\]automation[/\\].*',
210 )
[email protected]55459852011-08-10 15:17:19211
212 base_function_pattern = r'ForTest(ing)?|for_test(ing)?'
213 inclusion_pattern = input_api.re.compile(r'(%s)\s*\(' % base_function_pattern)
214 exclusion_pattern = input_api.re.compile(
215 r'::[A-Za-z0-9_]+(%s)|(%s)[^;]+\{' % (
216 base_function_pattern, base_function_pattern))
217
218 def FilterFile(affected_file):
[email protected]19e77fd2011-10-20 05:24:05219 black_list = (file_exclusion_patterns + path_exclusion_patterns +
[email protected]3afb12a42011-08-15 13:48:33220 _EXCLUDED_PATHS + input_api.DEFAULT_BLACK_LIST)
[email protected]55459852011-08-10 15:17:19221 return input_api.FilterSourceFile(
222 affected_file,
223 white_list=(file_inclusion_pattern, ),
224 black_list=black_list)
225
226 problems = []
227 for f in input_api.AffectedSourceFiles(FilterFile):
228 local_path = f.LocalPath()
229 lines = input_api.ReadFile(f).splitlines()
230 line_number = 0
231 for line in lines:
232 if (inclusion_pattern.search(line) and
233 not exclusion_pattern.search(line)):
234 problems.append(
235 '%s:%d\n %s' % (local_path, line_number, line.strip()))
236 line_number += 1
237
238 if problems:
[email protected]eea609a2011-11-18 13:10:12239 if not input_api.is_committing:
240 return [output_api.PresubmitPromptWarning(_TEST_ONLY_WARNING, problems)]
241 else:
242 # We don't warn on commit, to avoid stopping commits going through CQ.
243 return [output_api.PresubmitNotifyResult(_TEST_ONLY_WARNING, problems)]
[email protected]55459852011-08-10 15:17:19244 else:
245 return []
246
247
[email protected]10689ca2011-09-02 02:31:54248def _CheckNoIOStreamInHeaders(input_api, output_api):
249 """Checks to make sure no .h files include <iostream>."""
250 files = []
251 pattern = input_api.re.compile(r'^#include\s*<iostream>',
252 input_api.re.MULTILINE)
253 for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile):
254 if not f.LocalPath().endswith('.h'):
255 continue
256 contents = input_api.ReadFile(f)
257 if pattern.search(contents):
258 files.append(f)
259
260 if len(files):
261 return [ output_api.PresubmitError(
262 'Do not #include <iostream> in header files, since it inserts static ' +
263 'initialization into every file including the header. Instead, ' +
264 '#include <ostream>. See http://crbug.com/94794',
265 files) ]
266 return []
267
268
[email protected]72df4e782012-06-21 16:28:18269def _CheckNoUNIT_TESTInSourceFiles(input_api, output_api):
270 """Checks to make sure no source files use UNIT_TEST"""
271 problems = []
272 for f in input_api.AffectedFiles():
273 if (not f.LocalPath().endswith(('.cc', '.mm'))):
274 continue
275
276 for line_num, line in f.ChangedContents():
277 if 'UNIT_TEST' in line:
278 problems.append(' %s:%d' % (f.LocalPath(), line_num))
279
280 if not problems:
281 return []
282 return [output_api.PresubmitPromptWarning('UNIT_TEST is only for headers.\n' +
283 '\n'.join(problems))]
284
285
[email protected]8ea5d4b2011-09-13 21:49:22286def _CheckNoNewWStrings(input_api, output_api):
287 """Checks to make sure we don't introduce use of wstrings."""
[email protected]55463aa62011-10-12 00:48:27288 problems = []
[email protected]8ea5d4b2011-09-13 21:49:22289 for f in input_api.AffectedFiles():
[email protected]b5c24292011-11-28 14:38:20290 if (not f.LocalPath().endswith(('.cc', '.h')) or
291 f.LocalPath().endswith('test.cc')):
292 continue
[email protected]8ea5d4b2011-09-13 21:49:22293
[email protected]b5c24292011-11-28 14:38:20294 for line_num, line in f.ChangedContents():
[email protected]8ea5d4b2011-09-13 21:49:22295 if 'wstring' in line:
[email protected]55463aa62011-10-12 00:48:27296 problems.append(' %s:%d' % (f.LocalPath(), line_num))
[email protected]8ea5d4b2011-09-13 21:49:22297
[email protected]55463aa62011-10-12 00:48:27298 if not problems:
299 return []
300 return [output_api.PresubmitPromptWarning('New code should not use wstrings.'
301 ' If you are calling an API that accepts a wstring, fix the API.\n' +
302 '\n'.join(problems))]
[email protected]8ea5d4b2011-09-13 21:49:22303
304
[email protected]2a8ac9c2011-10-19 17:20:44305def _CheckNoDEPSGIT(input_api, output_api):
306 """Make sure .DEPS.git is never modified manually."""
307 if any(f.LocalPath().endswith('.DEPS.git') for f in
308 input_api.AffectedFiles()):
309 return [output_api.PresubmitError(
310 'Never commit changes to .DEPS.git. This file is maintained by an\n'
311 'automated system based on what\'s in DEPS and your changes will be\n'
312 'overwritten.\n'
313 'See http://code.google.com/p/chromium/wiki/UsingNewGit#Rolling_DEPS\n'
314 'for more information')]
315 return []
316
317
[email protected]127f18ec2012-06-16 05:05:59318def _CheckNoBannedFunctions(input_api, output_api):
319 """Make sure that banned functions are not used."""
320 warnings = []
321 errors = []
322
323 file_filter = lambda f: f.LocalPath().endswith(('.mm', '.m', '.h'))
324 for f in input_api.AffectedFiles(file_filter=file_filter):
325 for line_num, line in f.ChangedContents():
326 for func_name, message, error in _BANNED_OBJC_FUNCTIONS:
327 if func_name in line:
328 problems = warnings;
329 if error:
330 problems = errors;
331 problems.append(' %s:%d:' % (f.LocalPath(), line_num))
332 for message_line in message:
333 problems.append(' %s' % message_line)
334
335 file_filter = lambda f: f.LocalPath().endswith(('.cc', '.mm', '.h'))
336 for f in input_api.AffectedFiles(file_filter=file_filter):
337 for line_num, line in f.ChangedContents():
338 for func_name, message, error in _BANNED_CPP_FUNCTIONS:
339 if func_name in line:
340 problems = warnings;
341 if error:
342 problems = errors;
343 problems.append(' %s:%d:' % (f.LocalPath(), line_num))
344 for message_line in message:
345 problems.append(' %s' % message_line)
346
347 result = []
348 if (warnings):
349 result.append(output_api.PresubmitPromptWarning(
350 'Banned functions were used.\n' + '\n'.join(warnings)))
351 if (errors):
352 result.append(output_api.PresubmitError(
353 'Banned functions were used.\n' + '\n'.join(errors)))
354 return result
355
356
357
[email protected]22c9bd72011-03-27 16:47:39358def _CommonChecks(input_api, output_api):
359 """Checks common to both upload and commit."""
360 results = []
361 results.extend(input_api.canned_checks.PanProjectChecks(
362 input_api, output_api, excluded_paths=_EXCLUDED_PATHS))
[email protected]66daa702011-05-28 14:41:46363 results.extend(_CheckAuthorizedAuthor(input_api, output_api))
[email protected]55459852011-08-10 15:17:19364 results.extend(
365 _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api))
[email protected]10689ca2011-09-02 02:31:54366 results.extend(_CheckNoIOStreamInHeaders(input_api, output_api))
[email protected]72df4e782012-06-21 16:28:18367 results.extend(_CheckNoUNIT_TESTInSourceFiles(input_api, output_api))
[email protected]8ea5d4b2011-09-13 21:49:22368 results.extend(_CheckNoNewWStrings(input_api, output_api))
[email protected]2a8ac9c2011-10-19 17:20:44369 results.extend(_CheckNoDEPSGIT(input_api, output_api))
[email protected]127f18ec2012-06-16 05:05:59370 results.extend(_CheckNoBannedFunctions(input_api, output_api))
[email protected]22c9bd72011-03-27 16:47:39371 return results
[email protected]1f7b4172010-01-28 01:17:34372
[email protected]b337cb5b2011-01-23 21:24:05373
374def _CheckSubversionConfig(input_api, output_api):
375 """Verifies the subversion config file is correctly setup.
376
377 Checks that autoprops are enabled, returns an error otherwise.
378 """
379 join = input_api.os_path.join
380 if input_api.platform == 'win32':
381 appdata = input_api.environ.get('APPDATA', '')
382 if not appdata:
383 return [output_api.PresubmitError('%APPDATA% is not configured.')]
384 path = join(appdata, 'Subversion', 'config')
385 else:
386 home = input_api.environ.get('HOME', '')
387 if not home:
388 return [output_api.PresubmitError('$HOME is not configured.')]
389 path = join(home, '.subversion', 'config')
390
391 error_msg = (
392 'Please look at http://dev.chromium.org/developers/coding-style to\n'
393 'configure your subversion configuration file. This enables automatic\n'
[email protected]c6a3c10b2011-01-24 16:14:20394 'properties to simplify the project maintenance.\n'
395 'Pro-tip: just download and install\n'
396 'http://src.chromium.org/viewvc/chrome/trunk/tools/build/slave/config\n')
[email protected]b337cb5b2011-01-23 21:24:05397
398 try:
399 lines = open(path, 'r').read().splitlines()
400 # Make sure auto-props is enabled and check for 2 Chromium standard
401 # auto-prop.
402 if (not '*.cc = svn:eol-style=LF' in lines or
403 not '*.pdf = svn:mime-type=application/pdf' in lines or
404 not 'enable-auto-props = yes' in lines):
405 return [
[email protected]79ed7e62011-02-21 21:08:53406 output_api.PresubmitNotifyResult(
[email protected]b337cb5b2011-01-23 21:24:05407 'It looks like you have not configured your subversion config '
[email protected]b5359c02011-02-01 20:29:56408 'file or it is not up-to-date.\n' + error_msg)
[email protected]b337cb5b2011-01-23 21:24:05409 ]
410 except (OSError, IOError):
411 return [
[email protected]79ed7e62011-02-21 21:08:53412 output_api.PresubmitNotifyResult(
[email protected]b337cb5b2011-01-23 21:24:05413 'Can\'t find your subversion config file.\n' + error_msg)
414 ]
415 return []
416
417
[email protected]66daa702011-05-28 14:41:46418def _CheckAuthorizedAuthor(input_api, output_api):
419 """For non-googler/chromites committers, verify the author's email address is
420 in AUTHORS.
421 """
[email protected]9bb9cb82011-06-13 20:43:01422 # TODO(maruel): Add it to input_api?
423 import fnmatch
424
[email protected]66daa702011-05-28 14:41:46425 author = input_api.change.author_email
[email protected]9bb9cb82011-06-13 20:43:01426 if not author:
427 input_api.logging.info('No author, skipping AUTHOR check')
[email protected]66daa702011-05-28 14:41:46428 return []
[email protected]c99663292011-05-31 19:46:08429 authors_path = input_api.os_path.join(
[email protected]66daa702011-05-28 14:41:46430 input_api.PresubmitLocalPath(), 'AUTHORS')
431 valid_authors = (
432 input_api.re.match(r'[^#]+\s+\<(.+?)\>\s*$', line)
433 for line in open(authors_path))
[email protected]ac54b132011-06-06 18:11:18434 valid_authors = [item.group(1).lower() for item in valid_authors if item]
[email protected]9bb9cb82011-06-13 20:43:01435 if input_api.verbose:
436 print 'Valid authors are %s' % ', '.join(valid_authors)
[email protected]d8b50be2011-06-15 14:19:44437 if not any(fnmatch.fnmatch(author.lower(), valid) for valid in valid_authors):
[email protected]66daa702011-05-28 14:41:46438 return [output_api.PresubmitPromptWarning(
439 ('%s is not in AUTHORS file. If you are a new contributor, please visit'
440 '\n'
441 'http://www.chromium.org/developers/contributing-code and read the '
442 '"Legal" section\n'
443 'If you are a chromite, verify the contributor signed the CLA.') %
444 author)]
445 return []
446
447
[email protected]1f7b4172010-01-28 01:17:34448def CheckChangeOnUpload(input_api, output_api):
449 results = []
450 results.extend(_CommonChecks(input_api, output_api))
[email protected]fe5f57c52009-06-05 14:25:54451 return results
[email protected]ca8d1982009-02-19 16:33:12452
453
454def CheckChangeOnCommit(input_api, output_api):
[email protected]fe5f57c52009-06-05 14:25:54455 results = []
[email protected]1f7b4172010-01-28 01:17:34456 results.extend(_CommonChecks(input_api, output_api))
[email protected]dd805fe2009-10-01 08:11:51457 # TODO(thestig) temporarily disabled, doesn't work in third_party/
458 #results.extend(input_api.canned_checks.CheckSvnModifiedDirectories(
459 # input_api, output_api, sources))
[email protected]fe5f57c52009-06-05 14:25:54460 # Make sure the tree is 'open'.
[email protected]806e98e2010-03-19 17:49:27461 results.extend(input_api.canned_checks.CheckTreeIsOpen(
[email protected]7f238152009-08-12 19:00:34462 input_api,
463 output_api,
[email protected]4efa42142010-08-26 01:29:26464 json_url='http://chromium-status.appspot.com/current?format=json'))
[email protected]806e98e2010-03-19 17:49:27465 results.extend(input_api.canned_checks.CheckRietveldTryJobExecution(input_api,
[email protected]4ddc5df2011-12-12 03:05:04466 output_api, 'http://codereview.chromium.org',
[email protected]c1ba4c52012-03-09 14:23:28467 ('win_rel', 'linux_rel', 'mac_rel, win:compile'),
468 '[email protected]'))
[email protected]806e98e2010-03-19 17:49:27469
[email protected]3e4eb112011-01-18 03:29:54470 results.extend(input_api.canned_checks.CheckChangeHasBugField(
471 input_api, output_api))
472 results.extend(input_api.canned_checks.CheckChangeHasTestField(
473 input_api, output_api))
[email protected]c4b47562011-12-05 23:39:41474 results.extend(input_api.canned_checks.CheckChangeHasDescription(
475 input_api, output_api))
[email protected]b337cb5b2011-01-23 21:24:05476 results.extend(_CheckSubversionConfig(input_api, output_api))
[email protected]fe5f57c52009-06-05 14:25:54477 return results
[email protected]ca8d1982009-02-19 16:33:12478
479
[email protected]5efb2a822011-09-27 23:06:13480def GetPreferredTrySlaves(project, change):
[email protected]4ce995ea2012-06-27 02:13:10481 files = change.LocalPaths()
482
483 if all(re.search('\.(m|mm)$|[/_]mac[/_.]', f) for f in files):
[email protected]4ddc5df2011-12-12 03:05:04484 return ['mac_rel']
[email protected]4ce995ea2012-06-27 02:13:10485 if all(re.search('[/_]win[/_.]', f) for f in files):
486 return ['win_rel']
487 if all(re.search('[/_]android[/_.]', f) for f in files):
488 return ['android']
489
490 trybots = ['win_rel', 'linux_rel', 'mac_rel', 'linux_clang:compile']
491 # match things like aurax11.cc or aura_oak.cc
492 if any(re.search('[/_]aura', f) for f in files):
493 trybots.append('linux_chromeos')
494
495 # Ensure CL contains some relevant files (i.e. not purely ^chrome)
496 if any(re.search('^(base|build|content|ipc|jingle|media|net|sql)/', f)
497 for f in files):
498 trybots.append('android')
499
500 return trybots