You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
depot_tools/tests/PRESUBMIT.py

28 lines
847 B
Python

Revert "Reland "Remove Python 2 support for PRESUBMIT.py"" This reverts commit e9ece0f581d5cb89de5b396ee02def97ca919ee2. Reason for revert: broke infra presubmits: https://ci.chromium.org/p/infra/builders/try/infra-try-presubmit Original change's description: > Reland "Remove Python 2 support for PRESUBMIT.py" > > This is a reland of commit 8454fc2458b2421e0e339714c6ff7e6fffb70dc4 > > Original change's description: > > Remove Python 2 support for PRESUBMIT.py > > > > The presubmit system still supports invoking PRESUBMIT.py files using > > Python 2. This has recently been turned off on the bots so this change > > removes support more completely. > > > > There are still some python3 parameters being passed around - it seemed > > better to do the simplest possible removal now, with a follow-up change > > to remove more support code after this has sat for a while. > > > > Tests run from PRESUBMIT.py files could still be run using Python 2, but > > those should also have been addressed already. Removing support for that > > will be done in a subsequent change. > > > > Bug: 1207012 > > Change-Id: Id244d547a04438f83734dba269c3cc180c148b37 > > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4315183 > > Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com> > > Commit-Queue: Bruce Dawson <brucedawson@chromium.org> > > Bug: 1207012 > Change-Id: If542cac21d8ec8704b28d03fd8407c5c2899ca2c > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4317177 > Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com> > Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com> > Auto-Submit: Josip Sokcevic <sokcevic@chromium.org> Bug: 1207012 Change-Id: Iebf76d9e2580761fc773791bac07439160503c98 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4323198 Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> Auto-Submit: Josip Sokcevic <sokcevic@chromium.org> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2 years ago
# Copyright (c) 2021 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.
import sys
PRESUBMIT_VERSION = '2.0.0'
# This file can be removed once py2 presubmit is no longer supported. This is
# an integration test to ensure py2 presubmit still works.
def CheckPythonVersion(input_api, output_api):
# The tests here are assuming this is not defined, so raise an error
# if it is.
if 'USE_PYTHON3' in globals():
return [
output_api.PresubmitError(
'USE_PYTHON3 is defined; update the tests in //PRESUBMIT.py and '
'//tests/PRESUBMIT.py.')
]
if sys.version_info.major != 2:
return [
output_api.PresubmitError(
'Did not use Python2 for //PRESUBMIT.py by default.')
]
return []