OLD | NEW |
1 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2011 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 that ignores header files and may have some false positives. A | 44 that ignores header files and may have some false positives. A |
45 better implementation would probably need a proper C++ parser. | 45 better implementation would probably need a proper C++ parser. |
46 """ | 46 """ |
47 # We only scan .cc files and the like, as the declaration of | 47 # We only scan .cc files and the like, as the declaration of |
48 # for-testing functions in header files are hard to distinguish from | 48 # for-testing functions in header files are hard to distinguish from |
49 # calls to such functions without a proper C++ parser. | 49 # calls to such functions without a proper C++ parser. |
50 source_extensions = r'\.(cc|cpp|cxx|mm)$' | 50 source_extensions = r'\.(cc|cpp|cxx|mm)$' |
51 file_inclusion_pattern = r'.+%s' % source_extensions | 51 file_inclusion_pattern = r'.+%s' % source_extensions |
52 file_exclusion_pattern = (r'.+(_test_support|_(unit|browser|ui|perf)test)%s' % | 52 file_exclusion_pattern = (r'.+(_test_support|_(unit|browser|ui|perf)test)%s' % |
53 source_extensions) | 53 source_extensions) |
| 54 path_exclusion_pattern = r'.*[/\\](test|tool(s)?)[/\\].*' |
54 | 55 |
55 base_function_pattern = r'ForTest(ing)?|for_test(ing)?' | 56 base_function_pattern = r'ForTest(ing)?|for_test(ing)?' |
56 inclusion_pattern = input_api.re.compile(r'(%s)\s*\(' % base_function_pattern) | 57 inclusion_pattern = input_api.re.compile(r'(%s)\s*\(' % base_function_pattern) |
57 exclusion_pattern = input_api.re.compile( | 58 exclusion_pattern = input_api.re.compile( |
58 r'::[A-Za-z0-9_]+(%s)|(%s)[^;]+\{' % ( | 59 r'::[A-Za-z0-9_]+(%s)|(%s)[^;]+\{' % ( |
59 base_function_pattern, base_function_pattern)) | 60 base_function_pattern, base_function_pattern)) |
60 | 61 |
61 def FilterFile(affected_file): | 62 def FilterFile(affected_file): |
62 black_list = ((file_exclusion_pattern, ) + _EXCLUDED_PATHS + | 63 black_list = ((file_exclusion_pattern, path_exclusion_pattern, ) + |
63 input_api.DEFAULT_BLACK_LIST) | 64 _EXCLUDED_PATHS + input_api.DEFAULT_BLACK_LIST) |
64 return input_api.FilterSourceFile( | 65 return input_api.FilterSourceFile( |
65 affected_file, | 66 affected_file, |
66 white_list=(file_inclusion_pattern, ), | 67 white_list=(file_inclusion_pattern, ), |
67 black_list=black_list) | 68 black_list=black_list) |
68 | 69 |
69 problems = [] | 70 problems = [] |
70 for f in input_api.AffectedSourceFiles(FilterFile): | 71 for f in input_api.AffectedSourceFiles(FilterFile): |
71 local_path = f.LocalPath() | 72 local_path = f.LocalPath() |
72 lines = input_api.ReadFile(f).splitlines() | 73 lines = input_api.ReadFile(f).splitlines() |
73 line_number = 0 | 74 line_number = 0 |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 results.extend(input_api.canned_checks.CheckChangeHasBugField( | 199 results.extend(input_api.canned_checks.CheckChangeHasBugField( |
199 input_api, output_api)) | 200 input_api, output_api)) |
200 results.extend(input_api.canned_checks.CheckChangeHasTestField( | 201 results.extend(input_api.canned_checks.CheckChangeHasTestField( |
201 input_api, output_api)) | 202 input_api, output_api)) |
202 results.extend(_CheckSubversionConfig(input_api, output_api)) | 203 results.extend(_CheckSubversionConfig(input_api, output_api)) |
203 return results | 204 return results |
204 | 205 |
205 | 206 |
206 def GetPreferredTrySlaves(): | 207 def GetPreferredTrySlaves(): |
207 return ['win', 'linux', 'mac'] | 208 return ['win', 'linux', 'mac'] |
OLD | NEW |