Commit dfc71bbe authored by Bruce Dawson's avatar Bruce Dawson Committed by LUCI CQ

Add Python 3 support to GetPythonUnitTests

GetPythonUnitTests (and by extension RunPythonUnitTests) always ran
scripts using Python 2. This change adds a python3=False parameter to
GetPythonUnitTests to give the option of switching to Python 3, while
leaving the default as Python 2. The child scripts are run under one or
the other, based on this parameter.

This change is needed in support of crrev.com/c/3679801.

Bug: 1313804
Change-Id: Ic59287352d4941707adaf7981ed7af4201b7d526
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3680099Reviewed-by: 's avatarJesse McKenna <jessemckenna@google.com>
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
parent 41691abe
......@@ -882,7 +882,7 @@ def GetUnitTestsRecursively(input_api,
skip_shebang_check=skip_shebang_check)
def GetPythonUnitTests(input_api, output_api, unit_tests):
def GetPythonUnitTests(input_api, output_api, unit_tests, python3=False):
"""Run the unit tests out of process, capture the output and use the result
code to determine success.
......@@ -921,7 +921,10 @@ def GetPythonUnitTests(input_api, output_api, unit_tests):
backpath.append(env.get('PYTHONPATH'))
env['PYTHONPATH'] = input_api.os_path.pathsep.join((backpath))
env.pop('VPYTHON_CLEAR_PYTHONPATH', None)
cmd = [input_api.python_executable, '-m', '%s' % unit_test]
if python3:
cmd = [input_api.python3_executable, '-m', '%s' % unit_test]
else:
cmd = [input_api.python_executable, '-m', '%s' % unit_test]
results.append(input_api.Command(
name=unit_test_name,
cmd=cmd,
......
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