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 203 matching lines...) Loading... |
214 | 214 |
215 if len(files): | 215 if len(files): |
216 return [ output_api.PresubmitError( | 216 return [ output_api.PresubmitError( |
217 'Do not #include <iostream> in header files, since it inserts static ' + | 217 'Do not #include <iostream> in header files, since it inserts static ' + |
218 'initialization into every file including the header. Instead, ' + | 218 'initialization into every file including the header. Instead, ' + |
219 '#include <ostream>. See http://crbug.com/94794', | 219 '#include <ostream>. See http://crbug.com/94794', |
220 files) ] | 220 files) ] |
221 return [] | 221 return [] |
222 | 222 |
223 | 223 |
| 224 def _CheckNoUNIT_TESTInSourceFiles(input_api, output_api): |
| 225 """Checks to make sure no source files use UNIT_TEST""" |
| 226 problems = [] |
| 227 for f in input_api.AffectedFiles(): |
| 228 if (not f.LocalPath().endswith(('.cc', '.mm'))): |
| 229 continue |
| 230 |
| 231 for line_num, line in f.ChangedContents(): |
| 232 if 'UNIT_TEST' in line: |
| 233 problems.append(' %s:%d' % (f.LocalPath(), line_num)) |
| 234 |
| 235 if not problems: |
| 236 return [] |
| 237 return [output_api.PresubmitPromptWarning('UNIT_TEST is only for headers.\n' + |
| 238 '\n'.join(problems))] |
| 239 |
| 240 |
224 def _CheckNoNewWStrings(input_api, output_api): | 241 def _CheckNoNewWStrings(input_api, output_api): |
225 """Checks to make sure we don't introduce use of wstrings.""" | 242 """Checks to make sure we don't introduce use of wstrings.""" |
226 problems = [] | 243 problems = [] |
227 for f in input_api.AffectedFiles(): | 244 for f in input_api.AffectedFiles(): |
228 if (not f.LocalPath().endswith(('.cc', '.h')) or | 245 if (not f.LocalPath().endswith(('.cc', '.h')) or |
229 f.LocalPath().endswith('test.cc')): | 246 f.LocalPath().endswith('test.cc')): |
230 continue | 247 continue |
231 | 248 |
232 for line_num, line in f.ChangedContents(): | 249 for line_num, line in f.ChangedContents(): |
233 if 'wstring' in line: | 250 if 'wstring' in line: |
(...skipping 61 matching lines...) Loading... |
295 | 312 |
296 def _CommonChecks(input_api, output_api): | 313 def _CommonChecks(input_api, output_api): |
297 """Checks common to both upload and commit.""" | 314 """Checks common to both upload and commit.""" |
298 results = [] | 315 results = [] |
299 results.extend(input_api.canned_checks.PanProjectChecks( | 316 results.extend(input_api.canned_checks.PanProjectChecks( |
300 input_api, output_api, excluded_paths=_EXCLUDED_PATHS)) | 317 input_api, output_api, excluded_paths=_EXCLUDED_PATHS)) |
301 results.extend(_CheckAuthorizedAuthor(input_api, output_api)) | 318 results.extend(_CheckAuthorizedAuthor(input_api, output_api)) |
302 results.extend( | 319 results.extend( |
303 _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api)) | 320 _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api)) |
304 results.extend(_CheckNoIOStreamInHeaders(input_api, output_api)) | 321 results.extend(_CheckNoIOStreamInHeaders(input_api, output_api)) |
| 322 results.extend(_CheckNoUNIT_TESTInSourceFiles(input_api, output_api)) |
305 results.extend(_CheckNoNewWStrings(input_api, output_api)) | 323 results.extend(_CheckNoNewWStrings(input_api, output_api)) |
306 results.extend(_CheckNoDEPSGIT(input_api, output_api)) | 324 results.extend(_CheckNoDEPSGIT(input_api, output_api)) |
307 results.extend(_CheckNoBannedFunctions(input_api, output_api)) | 325 results.extend(_CheckNoBannedFunctions(input_api, output_api)) |
308 return results | 326 return results |
309 | 327 |
310 | 328 |
311 def _CheckSubversionConfig(input_api, output_api): | 329 def _CheckSubversionConfig(input_api, output_api): |
312 """Verifies the subversion config file is correctly setup. | 330 """Verifies the subversion config file is correctly setup. |
313 | 331 |
314 Checks that autoprops are enabled, returns an error otherwise. | 332 Checks that autoprops are enabled, returns an error otherwise. |
(...skipping 123 matching lines...) Loading... |
438 for non_android_re in (aura_re, win_re): | 456 for non_android_re in (aura_re, win_re): |
439 if all(re.search(non_android_re, f) for f in affected_files): | 457 if all(re.search(non_android_re, f) for f in affected_files): |
440 possibly_android = False | 458 possibly_android = False |
441 break | 459 break |
442 if possibly_android: | 460 if possibly_android: |
443 for f in change.AffectedFiles(): | 461 for f in change.AffectedFiles(): |
444 if any(re.search(r, f.LocalPath()) for r in android_re_list): | 462 if any(re.search(r, f.LocalPath()) for r in android_re_list): |
445 preferred.append('android') | 463 preferred.append('android') |
446 break | 464 break |
447 return preferred | 465 return preferred |
OLD | NEW |