Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-109566: Fix regrtest Python options for WASM/WASI #109954

Merged
merged 1 commit into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions Lib/test/libregrtest/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,9 +504,12 @@ def _add_python_opts(self):
if sys.flags.bytes_warning < 2:
python_opts.append('-bb')

# Ignore PYTHON* environment variables
if not sys.flags.ignore_environment:
python_opts.append('-E')
# WASM/WASI buildbot builders pass multiple PYTHON environment
# variables such as PYTHONPATH and _PYTHON_HOSTRUNNER.
if not self.python_cmd:
# Ignore PYTHON* environment variables
if not sys.flags.ignore_environment:
python_opts.append('-E')

if not python_opts:
return
Expand Down
6 changes: 5 additions & 1 deletion Lib/test/libregrtest/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@ def create_worker_process(runtests: RunTests, output_fd: int,
python_cmd = runtests.python_cmd
worker_json = runtests.as_json()

python_opts = support.args_from_interpreter_flags()
if python_cmd is not None:
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:
executable = (sys.executable,)
cmd = [*executable, *support.args_from_interpreter_flags(),
cmd = [*executable, *python_opts,
'-u', # Unbuffered stdout and stderr
'-m', 'test.libregrtest.worker',
worker_json]
Expand Down
13 changes: 9 additions & 4 deletions Lib/test/test_regrtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1965,16 +1965,20 @@ def test_dev_mode(self):
self.check_executed_tests(output, tests,
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
code = textwrap.dedent(r"""
import sys
import unittest
from test import support
try:
from _testinternalcapi import get_config
except ImportError:
get_config = None

# WASI/WASM buildbots don't use -E option
use_environment = (support.is_emscripten or support.is_wasi)

class WorkerTests(unittest.TestCase):
@unittest.skipUnless(get_config is None, 'need get_config()')
def test_config(self):
Expand All @@ -1986,7 +1990,7 @@ def test_config(self):
# -bb option
self.assertTrue(config['bytes_warning'], 2)
# -E option
self.assertTrue(config['use_environment'], 0)
self.assertTrue(config['use_environment'], use_environment)

def test_python_opts(self):
# -u option
Expand All @@ -2000,7 +2004,8 @@ def test_python_opts(self):
self.assertEqual(sys.flags.bytes_warning, 2)

# -E option
self.assertTrue(sys.flags.ignore_environment)
self.assertEqual(not sys.flags.ignore_environment,
use_environment)
""")
testname = self.create_test(code=code)

Expand All @@ -2018,7 +2023,7 @@ def test_python_opts(self):
def test_add_python_opts(self):
for opt in ("--fast-ci", "--slow-ci"):
with self.subTest(opt=opt):
self.check_reexec(opt)
self.check_add_python_opts(opt)


class TestUtils(unittest.TestCase):
Expand Down
Loading