From faac77f09975a5b21d7368e0d76c0051374df5e2 Mon Sep 17 00:00:00 2001 From: Ethan Smith Date: Mon, 25 Apr 2022 14:41:09 -0700 Subject: [PATCH 1/3] Add ability for multiprocessed libregrtest to use a different Python executable --- Lib/test/libregrtest/cmdline.py | 4 ++++ Lib/test/libregrtest/runtest_mp.py | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Lib/test/libregrtest/cmdline.py b/Lib/test/libregrtest/cmdline.py index 11fa0f940bb712..1ac63af734c412 100644 --- a/Lib/test/libregrtest/cmdline.py +++ b/Lib/test/libregrtest/cmdline.py @@ -206,6 +206,8 @@ def _create_parser(): group.add_argument('-S', '--start', metavar='START', help='the name of the test at which to start.' + more_details) + group.add_argument('-p', '--python', metavar='PYTHON', + help='Command to run Python test subprocesses with.') group = parser.add_argument_group('Verbosity') group.add_argument('-v', '--verbose', action='count', @@ -370,6 +372,8 @@ def _parse_args(args, **kwargs): parser.error("-s and -f don't go together!") if ns.use_mp is not None and ns.trace: parser.error("-T and -j don't go together!") + if ns.python is not None and ns.use_mp is None: + parser.error("-p requires -j!") if ns.failfast and not (ns.verbose or ns.verbose3): parser.error("-G/--failfast needs either -v or -W") if ns.pgo and (ns.verbose or ns.verbose2 or ns.verbose3): diff --git a/Lib/test/libregrtest/runtest_mp.py b/Lib/test/libregrtest/runtest_mp.py index 75444e48080ce5..39fab5566a089a 100644 --- a/Lib/test/libregrtest/runtest_mp.py +++ b/Lib/test/libregrtest/runtest_mp.py @@ -2,6 +2,7 @@ import json import os import queue +import shlex import signal import subprocess import sys @@ -55,8 +56,12 @@ def run_test_in_subprocess(testname: str, ns: Namespace) -> subprocess.Popen: ns_dict = vars(ns) worker_args = (ns_dict, testname) worker_args = json.dumps(worker_args) - - cmd = [sys.executable, *support.args_from_interpreter_flags(), + if ns.python is not None: + # The "executable" may be two or more parts, e.g. "node python.js" + executable = shlex.split(ns.python) + else: + executable = [sys.executable] + cmd = [*executable, *support.args_from_interpreter_flags(), '-u', # Unbuffered stdout and stderr '-m', 'test.regrtest', '--worker-args', worker_args] From 2fea1a6f6d536a216f172ad3002b1993a60650c0 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Mon, 2 May 2022 20:15:56 +0000 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Tests/2022-05-02-20-15-54.gh-issue-84461.DhxllI.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Tests/2022-05-02-20-15-54.gh-issue-84461.DhxllI.rst diff --git a/Misc/NEWS.d/next/Tests/2022-05-02-20-15-54.gh-issue-84461.DhxllI.rst b/Misc/NEWS.d/next/Tests/2022-05-02-20-15-54.gh-issue-84461.DhxllI.rst new file mode 100644 index 00000000000000..9aa8df481eb6f9 --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2022-05-02-20-15-54.gh-issue-84461.DhxllI.rst @@ -0,0 +1 @@ +When multiprocessing is enabled, libregrtest can now use a Python executable other than :code:`sys.executable` From b43b31277fc20d0f41aaf5499f11d58fbe7bb9d8 Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Mon, 2 May 2022 15:02:39 -0700 Subject: [PATCH 3/3] Update 2022-05-02-20-15-54.gh-issue-84461.DhxllI.rst --- .../next/Tests/2022-05-02-20-15-54.gh-issue-84461.DhxllI.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Tests/2022-05-02-20-15-54.gh-issue-84461.DhxllI.rst b/Misc/NEWS.d/next/Tests/2022-05-02-20-15-54.gh-issue-84461.DhxllI.rst index 9aa8df481eb6f9..4daae71060346e 100644 --- a/Misc/NEWS.d/next/Tests/2022-05-02-20-15-54.gh-issue-84461.DhxllI.rst +++ b/Misc/NEWS.d/next/Tests/2022-05-02-20-15-54.gh-issue-84461.DhxllI.rst @@ -1 +1 @@ -When multiprocessing is enabled, libregrtest can now use a Python executable other than :code:`sys.executable` +When multiprocessing is enabled, libregrtest can now use a Python executable other than :code:`sys.executable` via the ``--python`` flag.