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/+/1769719
Reviewed-by: Marc-Antoine Ruel <[email protected]>
Reviewed-by: Ted Choc <[email protected]>
Reviewed-by: Dirk Pranke <[email protected]>
Commit-Queue: Brian Sheedy <[email protected]>
Cr-Commit-Position: refs/heads/master@{#695232}
diff --git a/tools/mb/mb.py b/tools/mb/mb.py
index d95f0f18b..e7f08846a 100755
--- a/tools/mb/mb.py
+++ b/tools/mb/mb.py
@@ -1275,14 +1275,19 @@
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 @@
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 @@
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 @@
'--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 @@
'--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: