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 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
367 for line_num, line in f.ChangedContents(): | 367 for line_num, line in f.ChangedContents(): |
368 if 'UNIT_TEST ' in line or line.endswith('UNIT_TEST'): | 368 if 'UNIT_TEST ' in line or line.endswith('UNIT_TEST'): |
369 problems.append(' %s:%d' % (f.LocalPath(), line_num)) | 369 problems.append(' %s:%d' % (f.LocalPath(), line_num)) |
370 | 370 |
371 if not problems: | 371 if not problems: |
372 return [] | 372 return [] |
373 return [output_api.PresubmitPromptWarning('UNIT_TEST is only for headers.\n' + | 373 return [output_api.PresubmitPromptWarning('UNIT_TEST is only for headers.\n' + |
374 '\n'.join(problems))] | 374 '\n'.join(problems))] |
375 | 375 |
376 | 376 |
377 def _CheckDCHECK_IS_ONHasBraces(input_api, output_api): | |
378 """Checks to make sure DCHECK_IS_ON() does not skip the braces""" | |
ncarter (slow)
2015/10/23 20:39:02
Nit: period at end of sentence per https://www.pyt
danakj
2015/10/23 21:53:16
Done and fixed what I copied from.
| |
379 files = [] | |
380 pattern = input_api.re.compile(r'DCHECK_IS_ON(?!\(\))', | |
381 input_api.re.MULTILINE) | |
382 for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile): | |
383 if (not f.LocalPath().endswith(('.cc', '.mm', '.h'))): | |
384 continue | |
385 contents = input_api.ReadFile(f) | |
ncarter (slow)
2015/10/23 20:39:02
Should this iterate over ChangedContents (the diff
danakj
2015/10/23 21:53:16
Ya good point, copied from the UNIT_TEST one. Fixe
| |
386 if pattern.search(contents): | |
387 files.append(f) | |
388 | |
389 if not files: | |
390 return [] | |
391 return [ output_api.PresubmitError( | |
392 'Use of DCHECK_IS_ON() must be written as "#if DCHECK_IS_ON()", not ' | |
393 'forgetting the braces.', | |
394 files) ] | |
395 | |
396 | |
377 def _FindHistogramNameInLine(histogram_name, line): | 397 def _FindHistogramNameInLine(histogram_name, line): |
378 """Tries to find a histogram name or prefix in a line.""" | 398 """Tries to find a histogram name or prefix in a line.""" |
379 if not "affected-histogram" in line: | 399 if not "affected-histogram" in line: |
380 return histogram_name in line | 400 return histogram_name in line |
381 # A histogram_suffixes tag type has an affected-histogram name as a prefix of | 401 # A histogram_suffixes tag type has an affected-histogram name as a prefix of |
382 # the histogram_name. | 402 # the histogram_name. |
383 if not '"' in line: | 403 if not '"' in line: |
384 return False | 404 return False |
385 histogram_prefix = line.split('\"')[1] | 405 histogram_prefix = line.split('\"')[1] |
386 return histogram_prefix in histogram_name | 406 return histogram_prefix in histogram_name |
(...skipping 1246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1633 """Checks common to both upload and commit.""" | 1653 """Checks common to both upload and commit.""" |
1634 results = [] | 1654 results = [] |
1635 results.extend(input_api.canned_checks.PanProjectChecks( | 1655 results.extend(input_api.canned_checks.PanProjectChecks( |
1636 input_api, output_api, | 1656 input_api, output_api, |
1637 excluded_paths=_EXCLUDED_PATHS + _TESTRUNNER_PATHS)) | 1657 excluded_paths=_EXCLUDED_PATHS + _TESTRUNNER_PATHS)) |
1638 results.extend(_CheckAuthorizedAuthor(input_api, output_api)) | 1658 results.extend(_CheckAuthorizedAuthor(input_api, output_api)) |
1639 results.extend( | 1659 results.extend( |
1640 _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api)) | 1660 _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api)) |
1641 results.extend(_CheckNoIOStreamInHeaders(input_api, output_api)) | 1661 results.extend(_CheckNoIOStreamInHeaders(input_api, output_api)) |
1642 results.extend(_CheckNoUNIT_TESTInSourceFiles(input_api, output_api)) | 1662 results.extend(_CheckNoUNIT_TESTInSourceFiles(input_api, output_api)) |
1663 results.extend(_CheckDCHECK_IS_ONHasBraces(input_api, output_api)) | |
1643 results.extend(_CheckNoNewWStrings(input_api, output_api)) | 1664 results.extend(_CheckNoNewWStrings(input_api, output_api)) |
1644 results.extend(_CheckNoDEPSGIT(input_api, output_api)) | 1665 results.extend(_CheckNoDEPSGIT(input_api, output_api)) |
1645 results.extend(_CheckNoBannedFunctions(input_api, output_api)) | 1666 results.extend(_CheckNoBannedFunctions(input_api, output_api)) |
1646 results.extend(_CheckNoPragmaOnce(input_api, output_api)) | 1667 results.extend(_CheckNoPragmaOnce(input_api, output_api)) |
1647 results.extend(_CheckNoTrinaryTrueFalse(input_api, output_api)) | 1668 results.extend(_CheckNoTrinaryTrueFalse(input_api, output_api)) |
1648 results.extend(_CheckUnwantedDependencies(input_api, output_api)) | 1669 results.extend(_CheckUnwantedDependencies(input_api, output_api)) |
1649 results.extend(_CheckFilePermissions(input_api, output_api)) | 1670 results.extend(_CheckFilePermissions(input_api, output_api)) |
1650 results.extend(_CheckNoAuraWindowPropertyHInHeaders(input_api, output_api)) | 1671 results.extend(_CheckNoAuraWindowPropertyHInHeaders(input_api, output_api)) |
1651 results.extend(_CheckIncludeOrder(input_api, output_api)) | 1672 results.extend(_CheckIncludeOrder(input_api, output_api)) |
1652 results.extend(_CheckForVersionControlConflicts(input_api, output_api)) | 1673 results.extend(_CheckForVersionControlConflicts(input_api, output_api)) |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1979 for master in masters: | 2000 for master in masters: |
1980 try_config.setdefault(master, {}) | 2001 try_config.setdefault(master, {}) |
1981 for builder in masters[master]: | 2002 for builder in masters[master]: |
1982 # Do not trigger presubmit builders, since they're likely to fail | 2003 # Do not trigger presubmit builders, since they're likely to fail |
1983 # (e.g. OWNERS checks before finished code review), and we're | 2004 # (e.g. OWNERS checks before finished code review), and we're |
1984 # running local presubmit anyway. | 2005 # running local presubmit anyway. |
1985 if 'presubmit' not in builder: | 2006 if 'presubmit' not in builder: |
1986 try_config[master][builder] = ['defaulttests'] | 2007 try_config[master][builder] = ['defaulttests'] |
1987 | 2008 |
1988 return try_config | 2009 return try_config |
OLD | NEW |