gh-145177: Add emscripten run --test, uses test args from config.toml (#146160)
This allows us to change the test arguments from the python repo rather
than having to change buildmaster-config.
Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
diff --git a/Platforms/emscripten/__main__.py b/Platforms/emscripten/__main__.py
index 98e5731..6a79634 100644
--- a/Platforms/emscripten/__main__.py
+++ b/Platforms/emscripten/__main__.py
@@ -578,7 +578,10 @@ def run_emscripten_python(context):
if args and args[0] == "--":
args = args[1:]
- os.execv(str(exec_script), [str(exec_script)] + args)
+ if context.test:
+ args = load_config_toml()["test-args"] + args
+
+ os.execv(str(exec_script), [str(exec_script), *args])
def build_target(context):
@@ -696,6 +699,15 @@ def main():
help="Run the built emscripten Python",
)
run.add_argument(
+ "--test",
+ action="store_true",
+ default=False,
+ help=(
+ "If passed, will add the default test arguments to the beginning of the command. "
+ "Default arguments loaded from Platforms/emscripten/config.toml"
+ )
+ )
+ run.add_argument(
"args",
nargs=argparse.REMAINDER,
help=(
@@ -704,6 +716,7 @@ def main():
)
)
add_cross_build_dir_option(run)
+
clean = subcommands.add_parser(
"clean", help="Delete files and directories created by this script"
)
diff --git a/Platforms/emscripten/config.toml b/Platforms/emscripten/config.toml
index 4e76b5b..c474078 100644
--- a/Platforms/emscripten/config.toml
+++ b/Platforms/emscripten/config.toml
@@ -3,6 +3,14 @@
# Python versions.
emscripten-version = "4.0.12"
node-version = "24"
+test-args = [
+ "-m", "test",
+ "-v",
+ "-uall",
+ "--rerun",
+ "--single-process",
+ "-W",
+]
[libffi]
url = "https://github.com/libffi/libffi/releases/download/v{version}/libffi-{version}.tar.gz"