Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: PRESUBMIT.py

Issue 1856253002: Change PRESUBMIT.py to make sure the right FlakyTest being used (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 pattern = input_api.re.compile(r'^#include\s*<iostream>', 366 pattern = input_api.re.compile(r'^#include\s*<iostream>',
367 input_api.re.MULTILINE) 367 input_api.re.MULTILINE)
368 for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile): 368 for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile):
369 if not f.LocalPath().endswith('.h'): 369 if not f.LocalPath().endswith('.h'):
370 continue 370 continue
371 contents = input_api.ReadFile(f) 371 contents = input_api.ReadFile(f)
372 if pattern.search(contents): 372 if pattern.search(contents):
373 files.append(f) 373 files.append(f)
374 374
375 if len(files): 375 if len(files):
376 return [ output_api.PresubmitError( 376 return [output_api.PresubmitError(
377 'Do not #include <iostream> in header files, since it inserts static ' 377 'Do not #include <iostream> in header files, since it inserts static '
378 'initialization into every file including the header. Instead, ' 378 'initialization into every file including the header. Instead, '
379 '#include <ostream>. See http://crbug.com/94794', 379 '#include <ostream>. See http://crbug.com/94794',
380 files) ] 380 files) ]
381 return [] 381 return []
382 382
383 383
384 def _CheckNoUNIT_TESTInSourceFiles(input_api, output_api): 384 def _CheckNoUNIT_TESTInSourceFiles(input_api, output_api):
385 """Checks to make sure no source files use UNIT_TEST.""" 385 """Checks to make sure no source files use UNIT_TEST."""
386 problems = [] 386 problems = []
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 if not histogram_name_found: 472 if not histogram_name_found:
473 problems.append(' [%s:%d] %s' % 473 problems.append(' [%s:%d] %s' %
474 (f.LocalPath(), line_num, histogram_name)) 474 (f.LocalPath(), line_num, histogram_name))
475 475
476 if not problems: 476 if not problems:
477 return [] 477 return []
478 return [output_api.PresubmitPromptWarning('Some UMA_HISTOGRAM lines have ' 478 return [output_api.PresubmitPromptWarning('Some UMA_HISTOGRAM lines have '
479 'been modified and the associated histogram name has no match in either ' 479 'been modified and the associated histogram name has no match in either '
480 '%s or the modifications of it:' % (histograms_xml_path), problems)] 480 '%s or the modifications of it:' % (histograms_xml_path), problems)]
481 481
482 def _CheckFlakyTestUsage(input_api, output_api):
483 """Check that FlakyTest annotation is our own instead of the android one"""
484 pattern = input_api.re.compile(r'import android.test.FlakyTest;')
485 files = []
486 for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile):
487 if f.LocalPath().endswith('Test.java'):
488 if pattern.search(input_api.ReadFile(f)):
489 files.append(f)
490 if len(files):
491 return [output_api.PresubmitError(
492 'Use org.chromium.base.test.util.FlakyTest instead of '
493 'android.test.FlakyTest',
494 files)]
495 return []
482 496
483 def _CheckNoNewWStrings(input_api, output_api): 497 def _CheckNoNewWStrings(input_api, output_api):
484 """Checks to make sure we don't introduce use of wstrings.""" 498 """Checks to make sure we don't introduce use of wstrings."""
485 problems = [] 499 problems = []
486 for f in input_api.AffectedFiles(): 500 for f in input_api.AffectedFiles():
487 if (not f.LocalPath().endswith(('.cc', '.h')) or 501 if (not f.LocalPath().endswith(('.cc', '.h')) or
488 f.LocalPath().endswith(('test.cc', '_win.cc', '_win.h')) or 502 f.LocalPath().endswith(('test.cc', '_win.cc', '_win.h')) or
489 '/win/' in f.LocalPath()): 503 '/win/' in f.LocalPath()):
490 continue 504 continue
491 505
(...skipping 1156 matching lines...) Expand 10 before | Expand all | Expand 10 after
1648 if (f.LocalPath().endswith('.h') or f.LocalPath().endswith('.hxx') or 1662 if (f.LocalPath().endswith('.h') or f.LocalPath().endswith('.hxx') or
1649 f.LocalPath().endswith('.hpp') or f.LocalPath().endswith('.inl')): 1663 f.LocalPath().endswith('.hpp') or f.LocalPath().endswith('.inl')):
1650 contents = input_api.ReadFile(f) 1664 contents = input_api.ReadFile(f)
1651 for line in contents.splitlines(False): 1665 for line in contents.splitlines(False):
1652 if (not line.lstrip().startswith('//') and # Strip C++ comment. 1666 if (not line.lstrip().startswith('//') and # Strip C++ comment.
1653 pattern.search(line)): 1667 pattern.search(line)):
1654 files.append(f) 1668 files.append(f)
1655 break 1669 break
1656 1670
1657 if files: 1671 if files:
1658 return [ output_api.PresubmitError( 1672 return [output_api.PresubmitError(
1659 'Found base::Singleton<T> in the following header files.\n' + 1673 'Found base::Singleton<T> in the following header files.\n' +
1660 'Please move them to an appropriate source file so that the ' + 1674 'Please move them to an appropriate source file so that the ' +
1661 'template gets instantiated in a single compilation unit.', 1675 'template gets instantiated in a single compilation unit.',
1662 files) ] 1676 files) ]
1663 return [] 1677 return []
1664 1678
1665 1679
1666 def _CheckNoDeprecatedCompiledResourcesGYP(input_api, output_api): 1680 def _CheckNoDeprecatedCompiledResourcesGYP(input_api, output_api):
1667 """Checks for old style compiled_resources.gyp files.""" 1681 """Checks for old style compiled_resources.gyp files."""
1668 is_compiled_resource = lambda fp: fp.endswith('compiled_resources.gyp') 1682 is_compiled_resource = lambda fp: fp.endswith('compiled_resources.gyp')
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1789 results.extend(_CheckUnwantedDependencies(input_api, output_api)) 1803 results.extend(_CheckUnwantedDependencies(input_api, output_api))
1790 results.extend(_CheckFilePermissions(input_api, output_api)) 1804 results.extend(_CheckFilePermissions(input_api, output_api))
1791 results.extend(_CheckNoAuraWindowPropertyHInHeaders(input_api, output_api)) 1805 results.extend(_CheckNoAuraWindowPropertyHInHeaders(input_api, output_api))
1792 results.extend(_CheckIncludeOrder(input_api, output_api)) 1806 results.extend(_CheckIncludeOrder(input_api, output_api))
1793 results.extend(_CheckForVersionControlConflicts(input_api, output_api)) 1807 results.extend(_CheckForVersionControlConflicts(input_api, output_api))
1794 results.extend(_CheckPatchFiles(input_api, output_api)) 1808 results.extend(_CheckPatchFiles(input_api, output_api))
1795 results.extend(_CheckHardcodedGoogleHostsInLowerLayers(input_api, output_api)) 1809 results.extend(_CheckHardcodedGoogleHostsInLowerLayers(input_api, output_api))
1796 results.extend(_CheckNoAbbreviationInPngFileName(input_api, output_api)) 1810 results.extend(_CheckNoAbbreviationInPngFileName(input_api, output_api))
1797 results.extend(_CheckForInvalidOSMacros(input_api, output_api)) 1811 results.extend(_CheckForInvalidOSMacros(input_api, output_api))
1798 results.extend(_CheckForInvalidIfDefinedMacros(input_api, output_api)) 1812 results.extend(_CheckForInvalidIfDefinedMacros(input_api, output_api))
1813 results.extend(_CheckFlakyTestUsage(input_api, output_api))
1799 # TODO(danakj): Remove this when base/move.h is removed. 1814 # TODO(danakj): Remove this when base/move.h is removed.
1800 results.extend(_CheckForUsingPass(input_api, output_api)) 1815 results.extend(_CheckForUsingPass(input_api, output_api))
1801 results.extend(_CheckAddedDepsHaveTargetApprovals(input_api, output_api)) 1816 results.extend(_CheckAddedDepsHaveTargetApprovals(input_api, output_api))
1802 results.extend( 1817 results.extend(
1803 input_api.canned_checks.CheckChangeHasNoTabs( 1818 input_api.canned_checks.CheckChangeHasNoTabs(
1804 input_api, 1819 input_api,
1805 output_api, 1820 output_api,
1806 source_file_filter=lambda x: x.LocalPath().endswith('.grd'))) 1821 source_file_filter=lambda x: x.LocalPath().endswith('.grd')))
1807 results.extend(_CheckSpamLogging(input_api, output_api)) 1822 results.extend(_CheckSpamLogging(input_api, output_api))
1808 results.extend(_CheckForAnonymousVariables(input_api, output_api)) 1823 results.extend(_CheckForAnonymousVariables(input_api, output_api))
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
2090 results.extend(input_api.canned_checks.CheckTreeIsOpen( 2105 results.extend(input_api.canned_checks.CheckTreeIsOpen(
2091 input_api, 2106 input_api,
2092 output_api, 2107 output_api,
2093 json_url='http://chromium-status.appspot.com/current?format=json')) 2108 json_url='http://chromium-status.appspot.com/current?format=json'))
2094 2109
2095 results.extend(input_api.canned_checks.CheckChangeHasBugField( 2110 results.extend(input_api.canned_checks.CheckChangeHasBugField(
2096 input_api, output_api)) 2111 input_api, output_api))
2097 results.extend(input_api.canned_checks.CheckChangeHasDescription( 2112 results.extend(input_api.canned_checks.CheckChangeHasDescription(
2098 input_api, output_api)) 2113 input_api, output_api))
2099 return results 2114 return results
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698