Skip to content

Commit 80b0b38

Browse files
committed
Let Platforms/WASI test take arguments to pass to the Makefile
1 parent 6740479 commit 80b0b38

4 files changed

Lines changed: 48 additions & 0 deletions

File tree

‎Platforms/WASI/README.md‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,17 @@ selected versioned distribution directory inside `dist/`, then restores it
227227
from the matching `.tar.xz` archive before running the tests.
228228
The archive and other distributions in `dist/` are left untouched.
229229

230+
Any trailing `NAME=value` arguments after `--` are passed to `make` as variable
231+
assignments, e.g. to pass extra arguments to the test runner:
232+
233+
```shell
234+
python3 Platforms/WASI test --slow-ci -- "EXTRATESTOPTS=-u-cpu -j2" TESTTIMEOUT=1200
235+
```
236+
237+
For the `dist` and `archive` targets, `TESTPYTHON`, `TESTOPTS`, and
238+
`TESTRUNNER` are used to select the interpreter to test, so they cannot be set;
239+
use `EXTRATESTOPTS` and `TESTPYTHONOPTS` instead.
240+
230241
You can also run tests more directly. To find out where the WASI build directory
231242
is, you can run:
232243

‎Platforms/WASI/__main__.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,14 @@ def main():
102102
help="Test the build (the default), gathered distribution, or release archive; "
103103
"'archive' replaces the distribution directory with the archive's contents",
104104
)
105+
test.add_argument(
106+
"_args",
107+
nargs="*",
108+
metavar="NAME=VALUE",
109+
help="Extra make variable assignments, e.g. `EXTRATESTOPTS=-u-cpu`; "
110+
"TESTPYTHON, TESTOPTS, and TESTRUNNER cannot be set for the "
111+
"'dist' and 'archive' targets",
112+
)
105113
path = subcommands.add_parser(
106114
"path", help="Print the path to a build or distribution directory"
107115
)

‎Platforms/WASI/_shared.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,10 @@ def configure_args(self):
191191
args.extend(["--without-static-libpython"])
192192
return args
193193

194+
@functools.cached_property
195+
def test_args(self):
196+
return getattr(self, "_args", [])
197+
194198
@functools.cached_property
195199
def log_path(self):
196200
if self._log_path is not None:

‎Platforms/WASI/_test.py‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,29 @@
99

1010
import _shared
1111

12+
DIST_RESERVED_VARIABLES = frozenset({"TESTPYTHON", "TESTOPTS", "TESTRUNNER"})
13+
14+
15+
def validate_make_args(context):
16+
"""Check the extra arguments are only make variable assignments that won't
17+
override what this module sets."""
18+
make_args = context.test_args
19+
for arg in make_args:
20+
name, separator, _ = arg.partition("=")
21+
name = name.strip()
22+
if not separator or not name:
23+
raise ValueError(
24+
f"Extra argument {arg!r} is not a `NAME=value` make variable "
25+
"assignment"
26+
)
27+
if context.target in {"dist", "archive"} and name in DIST_RESERVED_VARIABLES:
28+
raise ValueError(
29+
f"Cannot set {name} when testing the {context.target!r} target "
30+
"as it is used to select the interpreter to test; use "
31+
"EXTRATESTOPTS or TESTPYTHONOPTS instead"
32+
)
33+
return make_args
34+
1235

1336
def dist_test_args(context):
1437
runner = context.dist_python_interpreter
@@ -34,6 +57,7 @@ def test(context, _working_dir):
3457
make_target = "buildbottest"
3558
case _:
3659
raise ValueError(f"Unknown CI mode {context.ci_mode}")
60+
make_args = validate_make_args(context)
3761
command = ["make", make_target]
3862
match context.target:
3963
case "archive":
@@ -70,4 +94,5 @@ def test(context, _working_dir):
7094
case _:
7195
raise ValueError(f"Unknown target {context.target}")
7296

97+
command.extend(make_args)
7398
context.call(command, env=_shared.updated_env())

0 commit comments

Comments
 (0)