Chromium Code Reviews| 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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 186 'RunAllPending()', | 186 'RunAllPending()', |
| 187 ( | 187 ( |
| 188 'This function is deprecated and we\'re working on removing it. Rename', | 188 'This function is deprecated and we\'re working on removing it. Rename', |
| 189 'to RunUntilIdle', | 189 'to RunUntilIdle', |
| 190 ), | 190 ), |
| 191 True, | 191 True, |
| 192 ), | 192 ), |
| 193 ) | 193 ) |
| 194 | 194 |
| 195 | 195 |
| 196 _DELETIONS_ONLY_FILES = ( | |
| 197 'build/android/findbugs_filter/findbugs_known_bugs.txt' | |
|
Isaac (away)
2013/01/09 05:40:10
if you keep this, you need a trailing comma on 197
Siva Chandra
2013/01/11 01:24:04
Done.
| |
| 198 ) | |
| 199 | |
| 200 | |
| 196 | 201 |
| 197 def _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api): | 202 def _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api): |
| 198 """Attempts to prevent use of functions intended only for testing in | 203 """Attempts to prevent use of functions intended only for testing in |
| 199 non-testing code. For now this is just a best-effort implementation | 204 non-testing code. For now this is just a best-effort implementation |
| 200 that ignores header files and may have some false positives. A | 205 that ignores header files and may have some false positives. A |
| 201 better implementation would probably need a proper C++ parser. | 206 better implementation would probably need a proper C++ parser. |
| 202 """ | 207 """ |
| 203 # We only scan .cc files and the like, as the declaration of | 208 # We only scan .cc files and the like, as the declaration of |
| 204 # for-testing functions in header files are hard to distinguish from | 209 # for-testing functions in header files are hard to distinguish from |
| 205 # calls to such functions without a proper C++ parser. | 210 # calls to such functions without a proper C++ parser. |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 621 warnings = _CheckIncludeOrderInFile(input_api, output_api, f, False, | 626 warnings = _CheckIncludeOrderInFile(input_api, output_api, f, False, |
| 622 changed_linenums) | 627 changed_linenums) |
| 623 | 628 |
| 624 results = [] | 629 results = [] |
| 625 if warnings: | 630 if warnings: |
| 626 results.append(output_api.PresubmitPromptWarning(_INCLUDE_ORDER_WARNING, | 631 results.append(output_api.PresubmitPromptWarning(_INCLUDE_ORDER_WARNING, |
| 627 warnings)) | 632 warnings)) |
| 628 return results | 633 return results |
| 629 | 634 |
| 630 | 635 |
| 636 def _CheckDeletionsOnlyFiles(input_api, output_api): | |
| 637 """Check that a certain listed files only have deletions. | |
|
Isaac (away)
2013/01/12 02:42:30
nit: end triple quote on line 637 (delete line 638
| |
| 638 """ | |
| 639 errors = [] | |
| 640 for f in input_api.AffectedFiles(): | |
| 641 if f.LocalPath() in _DELETIONS_ONLY_FILES: | |
|
Isaac (away)
2013/01/09 05:40:10
how about just:
if f.LocalPath() = 'build/android
Siva Chandra
2013/01/11 01:24:04
Unless you feel generality is bad here, I would pr
Isaac (away)
2013/01/12 02:42:30
SGTM. It's fine to keep the DELETION_ONLY_FILES a
| |
| 642 if f.ChangedContents(): | |
| 643 errors.append(f.LocalPath()) | |
| 644 results = [] | |
| 645 if errors: | |
| 646 results.append(output_api.PresubmitError( | |
| 647 'Following files should only contain deletions.', errors)) | |
| 648 return results | |
| 649 | |
| 650 | |
| 631 def _CommonChecks(input_api, output_api): | 651 def _CommonChecks(input_api, output_api): |
| 632 """Checks common to both upload and commit.""" | 652 """Checks common to both upload and commit.""" |
| 633 results = [] | 653 results = [] |
| 634 results.extend(input_api.canned_checks.PanProjectChecks( | 654 results.extend(input_api.canned_checks.PanProjectChecks( |
| 635 input_api, output_api, excluded_paths=_EXCLUDED_PATHS)) | 655 input_api, output_api, excluded_paths=_EXCLUDED_PATHS)) |
| 636 results.extend(_CheckAuthorizedAuthor(input_api, output_api)) | 656 results.extend(_CheckAuthorizedAuthor(input_api, output_api)) |
| 637 results.extend( | 657 results.extend( |
| 638 _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api)) | 658 _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api)) |
| 639 results.extend(_CheckNoIOStreamInHeaders(input_api, output_api)) | 659 results.extend(_CheckNoIOStreamInHeaders(input_api, output_api)) |
| 640 results.extend(_CheckNoUNIT_TESTInSourceFiles(input_api, output_api)) | 660 results.extend(_CheckNoUNIT_TESTInSourceFiles(input_api, output_api)) |
| 641 results.extend(_CheckNoNewWStrings(input_api, output_api)) | 661 results.extend(_CheckNoNewWStrings(input_api, output_api)) |
| 642 results.extend(_CheckNoDEPSGIT(input_api, output_api)) | 662 results.extend(_CheckNoDEPSGIT(input_api, output_api)) |
| 643 results.extend(_CheckNoBannedFunctions(input_api, output_api)) | 663 results.extend(_CheckNoBannedFunctions(input_api, output_api)) |
| 644 results.extend(_CheckNoPragmaOnce(input_api, output_api)) | 664 results.extend(_CheckNoPragmaOnce(input_api, output_api)) |
| 645 results.extend(_CheckNoTrinaryTrueFalse(input_api, output_api)) | 665 results.extend(_CheckNoTrinaryTrueFalse(input_api, output_api)) |
| 646 results.extend(_CheckUnwantedDependencies(input_api, output_api)) | 666 results.extend(_CheckUnwantedDependencies(input_api, output_api)) |
| 647 results.extend(_CheckFilePermissions(input_api, output_api)) | 667 results.extend(_CheckFilePermissions(input_api, output_api)) |
| 648 results.extend(_CheckNoAuraWindowPropertyHInHeaders(input_api, output_api)) | 668 results.extend(_CheckNoAuraWindowPropertyHInHeaders(input_api, output_api)) |
| 649 results.extend(_CheckIncludeOrder(input_api, output_api)) | 669 results.extend(_CheckIncludeOrder(input_api, output_api)) |
| 670 results.extend(_CheckDeletionsOnlyFiles(input_api, output_api)) | |
| 650 return results | 671 return results |
| 651 | 672 |
| 652 | 673 |
| 653 def _CheckSubversionConfig(input_api, output_api): | 674 def _CheckSubversionConfig(input_api, output_api): |
| 654 """Verifies the subversion config file is correctly setup. | 675 """Verifies the subversion config file is correctly setup. |
| 655 | 676 |
| 656 Checks that autoprops are enabled, returns an error otherwise. | 677 Checks that autoprops are enabled, returns an error otherwise. |
| 657 """ | 678 """ |
| 658 join = input_api.os_path.join | 679 join = input_api.os_path.join |
| 659 if input_api.platform == 'win32': | 680 if input_api.platform == 'win32': |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 787 | 808 |
| 788 # Match things like path/aura/file.cc and path/file_aura.cc. | 809 # Match things like path/aura/file.cc and path/file_aura.cc. |
| 789 # Same for ash and chromeos. | 810 # Same for ash and chromeos. |
| 790 if any(re.search('[/_](ash|aura)', f) for f in files): | 811 if any(re.search('[/_](ash|aura)', f) for f in files): |
| 791 trybots += ['linux_chromeos_clang:compile', 'win_aura', | 812 trybots += ['linux_chromeos_clang:compile', 'win_aura', |
| 792 'linux_chromeos_asan'] | 813 'linux_chromeos_asan'] |
| 793 elif any(re.search('[/_]chromeos', f) for f in files): | 814 elif any(re.search('[/_]chromeos', f) for f in files): |
| 794 trybots += ['linux_chromeos_clang:compile', 'linux_chromeos_asan'] | 815 trybots += ['linux_chromeos_clang:compile', 'linux_chromeos_asan'] |
| 795 | 816 |
| 796 return trybots | 817 return trybots |
| OLD | NEW |