New approach for timing lower-level checks

Use input_api.version and PRESUBMIT_VERSION to ensure newest versions.

Enable presubmit_support to time/ResultDB wrap each individual
lower-level check in PRESUBMIT.py. The approach taken here is to have
the PRESUBMIT_VERSION = 2.0.0 in PRESUBMIT.py
so that presubmit_support is aware of the new version of PRESUBMIT.py,
then check input_api.version in CheckChangeOnCommit/Upload to ensure
that presubmit_support itself is the new version.


Once these changes are landed, the associated changes in PRESUBMIT.py
(crrev.com/c/2350234) can landed as well.


Change-Id: If6d5e318547bc4f128ffe151387c4dc339ef5dc8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2349979
Commit-Queue: Saagar Sanghavi <saagarsanghavi@google.com>
Reviewed-by: Dirk Pranke <dpranke@google.com>
changes/79/2349979/5
Saagar Sanghavi 5 years ago committed by LUCI CQ
parent 97adc5795e
commit 9981690ea6

@ -8,7 +8,7 @@
from __future__ import print_function
__version__ = '1.8.0'
__version__ = '2.0.0'
# TODO(joi) Add caching where appropriate/needed. The API is designed to allow
# caching (between all different invocations of presubmit scripts for a given
@ -1543,11 +1543,6 @@ class PresubmitExecuter(object):
output_api = OutputApi(self.committing)
context = {}
PRESUBMIT_VERSION = [0]
def REQUIRE_PRESUBMIT_VERSION(num):
PRESUBMIT_VERSION[0] = num
context['REQUIRE_PRESUBMIT_VERSION'] = REQUIRE_PRESUBMIT_VERSION
try:
exec(compile(script_text, 'PRESUBMIT.py', 'exec', dont_inherit=True),
context)
@ -1575,7 +1570,8 @@ class PresubmitExecuter(object):
results = []
try:
if PRESUBMIT_VERSION[0] > 0:
if 'PRESUBMIT_VERSION' in context and \
[int(x) for x in context['PRESUBMIT_VERSION'].split('.')] >= [2, 0, 0]:
for function_name in context:
if not function_name.startswith('Check'):
continue

Loading…
Cancel
Save