From 9981690ea644e02b4c8a785c6e48163f7404ba42 Mon Sep 17 00:00:00 2001 From: Saagar Sanghavi Date: Tue, 11 Aug 2020 22:41:25 +0000 Subject: [PATCH] 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 Reviewed-by: Dirk Pranke --- presubmit_support.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/presubmit_support.py b/presubmit_support.py index 7ef84d167..53ed9c519 100755 --- a/presubmit_support.py +++ b/presubmit_support.py @@ -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