OLD | NEW |
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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 if 'FRIEND_TEST(' in line: | 176 if 'FRIEND_TEST(' in line: |
177 problems.append(' %s:%d' % (f.LocalPath(), line_num)) | 177 problems.append(' %s:%d' % (f.LocalPath(), line_num)) |
178 | 178 |
179 if not problems: | 179 if not problems: |
180 return [] | 180 return [] |
181 return [output_api.PresubmitPromptWarning('Chromium code should not use ' | 181 return [output_api.PresubmitPromptWarning('Chromium code should not use ' |
182 'gtest\'s FRIEND_TEST() macro. Include base/gtest_prod_util.h and use ' | 182 'gtest\'s FRIEND_TEST() macro. Include base/gtest_prod_util.h and use ' |
183 'FRIEND_TEST_ALL_PREFIXES() instead.\n' + '\n'.join(problems))] | 183 'FRIEND_TEST_ALL_PREFIXES() instead.\n' + '\n'.join(problems))] |
184 | 184 |
185 | 185 |
| 186 def _CheckNoScopedAllowIO(input_api, output_api): |
| 187 """Make sure that ScopedAllowIO is not used.""" |
| 188 problems = [] |
| 189 |
| 190 file_filter = lambda f: f.LocalPath().endswith(('.cc', '.h')) |
| 191 for f in input_api.AffectedFiles(file_filter=file_filter): |
| 192 for line_num, line in f.ChangedContents(): |
| 193 if 'ScopedAllowIO' in line: |
| 194 problems.append(' %s:%d' % (f.LocalPath(), line_num)) |
| 195 |
| 196 if not problems: |
| 197 return [] |
| 198 return [output_api.PresubmitPromptWarning('New code should not use ' |
| 199 'ScopedAllowIO. Post a task to the blocking pool or the FILE thread ' |
| 200 'instead.\n' + '\n'.join(problems))] |
| 201 |
| 202 |
186 def _CommonChecks(input_api, output_api): | 203 def _CommonChecks(input_api, output_api): |
187 """Checks common to both upload and commit.""" | 204 """Checks common to both upload and commit.""" |
188 results = [] | 205 results = [] |
189 results.extend(input_api.canned_checks.PanProjectChecks( | 206 results.extend(input_api.canned_checks.PanProjectChecks( |
190 input_api, output_api, excluded_paths=_EXCLUDED_PATHS)) | 207 input_api, output_api, excluded_paths=_EXCLUDED_PATHS)) |
191 results.extend(_CheckNoInterfacesInBase(input_api, output_api)) | 208 results.extend(_CheckNoInterfacesInBase(input_api, output_api)) |
192 results.extend(_CheckAuthorizedAuthor(input_api, output_api)) | 209 results.extend(_CheckAuthorizedAuthor(input_api, output_api)) |
193 results.extend( | 210 results.extend( |
194 _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api)) | 211 _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api)) |
195 results.extend(_CheckNoIOStreamInHeaders(input_api, output_api)) | 212 results.extend(_CheckNoIOStreamInHeaders(input_api, output_api)) |
196 results.extend(_CheckNoNewWStrings(input_api, output_api)) | 213 results.extend(_CheckNoNewWStrings(input_api, output_api)) |
197 results.extend(_CheckNoDEPSGIT(input_api, output_api)) | 214 results.extend(_CheckNoDEPSGIT(input_api, output_api)) |
198 results.extend(_CheckNoFRIEND_TEST(input_api, output_api)) | 215 results.extend(_CheckNoFRIEND_TEST(input_api, output_api)) |
| 216 results.extend(_CheckNoScopedAllowIO(input_api, output_api)) |
199 return results | 217 return results |
200 | 218 |
201 | 219 |
202 def _CheckSubversionConfig(input_api, output_api): | 220 def _CheckSubversionConfig(input_api, output_api): |
203 """Verifies the subversion config file is correctly setup. | 221 """Verifies the subversion config file is correctly setup. |
204 | 222 |
205 Checks that autoprops are enabled, returns an error otherwise. | 223 Checks that autoprops are enabled, returns an error otherwise. |
206 """ | 224 """ |
207 join = input_api.os_path.join | 225 join = input_api.os_path.join |
208 if input_api.platform == 'win32': | 226 if input_api.platform == 'win32': |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 for non_android_re in (aura_re, win_re): | 350 for non_android_re in (aura_re, win_re): |
333 if all(re.search(non_android_re, f) for f in affected_files): | 351 if all(re.search(non_android_re, f) for f in affected_files): |
334 possibly_android = False | 352 possibly_android = False |
335 break | 353 break |
336 if possibly_android: | 354 if possibly_android: |
337 for f in change.AffectedFiles(): | 355 for f in change.AffectedFiles(): |
338 if any(re.search(r, f.LocalPath()) for r in android_re_list): | 356 if any(re.search(r, f.LocalPath()) for r in android_re_list): |
339 preferred.append('android') | 357 preferred.append('android') |
340 break | 358 break |
341 return preferred | 359 return preferred |
OLD | NEW |