summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEthan Smith <ethan@ethanhs.me>2022-05-02 22:51:34 (GMT)
committerGitHub <noreply@github.com>2022-05-02 22:51:34 (GMT)
commitaff8c4f4884fe5ffb2059c2ac9485ded3bba3f3c (patch)
treed8bde733d487289ebd62cb418c0349ca20e459f6
parentb04e02c57f82d6e1ae52ee6f070eb893d019f4fd (diff)
downloadcpython-aff8c4f4884fe5ffb2059c2ac9485ded3bba3f3c.zip
cpython-aff8c4f4884fe5ffb2059c2ac9485ded3bba3f3c.tar.gz
cpython-aff8c4f4884fe5ffb2059c2ac9485ded3bba3f3c.tar.bz2
gh-84461: Add ability for multiprocessed libregrtest to use a different Python executable (GH-91930)
-rw-r--r--Lib/test/libregrtest/cmdline.py4
-rw-r--r--Lib/test/libregrtest/runtest_mp.py9
-rw-r--r--Misc/NEWS.d/next/Tests/2022-05-02-20-15-54.gh-issue-84461.DhxllI.rst1
3 files changed, 12 insertions, 2 deletions
diff --git a/Lib/test/libregrtest/cmdline.py b/Lib/test/libregrtest/cmdline.py
index 11fa0f9..1ac63af 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 75444e4..39fab55 100644
--- a/Lib/test/libregrtest/runtest_mp.py
+++ b/Lib/test/libregrtest/runtest_mp.py
@@ -2,6 +2,7 @@ import faulthandler
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]
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 0000000..4daae71
--- /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` via the ``--python`` flag.