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

Unified Diff: PRESUBMIT.py

Issue 10572054: Add a presubmit warning for not using UNIT_TEST in source files. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: PRESUBMIT.py
===================================================================
--- PRESUBMIT.py (revision 143189)
+++ PRESUBMIT.py (working copy)
@@ -221,6 +221,23 @@
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 @@
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))
« 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