Commit 234580e5 authored by Brian Sheedy's avatar Brian Sheedy Committed by Commit Bot

Add option to run tests with Python3

Adds the option to run tests using Python3 instead of Python2 to allow
for tests to be migrated over in preparation for the Python2 deprecation.

This can be achieved by adding a "'use_python3': True" entry to the
test's gn_isolate_map.pyl entry.

Bug: 898348
Change-Id: I675ec068e18cec6bf59ea9d19802bd712f18e87e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1769719Reviewed-by: default avatarMarc-Antoine Ruel <maruel@chromium.org>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Reviewed-by: default avatarDirk Pranke <dpranke@chromium.org>
Commit-Queue: Brian Sheedy <bsheedy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#695232}
parent e51f4cc6
# This is a vpython "spec" file.
#
# It describes patterns for python wheel dependencies of the python scripts in
# the chromium repo, particularly for dependencies that have compiled components
# (since pure-python dependencies can be easily vendored into third_party).
#
# When vpython is invoked, it finds this file and builds a python VirtualEnv,
# containing all of the dependencies described in this file, fetching them from
# CIPD (the "Chrome Infrastructure Package Deployer" service). Unlike `pip`,
# this never requires the end-user machine to have a working python extension
# compilation environment. All of these packages are built using:
# https://chromium.googlesource.com/infra/infra/+/master/infra/tools/dockerbuild/
#
# All python scripts in the repo share this same spec, to avoid dependency
# fragmentation.
#
# If you have depot_tools installed in your $PATH, you can invoke python scripts
# in this repo by running them as you normally would run them, except
# substituting `vpython` instead of `python` on the command line, e.g.:
# vpython path/to/script.py some --arguments
#
# Read more about `vpython` and how to modify this file here:
# https://chromium.googlesource.com/infra/infra/+/master/doc/users/vpython.md
python_version: "3.8"
# TODO(https://crbug.com/898348): Add in necessary wheels as Python3 versions
# become available.
......@@ -10,10 +10,9 @@ per-file .gitignore=*
per-file .git-blame-ignore-revs=mgiuca@chromium.org
per-file .git-blame-ignore-revs=thakis@chromium.org
per-file .gn=file://build/OWNERS
per-file .vpython=dnj@chromium.org
per-file .vpython=dpranke@chromium.org
per-file .vpython=iannucci@chromium.org
per-file .vpython=jbudorick@chromium.org
per-file .vpython*=dpranke@chromium.org
per-file .vpython*=iannucci@chromium.org
per-file .vpython*=jbudorick@chromium.org
per-file AUTHORS=*
per-file BUILD.gn=file://build/OWNERS
per-file codereview.settings=agable@chromium.org
......
......@@ -1275,14 +1275,19 @@ class MetaBuildWrapper(object):
java_coverage = 'jacoco_coverage=true' in vals['gn_args']
test_type = isolate_map[target]['type']
use_python3 = isolate_map[target].get('use_python3', False)
executable = isolate_map[target].get('executable', target)
executable_suffix = isolate_map[target].get(
'executable_suffix', '.exe' if is_win else '')
cmdline = []
extra_files = [
'../../.vpython',
if use_python3:
cmdline = [ 'vpython3' ]
extra_files = [ '../../.vpython3' ]
else:
cmdline = [ 'vpython' ]
extra_files = [ '../../.vpython' ]
extra_files += [
'../../testing/test_env.py',
]
......@@ -1294,19 +1299,18 @@ class MetaBuildWrapper(object):
script = isolate_map[target]['script']
if self.platform == 'win32':
script += '.bat'
cmdline = [
cmdline += [
'../../testing/test_env.py',
script,
]
elif test_type == 'fuzzer':
cmdline = [
cmdline += [
'../../testing/test_env.py',
'../../tools/code_coverage/run_fuzz_target.py',
'--fuzzer', './' + target,
'--output-dir', '${ISOLATED_OUTDIR}',
'--timeout', '3600']
elif is_android and test_type != "script":
cmdline = []
if asan:
cmdline += [os.path.join('bin', 'run_with_asan'), '--']
cmdline += [
......@@ -1318,20 +1322,20 @@ class MetaBuildWrapper(object):
if java_coverage:
cmdline += ['--coverage-dir', '${ISOLATED_OUTDIR}']
elif is_fuchsia and test_type != 'script':
cmdline = [
cmdline += [
'../../testing/test_env.py',
os.path.join('bin', 'run_%s' % target),
'--test-launcher-bot-mode',
'--system-log-file', '${ISOLATED_OUTDIR}/system_log'
]
elif is_simplechrome and test_type != 'script':
cmdline = [
cmdline += [
'../../testing/test_env.py',
os.path.join('bin', 'run_%s' % target),
]
elif use_xvfb and test_type == 'windowed_test_launcher':
extra_files.append('../../testing/xvfb.py')
cmdline = [
cmdline += [
'../../testing/xvfb.py',
'./' + str(executable) + executable_suffix,
'--test-launcher-bot-mode',
......@@ -1346,7 +1350,7 @@ class MetaBuildWrapper(object):
'--cfi-diag=%d' % cfi_diag,
]
elif test_type in ('windowed_test_launcher', 'console_test_launcher'):
cmdline = [
cmdline += [
'../../testing/test_env.py',
'./' + str(executable) + executable_suffix,
'--test-launcher-bot-mode',
......@@ -1361,7 +1365,6 @@ class MetaBuildWrapper(object):
'--cfi-diag=%d' % cfi_diag,
]
elif test_type == 'script':
cmdline = []
# If we're testing a CrOS simplechrome build, assume we need to prepare a
# DUT for testing. So prepend the command to run with the test wrapper.
if is_simplechrome:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment