diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-21 16:28:18 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-21 16:28:18 +0000 |
commit | 72df4e78fe852acd2612f22231455a3112a8812d (patch) | |
tree | be9fdc4c104976481f5b7695e82e9bd1b9e39f6c /PRESUBMIT.py | |
parent | bceeb90ab07a5b07c0bd38789741812b94031e03 (diff) | |
download | chromium_src-72df4e78fe852acd2612f22231455a3112a8812d.zip chromium_src-72df4e78fe852acd2612f22231455a3112a8812d.tar.gz chromium_src-72df4e78fe852acd2612f22231455a3112a8812d.tar.bz2 |
Add a presubmit warning for not using UNIT_TEST in source files.
Review URL: https://chromiumcodereview.appspot.com/10572054
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@143389 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'PRESUBMIT.py')
-rw-r--r-- | PRESUBMIT.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/PRESUBMIT.py b/PRESUBMIT.py index fed881b..ab24b57 100644 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py @@ -221,6 +221,23 @@ def _CheckNoIOStreamInHeaders(input_api, output_api): return [] +def _CheckNoUNIT_TESTInSourceFiles(input_api, output_api): + """Checks to make sure no source files use UNIT_TEST""" + problems = [] + for f in input_api.AffectedFiles(): + if (not f.LocalPath().endswith(('.cc', '.mm'))): + continue + + for line_num, line in f.ChangedContents(): + if 'UNIT_TEST' in line: + problems.append(' %s:%d' % (f.LocalPath(), line_num)) + + if not problems: + return [] + return [output_api.PresubmitPromptWarning('UNIT_TEST is only for headers.\n' + + '\n'.join(problems))] + + def _CheckNoNewWStrings(input_api, output_api): """Checks to make sure we don't introduce use of wstrings.""" problems = [] @@ -302,6 +319,7 @@ def _CommonChecks(input_api, output_api): results.extend( _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api)) results.extend(_CheckNoIOStreamInHeaders(input_api, output_api)) + results.extend(_CheckNoUNIT_TESTInSourceFiles(input_api, output_api)) results.extend(_CheckNoNewWStrings(input_api, output_api)) results.extend(_CheckNoDEPSGIT(input_api, output_api)) results.extend(_CheckNoBannedFunctions(input_api, output_api)) |