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

Side by Side Diff: PRESUBMIT.py

Issue 10535106: Fix presubmit check to account for e.g. fooblat_unittest_android.cc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 54
55 def _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api): 55 def _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api):
56 """Attempts to prevent use of functions intended only for testing in 56 """Attempts to prevent use of functions intended only for testing in
57 non-testing code. For now this is just a best-effort implementation 57 non-testing code. For now this is just a best-effort implementation
58 that ignores header files and may have some false positives. A 58 that ignores header files and may have some false positives. A
59 better implementation would probably need a proper C++ parser. 59 better implementation would probably need a proper C++ parser.
60 """ 60 """
61 # We only scan .cc files and the like, as the declaration of 61 # We only scan .cc files and the like, as the declaration of
62 # for-testing functions in header files are hard to distinguish from 62 # for-testing functions in header files are hard to distinguish from
63 # calls to such functions without a proper C++ parser. 63 # calls to such functions without a proper C++ parser.
64 platform_specifiers = r'(_(android|chromeos|gtk|mac|posix|win))?'
64 source_extensions = r'\.(cc|cpp|cxx|mm)$' 65 source_extensions = r'\.(cc|cpp|cxx|mm)$'
65 file_inclusion_pattern = r'.+%s' % source_extensions 66 file_inclusion_pattern = r'.+%s' % source_extensions
66 file_exclusion_patterns = ( 67 file_exclusion_patterns = (
67 r'.*[/\\](test_|mock_).+%s' % source_extensions, 68 r'.*[/\\](test_|mock_).+%s' % source_extensions,
68 r'.+_test_(base|support|util)%s' % source_extensions, 69 r'.+_test_(base|support|util)%s' % source_extensions,
69 r'.+_(api|browser|perf|unit|ui)?test%s' % source_extensions, 70 r'.+_(api|browser|perf|unit|ui)?test%s%s' % (platform_specifiers,
71 source_extensions),
70 r'.+profile_sync_service_harness%s' % source_extensions, 72 r'.+profile_sync_service_harness%s' % source_extensions,
71 ) 73 )
72 path_exclusion_patterns = ( 74 path_exclusion_patterns = (
73 r'.*[/\\](test|tool(s)?)[/\\].*', 75 r'.*[/\\](test|tool(s)?)[/\\].*',
74 # At request of folks maintaining this folder. 76 # At request of folks maintaining this folder.
75 r'chrome[/\\]browser[/\\]automation[/\\].*', 77 r'chrome[/\\]browser[/\\]automation[/\\].*',
76 ) 78 )
77 79
78 base_function_pattern = r'ForTest(ing)?|for_test(ing)?' 80 base_function_pattern = r'ForTest(ing)?|for_test(ing)?'
79 inclusion_pattern = input_api.re.compile(r'(%s)\s*\(' % base_function_pattern) 81 inclusion_pattern = input_api.re.compile(r'(%s)\s*\(' % base_function_pattern)
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 for non_android_re in (aura_re, win_re): 367 for non_android_re in (aura_re, win_re):
366 if all(re.search(non_android_re, f) for f in affected_files): 368 if all(re.search(non_android_re, f) for f in affected_files):
367 possibly_android = False 369 possibly_android = False
368 break 370 break
369 if possibly_android: 371 if possibly_android:
370 for f in change.AffectedFiles(): 372 for f in change.AffectedFiles():
371 if any(re.search(r, f.LocalPath()) for r in android_re_list): 373 if any(re.search(r, f.LocalPath()) for r in android_re_list):
372 preferred.append('android') 374 preferred.append('android')
373 break 375 break
374 return preferred 376 return preferred
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