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 depot_tools. | 8 for more details about the presubmit API built into depot_tools. |
9 """ | 9 """ |
10 | 10 |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 if 'UNIT_TEST ' in line or line.endswith('UNIT_TEST'): | 424 if 'UNIT_TEST ' in line or line.endswith('UNIT_TEST'): |
425 problems.append(' %s:%d' % (f.LocalPath(), line_num)) | 425 problems.append(' %s:%d' % (f.LocalPath(), line_num)) |
426 | 426 |
427 if not problems: | 427 if not problems: |
428 return [] | 428 return [] |
429 return [output_api.PresubmitPromptWarning('UNIT_TEST is only for headers.\n' + | 429 return [output_api.PresubmitPromptWarning('UNIT_TEST is only for headers.\n' + |
430 '\n'.join(problems))] | 430 '\n'.join(problems))] |
431 | 431 |
432 | 432 |
433 def _CheckDCHECK_IS_ONHasBraces(input_api, output_api): | 433 def _CheckDCHECK_IS_ONHasBraces(input_api, output_api): |
434 """Checks to make sure DCHECK_IS_ON() does not skip the braces.""" | 434 """Checks to make sure DCHECK_IS_ON() does not skip the parentheses.""" |
435 errors = [] | 435 errors = [] |
436 pattern = input_api.re.compile(r'DCHECK_IS_ON(?!\(\))', | 436 pattern = input_api.re.compile(r'DCHECK_IS_ON(?!\(\))', |
437 input_api.re.MULTILINE) | 437 input_api.re.MULTILINE) |
438 for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile): | 438 for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile): |
439 if (not f.LocalPath().endswith(('.cc', '.mm', '.h'))): | 439 if (not f.LocalPath().endswith(('.cc', '.mm', '.h'))): |
440 continue | 440 continue |
441 for lnum, line in f.ChangedContents(): | 441 for lnum, line in f.ChangedContents(): |
442 if input_api.re.search(pattern, line): | 442 if input_api.re.search(pattern, line): |
443 errors.append(output_api.PresubmitError( | 443 errors.append(output_api.PresubmitError( |
444 ('%s:%d: Use of DCHECK_IS_ON() must be written as "#if ' + | 444 ('%s:%d: Use of DCHECK_IS_ON() must be written as "#if ' + |
445 'DCHECK_IS_ON()", not forgetting the braces.') | 445 'DCHECK_IS_ON()", not forgetting the parentheses.') |
446 % (f.LocalPath(), lnum))) | 446 % (f.LocalPath(), lnum))) |
447 return errors | 447 return errors |
448 | 448 |
449 | 449 |
450 def _FindHistogramNameInLine(histogram_name, line): | 450 def _FindHistogramNameInLine(histogram_name, line): |
451 """Tries to find a histogram name or prefix in a line.""" | 451 """Tries to find a histogram name or prefix in a line.""" |
452 if not "affected-histogram" in line: | 452 if not "affected-histogram" in line: |
453 return histogram_name in line | 453 return histogram_name in line |
454 # A histogram_suffixes tag type has an affected-histogram name as a prefix of | 454 # A histogram_suffixes tag type has an affected-histogram name as a prefix of |
455 # the histogram_name. | 455 # the histogram_name. |
(...skipping 1916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2372 output_api, | 2372 output_api, |
2373 json_url='http://chromium-status.appspot.com/current?format=json')) | 2373 json_url='http://chromium-status.appspot.com/current?format=json')) |
2374 | 2374 |
2375 results.extend( | 2375 results.extend( |
2376 input_api.canned_checks.CheckPatchFormatted(input_api, output_api)) | 2376 input_api.canned_checks.CheckPatchFormatted(input_api, output_api)) |
2377 results.extend(input_api.canned_checks.CheckChangeHasBugField( | 2377 results.extend(input_api.canned_checks.CheckChangeHasBugField( |
2378 input_api, output_api)) | 2378 input_api, output_api)) |
2379 results.extend(input_api.canned_checks.CheckChangeHasDescription( | 2379 results.extend(input_api.canned_checks.CheckChangeHasDescription( |
2380 input_api, output_api)) | 2380 input_api, output_api)) |
2381 return results | 2381 return results |
OLD | NEW |