Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Allow for ``Platforms/WASI test`` to accept arguments for the underlying
Makefile (e.g., ``EXTRATESTOPTS``).
11 changes: 11 additions & 0 deletions Platforms/WASI/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
8 changes: 8 additions & 0 deletions Platforms/WASI/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
4 changes: 4 additions & 0 deletions Platforms/WASI/_shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
28 changes: 28 additions & 0 deletions Platforms/WASI/_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,32 @@

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
Expand All @@ -34,6 +60,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":
Expand Down Expand Up @@ -70,4 +97,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())
Loading