From db5af6d71013dbb7e254aa701a70aea9ecf04345 Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Tue, 1 Dec 2026 16:52:12 -0700 Subject: [PATCH 1/4] Let `Platforms/WASI test` take arguments to pass to the Makefile --- Platforms/WASI/README.md | 11 +++++++++++ Platforms/WASI/__main__.py | 8 ++++++++ Platforms/WASI/_shared.py | 4 ++++ Platforms/WASI/_test.py | 25 +++++++++++++++++++++++++ 4 files changed, 48 insertions(+) diff --git a/Platforms/WASI/README.md b/Platforms/WASI/README.md index c99b628d7b88a7..f9f4a1fb094ac7 100644 --- a/Platforms/WASI/README.md +++ b/Platforms/WASI/README.md @@ -227,6 +227,17 @@ selected versioned distribution directory inside `dist/`, then restores it from the matching `.tar.xz` archive before running the tests. The archive and other distributions in `dist/` are left untouched. +Any trailing `NAME=value` arguments after `--` are passed to `make` as variable +assignments, e.g. to pass extra arguments to the test runner: + +```shell +python3 Platforms/WASI test --slow-ci -- "EXTRATESTOPTS=-u-cpu -j2" TESTTIMEOUT=1200 +``` + +For the `dist` and `archive` targets, `TESTPYTHON`, `TESTOPTS`, and +`TESTRUNNER` are used to select the interpreter to test, so they cannot be set; +use `EXTRATESTOPTS` and `TESTPYTHONOPTS` instead. + You can also run tests more directly. To find out where the WASI build directory is, you can run: diff --git a/Platforms/WASI/__main__.py b/Platforms/WASI/__main__.py index 2fea2b7d4476cb..86051c54a04f54 100644 --- a/Platforms/WASI/__main__.py +++ b/Platforms/WASI/__main__.py @@ -102,6 +102,14 @@ def main(): help="Test the build (the default), gathered distribution, or release archive; " "'archive' replaces the distribution directory with the archive's contents", ) + test.add_argument( + "_args", + nargs="*", + metavar="NAME=VALUE", + help="Extra make variable assignments, e.g. `EXTRATESTOPTS=-u-cpu`; " + "TESTPYTHON, TESTOPTS, and TESTRUNNER cannot be set for the " + "'dist' and 'archive' targets", + ) path = subcommands.add_parser( "path", help="Print the path to a build or distribution directory" ) diff --git a/Platforms/WASI/_shared.py b/Platforms/WASI/_shared.py index 8e5f13d03adc57..c056964afdefd5 100644 --- a/Platforms/WASI/_shared.py +++ b/Platforms/WASI/_shared.py @@ -191,6 +191,10 @@ def configure_args(self): args.extend(["--without-static-libpython"]) return args + @functools.cached_property + def test_args(self): + return getattr(self, "_args", []) + @functools.cached_property def log_path(self): if self._log_path is not None: diff --git a/Platforms/WASI/_test.py b/Platforms/WASI/_test.py index a44838659c7011..85874c5148c0a9 100644 --- a/Platforms/WASI/_test.py +++ b/Platforms/WASI/_test.py @@ -9,6 +9,29 @@ import _shared +DIST_RESERVED_VARIABLES = frozenset({"TESTPYTHON", "TESTOPTS", "TESTRUNNER"}) + + +def validate_make_args(context): + """Check the extra arguments are only make variable assignments that won't + override what this module sets.""" + make_args = context.test_args + for arg in make_args: + name, separator, _ = arg.partition("=") + name = name.strip() + if not separator or not name: + raise ValueError( + f"Extra argument {arg!r} is not a `NAME=value` make variable " + "assignment" + ) + if context.target in {"dist", "archive"} and name in DIST_RESERVED_VARIABLES: + raise ValueError( + f"Cannot set {name} when testing the {context.target!r} target " + "as it is used to select the interpreter to test; use " + "EXTRATESTOPTS or TESTPYTHONOPTS instead" + ) + return make_args + def dist_test_args(context): runner = context.dist_python_interpreter @@ -34,6 +57,7 @@ def test(context, _working_dir): make_target = "buildbottest" case _: raise ValueError(f"Unknown CI mode {context.ci_mode}") + make_args = validate_make_args(context) command = ["make", make_target] match context.target: case "archive": @@ -70,4 +94,5 @@ def test(context, _working_dir): case _: raise ValueError(f"Unknown target {context.target}") + command.extend(make_args) context.call(command, env=_shared.updated_env()) From 2d6acce5046290c714d960130572bef1b9763550 Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Thu, 3 Dec 2026 13:42:05 -0700 Subject: [PATCH 2/4] Fix formatting --- Platforms/WASI/_test.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Platforms/WASI/_test.py b/Platforms/WASI/_test.py index 85874c5148c0a9..748a7d25210533 100644 --- a/Platforms/WASI/_test.py +++ b/Platforms/WASI/_test.py @@ -24,7 +24,10 @@ def validate_make_args(context): f"Extra argument {arg!r} is not a `NAME=value` make variable " "assignment" ) - if context.target in {"dist", "archive"} and name in DIST_RESERVED_VARIABLES: + if ( + context.target in {"dist", "archive"} + and name in DIST_RESERVED_VARIABLES + ): raise ValueError( f"Cannot set {name} when testing the {context.target!r} target " "as it is used to select the interpreter to test; use " From 22750922bcd2629c4937e862321e47bdf599349b Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Thu, 3 Dec 2026 13:43:38 -0700 Subject: [PATCH 3/4] Add a news entry --- .../next/WASI/2026-12-03-13-43-30.gh-issue-163107.E4yTKi.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/WASI/2026-12-03-13-43-30.gh-issue-163107.E4yTKi.rst diff --git a/Misc/NEWS.d/next/WASI/2026-12-03-13-43-30.gh-issue-163107.E4yTKi.rst b/Misc/NEWS.d/next/WASI/2026-12-03-13-43-30.gh-issue-163107.E4yTKi.rst new file mode 100644 index 00000000000000..fa56f0abf7cd92 --- /dev/null +++ b/Misc/NEWS.d/next/WASI/2026-12-03-13-43-30.gh-issue-163107.E4yTKi.rst @@ -0,0 +1,2 @@ +Allow for `Platforms/WASI test` to accept arguments for the underlying +Makefile (e.g., ``EXTRATESTOPTS``). From cf1a85a39267b23aa093fa006952e630ee6d4276 Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Thu, 3 Dec 2026 13:47:53 -0700 Subject: [PATCH 4/4] Fix formatting in news entry --- .../next/WASI/2026-12-03-13-43-30.gh-issue-163107.E4yTKi.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/WASI/2026-12-03-13-43-30.gh-issue-163107.E4yTKi.rst b/Misc/NEWS.d/next/WASI/2026-12-03-13-43-30.gh-issue-163107.E4yTKi.rst index fa56f0abf7cd92..ab132527c1d26a 100644 --- a/Misc/NEWS.d/next/WASI/2026-12-03-13-43-30.gh-issue-163107.E4yTKi.rst +++ b/Misc/NEWS.d/next/WASI/2026-12-03-13-43-30.gh-issue-163107.E4yTKi.rst @@ -1,2 +1,2 @@ -Allow for `Platforms/WASI test` to accept arguments for the underlying +Allow for ``Platforms/WASI test`` to accept arguments for the underlying Makefile (e.g., ``EXTRATESTOPTS``).