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

Unified Diff: cc/PRESUBMIT.py

Issue 11794017: cc: Ban (f)printf via presubmit.py (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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: cc/PRESUBMIT.py
diff --git a/cc/PRESUBMIT.py b/cc/PRESUBMIT.py
index 1c3613aa045ad63d60e4d58adf9f062abfebde01..319d3b5234469fda2acd4114ac8b5bc7905f9913 100644
--- a/cc/PRESUBMIT.py
+++ b/cc/PRESUBMIT.py
@@ -11,6 +11,7 @@ details on the presubmit API built into gcl.
import re
CC_SOURCE_FILES=(r'^cc/.*\.(cc|h)$',)
+CC_PERF_TEST =(r'^.*_perftest.*\.(cc|h)$',)
def CheckAsserts(input_api, output_api, white_list=CC_SOURCE_FILES, black_list=None):
black_list = tuple(black_list or input_api.DEFAULT_BLACK_LIST)
@@ -42,24 +43,31 @@ def CheckSpamLogging(input_api, output_api, white_list=CC_SOURCE_FILES, black_li
black_list = tuple(black_list or input_api.DEFAULT_BLACK_LIST)
source_file_filter = lambda x: input_api.FilterSourceFile(x, white_list, black_list)
- bad_files = []
+ log_info = []
+ printf = []
for f in input_api.AffectedSourceFiles(source_file_filter):
contents = input_api.ReadFile(f, 'rb')
if re.search(r"\bD?LOG\s*\(\s*INFO\s*\)", contents):
- bad_files.append(f.LocalPath())
+ log_info.append(f.LocalPath())
+ if re.search(r"\bf?printf\(", contents):
+ printf.append(f.LocalPath())
- if bad_files:
+ if log_info:
return [output_api.PresubmitError(
'These files spam the console log with LOG(INFO):',
- items=bad_files)]
+ items=log_info)]
+ if printf:
+ return [output_api.PresubmitError(
+ 'These files spam the console log with printf/fprintf:',
+ items=printf)]
return []
def CheckChangeOnUpload(input_api, output_api):
results = []
results += CheckAsserts(input_api, output_api)
- results += CheckSpamLogging(input_api, output_api)
+ results += CheckSpamLogging(input_api, output_api, black_list=CC_PERF_TEST)
return results
def GetPreferredTrySlaves(project, change):
« 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