summaryrefslogtreecommitdiffstats
path: root/cc/PRESUBMIT.py
diff options
context:
space:
mode:
authordanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-18 18:15:04 +0000
committerdanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-18 18:15:04 +0000
commit1d99317a73040007668b1cdf134334f45d45600e (patch)
tree0da28120111aa69a339ec90ff05d7cac8b21cf77 /cc/PRESUBMIT.py
parent52f1a7e63128f2a4f644e1a28a6744b916585999 (diff)
downloadchromium_src-1d99317a73040007668b1cdf134334f45d45600e.zip
chromium_src-1d99317a73040007668b1cdf134334f45d45600e.tar.gz
chromium_src-1d99317a73040007668b1cdf134334f45d45600e.tar.bz2
cc: Switch to Chromium DCHECKs LOGs
We can't compile-guard code and use DCHECK since it can be enabled at runtime. So we guard the DCHECKs that we want to rely on conditionally-compiled code in !NDEBUG compile guards. This also replaces use of LOG_ERROR("Foo") with LOG(ERROR)<<"Foo"; This was previously discussed and committed as https://codereview.chromium.org/11048044/ using a guard based on LOGGING_IS_OFFICIAL_BUILD, however this was not sufficient since there are build configurations that are official builds but have dchecks compiled. R=enne Review URL: https://codereview.chromium.org/11192030 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@162739 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/PRESUBMIT.py')
-rw-r--r--cc/PRESUBMIT.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/cc/PRESUBMIT.py b/cc/PRESUBMIT.py
index 0608901..2f2c0f5 100644
--- a/cc/PRESUBMIT.py
+++ b/cc/PRESUBMIT.py
@@ -8,6 +8,41 @@ See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for
details on the presubmit API built into gcl.
"""
+import re
+
+CC_SOURCE_FILES=(r'^cc/.*\.(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)
+ source_file_filter = lambda x: input_api.FilterSourceFile(x, white_list, black_list)
+
+ assert_files = []
+ notreached_files = []
+
+ for f in input_api.AffectedSourceFiles(source_file_filter):
+ contents = input_api.ReadFile(f, 'rb')
+ # WebKit ASSERT() is not allowed.
+ if re.search(r"ASSERT\(", contents):
+ assert_files.append(f.LocalPath())
+ # WebKit ASSERT_NOT_REACHED() is not allowed.
+ if re.search(r"ASSERT_NOT_REACHED\(", contents):
+ notreached_files.append(f.LocalPath())
+
+ if assert_files:
+ return [output_api.PresubmitError(
+ 'These files use ASSERT instead of using DCHECK:',
+ items=assert_files)]
+ if notreached_files:
+ return [output_api.PresubmitError(
+ 'These files use ASSERT_NOT_REACHED instead of using NOTREACHED:',
+ items=notreached_files)]
+ return []
+
+def CheckChangeOnUpload(input_api, output_api):
+ results = []
+ results += CheckAsserts(input_api, output_api)
+ return results
+
def GetPreferredTrySlaves(project, change):
return [
'linux_layout_rel',