diff options
author | robertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-28 14:38:20 +0000 |
---|---|---|
committer | robertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-28 14:38:20 +0000 |
commit | b5c2429b2bf3c106e76f8fc537c8ceb6732207ea (patch) | |
tree | 710ff989c436e8b460251e2a2e93a679c722a08d | |
parent | 14f79fec5f13a623f837f0b9438556180e5e7896 (diff) | |
download | chromium_src-b5c2429b2bf3c106e76f8fc537c8ceb6732207ea.zip chromium_src-b5c2429b2bf3c106e76f8fc537c8ceb6732207ea.tar.gz chromium_src-b5c2429b2bf3c106e76f8fc537c8ceb6732207ea.tar.bz2 |
Add a presubmit check that enforces the use of FRIEND_TEST_ALL_PREFIXES() rather than FRIEND_TEST() since the former allows tests to be marked FLAKY_/FAILS_/DISABLED_.
Also speed up _CheckNoNewWStrings() a bit.
BUG=NONE
TEST=Attempt to submit a change that includes FRIEND_TEST(). Get scolded.
Review URL: http://codereview.chromium.org/8660006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111699 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | PRESUBMIT.py | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/PRESUBMIT.py b/PRESUBMIT.py index fa2f98f..dce79ab 100644 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py @@ -131,11 +131,11 @@ def _CheckNoNewWStrings(input_api, output_api): """Checks to make sure we don't introduce use of wstrings.""" problems = [] for f in input_api.AffectedFiles(): - for line_num, line in f.ChangedContents(): - if (not f.LocalPath().endswith(('.cc', '.h')) or - f.LocalPath().endswith('test.cc')): - continue + if (not f.LocalPath().endswith(('.cc', '.h')) or + f.LocalPath().endswith('test.cc')): + continue + for line_num, line in f.ChangedContents(): if 'wstring' in line: problems.append(' %s:%d' % (f.LocalPath(), line_num)) @@ -159,6 +159,25 @@ def _CheckNoDEPSGIT(input_api, output_api): return [] +def _CheckNoFRIEND_TEST(input_api, output_api): + """Make sure that gtest's FRIEND_TEST() macro is not used, the + FRIEND_TEST_ALL_PREFIXES() macro from base/gtest_prod_util.h should be used + instead since that allows for FLAKY_, FAILS_ and DISABLED_ prefixes.""" + problems = [] + + file_filter = lambda f: f.LocalPath().endswith(('.cc', '.h')) + for f in input_api.AffectedFiles(file_filter=file_filter): + for line_num, line in f.ChangedContents(): + if 'FRIEND_TEST(' in line: + problems.append(' %s:%d' % (f.LocalPath(), line_num)) + + if not problems: + return [] + return [output_api.PresubmitPromptWarning('Chromium code should not use ' + 'gtest\'s FRIEND_TEST() macro. Include base/gtest_prod_util.h and use' + 'FRIEND_TEST_ALL_PREFIXES() instead.\n' + '\n'.join(problems))] + + def _CommonChecks(input_api, output_api): """Checks common to both upload and commit.""" results = [] @@ -171,6 +190,7 @@ def _CommonChecks(input_api, output_api): results.extend(_CheckNoIOStreamInHeaders(input_api, output_api)) results.extend(_CheckNoNewWStrings(input_api, output_api)) results.extend(_CheckNoDEPSGIT(input_api, output_api)) + results.extend(_CheckNoFRIEND_TEST(input_api, output_api)) return results |