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

Unified Diff: PRESUBMIT.py

Issue 22366003: Add a PRESUBMIT check for 'printf'. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Upload-only. Created 7 years, 4 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
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 6b2cfd92ee3118a664182f3efcff59b116676dd3..a325f5e7a2ac81b9b506482f0d1ea93f290f3c2e 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -233,10 +233,27 @@ def _CompileDevtoolsFrontend(input_api, output_api):
return []
+def _CheckForPrintfDebugging(input_api, output_api):
+ """Generally speaking, we'd prefer not to land patches that printf
+ debug output."""
+ os_macro_re = input_api.re.compile(r'^\s*printf\(')
+ errors = input_api.canned_checks._FindNewViolationsOfRule(
+ lambda _, x: not os_macro_re.search(x),
+ input_api, None)
+ errors = [' * %s' % violation for violation in errors]
+ if errors:
+ return [output_api.PresubmitPromptOrNotify(
+ 'printf debugging is best debugging! That said, it might '
+ 'be a good idea to drop the following occurances from '
+ 'your patch before uploading:\n%s' % '\n'.join(errors))]
+ return []
+
+
def CheckChangeOnUpload(input_api, output_api):
results = []
results.extend(_CommonChecks(input_api, output_api))
results.extend(_CheckStyle(input_api, output_api))
+ results.extend(_CheckForPrintfDebugging(input_api, output_api))
results.extend(_CompileDevtoolsFrontend(input_api, output_api))
return results
« 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