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

Unified Diff: third_party/WebKit/Source/core/frame/PRESUBMIT.py

Issue 2380003003: Update PRESUBMIT check for use counters to handle C++ formatting changes (Closed)
Patch Set: Simplify regex and fix comment. Created 4 years, 3 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: third_party/WebKit/Source/core/frame/PRESUBMIT.py
diff --git a/third_party/WebKit/Source/core/frame/PRESUBMIT.py b/third_party/WebKit/Source/core/frame/PRESUBMIT.py
index f4541a133a55a9cce6075d335be3b23e02b714ba..40530edb9b17158134323c523a5a0a9c0a3e967a 100644
--- a/third_party/WebKit/Source/core/frame/PRESUBMIT.py
+++ b/third_party/WebKit/Source/core/frame/PRESUBMIT.py
@@ -12,29 +12,32 @@ for more details about the presubmit API built into gcl.
def _RunUseCounterChecks(input_api, output_api):
for f in input_api.AffectedFiles():
if f.LocalPath().endswith('UseCounter.cpp'):
- useCounterCpp = f
+ use_counter_cpp_file = f
break
else:
return []
- largestFoundBucket = 0
- maximumBucket = 0
- # Looking for a line like "case CSSPropertyGrid: return 453;"
- bucketFinder = input_api.re.compile(r'.*CSSProperty.*return\s*([0-9]+).*')
- # Looking for a line like "int maximumCSSSampleId() { return 452; }"
- maximumFinder = input_api.re.compile(
- r'constexpr int kMaximumCSSSampleId = ([0-9]+);')
- for line in useCounterCpp.NewContents():
- bucketMatch = bucketFinder.match(line)
- if bucketMatch:
- bucket = int(bucketMatch.group(1))
- largestFoundBucket = max(largestFoundBucket, bucket)
- else:
- maximumMatch = maximumFinder.match(line)
- if maximumMatch:
- maximumBucket = int(maximumMatch.group(1))
+ largest_found_bucket = 0
+ expected_max_bucket = 0
- if largestFoundBucket != maximumBucket:
+ # Looking for a line like "case CSSPropertyGrid: return 453;"
+ bucket_finder = input_api.re.compile(
+ r'case CSSProperty\w*?:\s+?return (\d+);',
+ input_api.re.MULTILINE)
+ # Looking for a line like "constexpr int kMaximumCSSSampleId = 452;"
+ expected_max_finder = input_api.re.compile(
+ r'constexpr int kMaximumCSSSampleId = (\d+);')
+ joined_contents = '\n'.join(use_counter_cpp_file.NewContents())
+
+ expected_max_match = expected_max_finder.search(joined_contents)
+ if expected_max_match:
+ expected_max_bucket = int(expected_max_match.group(1))
+
+ for bucket_match in bucket_finder.finditer(joined_contents):
+ bucket = int(bucket_match.group(1))
+ largest_found_bucket = max(largest_found_bucket, bucket)
+
+ if largest_found_bucket != expected_max_bucket:
if input_api.is_committing:
message_type = output_api.PresubmitError
else:
@@ -42,9 +45,9 @@ def _RunUseCounterChecks(input_api, output_api):
return [message_type(
'Largest found CSSProperty bucket Id (%d) does not match '
- 'maximumCSSSampleId (%d)' %
- (largestFoundBucket, maximumBucket),
- items=[useCounterCpp.LocalPath()])]
+ 'maximumCSSSampleId (%d)' % (
+ largest_found_bucket, expected_max_bucket),
+ items=[use_counter_cpp_file.LocalPath()])]
return []
« 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