mirror of
https://github.com/python/cpython.git
synced 2025-10-07 23:51:16 +00:00
gh-109566: Fix regrtest Python options for WASM/WASI (#109954)
WASM and WASI buildbots use multiple PYTHON environment variables such as PYTHONPATH and _PYTHON_HOSTRUNNER. Don't use -E if the --python=COMMAND option is used.
This commit is contained in:
parent
b1aebf1e65
commit
91fb8daa24
3 changed files with 20 additions and 8 deletions
|
@ -504,9 +504,12 @@ class Regrtest:
|
||||||
if sys.flags.bytes_warning < 2:
|
if sys.flags.bytes_warning < 2:
|
||||||
python_opts.append('-bb')
|
python_opts.append('-bb')
|
||||||
|
|
||||||
# Ignore PYTHON* environment variables
|
# WASM/WASI buildbot builders pass multiple PYTHON environment
|
||||||
if not sys.flags.ignore_environment:
|
# variables such as PYTHONPATH and _PYTHON_HOSTRUNNER.
|
||||||
python_opts.append('-E')
|
if not self.python_cmd:
|
||||||
|
# Ignore PYTHON* environment variables
|
||||||
|
if not sys.flags.ignore_environment:
|
||||||
|
python_opts.append('-E')
|
||||||
|
|
||||||
if not python_opts:
|
if not python_opts:
|
||||||
return
|
return
|
||||||
|
|
|
@ -22,11 +22,15 @@ def create_worker_process(runtests: RunTests, output_fd: int,
|
||||||
python_cmd = runtests.python_cmd
|
python_cmd = runtests.python_cmd
|
||||||
worker_json = runtests.as_json()
|
worker_json = runtests.as_json()
|
||||||
|
|
||||||
|
python_opts = support.args_from_interpreter_flags()
|
||||||
if python_cmd is not None:
|
if python_cmd is not None:
|
||||||
executable = python_cmd
|
executable = python_cmd
|
||||||
|
# Remove -E option, since --python=COMMAND can set PYTHON environment
|
||||||
|
# variables, such as PYTHONPATH, in the worker process.
|
||||||
|
python_opts = [opt for opt in python_opts if opt != "-E"]
|
||||||
else:
|
else:
|
||||||
executable = (sys.executable,)
|
executable = (sys.executable,)
|
||||||
cmd = [*executable, *support.args_from_interpreter_flags(),
|
cmd = [*executable, *python_opts,
|
||||||
'-u', # Unbuffered stdout and stderr
|
'-u', # Unbuffered stdout and stderr
|
||||||
'-m', 'test.libregrtest.worker',
|
'-m', 'test.libregrtest.worker',
|
||||||
worker_json]
|
worker_json]
|
||||||
|
|
|
@ -1965,16 +1965,20 @@ class ArgsTestCase(BaseTestCase):
|
||||||
self.check_executed_tests(output, tests,
|
self.check_executed_tests(output, tests,
|
||||||
stats=len(tests), parallel=True)
|
stats=len(tests), parallel=True)
|
||||||
|
|
||||||
def check_reexec(self, option):
|
def check_add_python_opts(self, option):
|
||||||
# --fast-ci and --slow-ci add "-u -W default -bb -E" options to Python
|
# --fast-ci and --slow-ci add "-u -W default -bb -E" options to Python
|
||||||
code = textwrap.dedent(r"""
|
code = textwrap.dedent(r"""
|
||||||
import sys
|
import sys
|
||||||
import unittest
|
import unittest
|
||||||
|
from test import support
|
||||||
try:
|
try:
|
||||||
from _testinternalcapi import get_config
|
from _testinternalcapi import get_config
|
||||||
except ImportError:
|
except ImportError:
|
||||||
get_config = None
|
get_config = None
|
||||||
|
|
||||||
|
# WASI/WASM buildbots don't use -E option
|
||||||
|
use_environment = (support.is_emscripten or support.is_wasi)
|
||||||
|
|
||||||
class WorkerTests(unittest.TestCase):
|
class WorkerTests(unittest.TestCase):
|
||||||
@unittest.skipUnless(get_config is None, 'need get_config()')
|
@unittest.skipUnless(get_config is None, 'need get_config()')
|
||||||
def test_config(self):
|
def test_config(self):
|
||||||
|
@ -1986,7 +1990,7 @@ class ArgsTestCase(BaseTestCase):
|
||||||
# -bb option
|
# -bb option
|
||||||
self.assertTrue(config['bytes_warning'], 2)
|
self.assertTrue(config['bytes_warning'], 2)
|
||||||
# -E option
|
# -E option
|
||||||
self.assertTrue(config['use_environment'], 0)
|
self.assertTrue(config['use_environment'], use_environment)
|
||||||
|
|
||||||
def test_python_opts(self):
|
def test_python_opts(self):
|
||||||
# -u option
|
# -u option
|
||||||
|
@ -2000,7 +2004,8 @@ class ArgsTestCase(BaseTestCase):
|
||||||
self.assertEqual(sys.flags.bytes_warning, 2)
|
self.assertEqual(sys.flags.bytes_warning, 2)
|
||||||
|
|
||||||
# -E option
|
# -E option
|
||||||
self.assertTrue(sys.flags.ignore_environment)
|
self.assertEqual(not sys.flags.ignore_environment,
|
||||||
|
use_environment)
|
||||||
""")
|
""")
|
||||||
testname = self.create_test(code=code)
|
testname = self.create_test(code=code)
|
||||||
|
|
||||||
|
@ -2018,7 +2023,7 @@ class ArgsTestCase(BaseTestCase):
|
||||||
def test_add_python_opts(self):
|
def test_add_python_opts(self):
|
||||||
for opt in ("--fast-ci", "--slow-ci"):
|
for opt in ("--fast-ci", "--slow-ci"):
|
||||||
with self.subTest(opt=opt):
|
with self.subTest(opt=opt):
|
||||||
self.check_reexec(opt)
|
self.check_add_python_opts(opt)
|
||||||
|
|
||||||
|
|
||||||
class TestUtils(unittest.TestCase):
|
class TestUtils(unittest.TestCase):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue