blob: eba4c2f66424070ec1a33f4ddb8ae72efd61c7ba [file] [log] [blame]
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Blink frame presubmit script
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
return []
largestFoundBucket = 0
maximumBucket = 0
# Looking for a line like "case CSSPropertyGrid: return 453;"
bucketFinder ='.*CSSProperty.*return\s*([0-9]+).*')
# Looking for a line like "static int maximumCSSSampleId() { return 452; }"
maximumFinder =
r'static int maximumCSSSampleId\(\) { return ([0-9]+)')
for line in useCounterCpp.NewContents():
bucketMatch = bucketFinder.match(line)
if bucketMatch:
bucket = int(
largestFoundBucket = max(largestFoundBucket, bucket)
maximumMatch = maximumFinder.match(line)
if maximumMatch:
maximumBucket = int(
if largestFoundBucket != maximumBucket:
if input_api.is_committing:
message_type = output_api.PresubmitError
message_type = output_api.PresubmitPromptWarning
return [message_type(
'Largest found CSSProperty bucket Id (%d) does not match '
'maximumCSSSampleId (%d)' %
(largestFoundBucket, maximumBucket),
return []
def CheckChangeOnUpload(input_api, output_api):
return _RunUseCounterChecks(input_api, output_api)
def CheckChangeOnCommit(input_api, output_api):
return _RunUseCounterChecks(input_api, output_api)