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

Side by Side Diff: PRESUBMIT.py

Issue 285623004: Add check to make sure the production code is not calling a function in test namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
« 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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 """Attempts to prevent use of functions intended only for testing in 271 """Attempts to prevent use of functions intended only for testing in
272 non-testing code. For now this is just a best-effort implementation 272 non-testing code. For now this is just a best-effort implementation
273 that ignores header files and may have some false positives. A 273 that ignores header files and may have some false positives. A
274 better implementation would probably need a proper C++ parser. 274 better implementation would probably need a proper C++ parser.
275 """ 275 """
276 # We only scan .cc files and the like, as the declaration of 276 # We only scan .cc files and the like, as the declaration of
277 # for-testing functions in header files are hard to distinguish from 277 # for-testing functions in header files are hard to distinguish from
278 # calls to such functions without a proper C++ parser. 278 # calls to such functions without a proper C++ parser.
279 file_inclusion_pattern = r'.+%s' % _IMPLEMENTATION_EXTENSIONS 279 file_inclusion_pattern = r'.+%s' % _IMPLEMENTATION_EXTENSIONS
280 280
281 base_function_pattern = r'ForTest(ing)?|for_test(ing)?' 281 base_function_pattern = r'[ :]test::[^\s]+|ForTest(ing)?|for_test(ing)?'
282 inclusion_pattern = input_api.re.compile(r'(%s)\s*\(' % base_function_pattern) 282 inclusion_pattern = input_api.re.compile(r'(%s)\s*\(' % base_function_pattern)
283 comment_pattern = input_api.re.compile(r'//.*%s' % base_function_pattern) 283 comment_pattern = input_api.re.compile(r'//.*(%s)' % base_function_pattern)
284 exclusion_pattern = input_api.re.compile( 284 exclusion_pattern = input_api.re.compile(
285 r'::[A-Za-z0-9_]+(%s)|(%s)[^;]+\{' % ( 285 r'::[A-Za-z0-9_]+(%s)|(%s)[^;]+\{' % (
286 base_function_pattern, base_function_pattern)) 286 base_function_pattern, base_function_pattern))
287 287
288 def FilterFile(affected_file): 288 def FilterFile(affected_file):
289 black_list = (_EXCLUDED_PATHS + 289 black_list = (_EXCLUDED_PATHS +
290 _TEST_CODE_EXCLUDED_PATHS + 290 _TEST_CODE_EXCLUDED_PATHS +
291 input_api.DEFAULT_BLACK_LIST) 291 input_api.DEFAULT_BLACK_LIST)
292 return input_api.FilterSourceFile( 292 return input_api.FilterSourceFile(
293 affected_file, 293 affected_file,
(...skipping 1207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1501 builders.extend(['cros_x86']) 1501 builders.extend(['cros_x86'])
1502 1502
1503 # The AOSP bot doesn't build the chrome/ layer, so ignore any changes to it 1503 # The AOSP bot doesn't build the chrome/ layer, so ignore any changes to it
1504 # unless they're .gyp(i) files as changes to those files can break the gyp 1504 # unless they're .gyp(i) files as changes to those files can break the gyp
1505 # step on that bot. 1505 # step on that bot.
1506 if (not all(re.search('^chrome', f) for f in files) or 1506 if (not all(re.search('^chrome', f) for f in files) or
1507 any(re.search('\.gypi?$', f) for f in files)): 1507 any(re.search('\.gypi?$', f) for f in files)):
1508 builders.extend(['android_aosp']) 1508 builders.extend(['android_aosp'])
1509 1509
1510 return GetDefaultTryConfigs(builders) 1510 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