From 6ed14d4ef2bd6aa0a8524cc3cc405b10b41f9607 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Thu, 19 Mar 2026 23:14:13 +0100 Subject: [PATCH] gh-145177: Add emscripten run --test, uses test args from config.toml (GH-146160) This allows us to change the test arguments from the python repo rather than having to change buildmaster-config. (cherry picked from commit 6b5511d66bab0754d1d959cfe98947c536bf4d82) Co-authored-by: Hood Chatham Co-authored-by: Russell Keith-Magee --- Platforms/emscripten/__main__.py | 15 ++++++++++++++- Platforms/emscripten/config.toml | 8 ++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/Platforms/emscripten/__main__.py b/Platforms/emscripten/__main__.py index a7c52c2d59f10d..1aef9fcede3d30 100644 --- a/Platforms/emscripten/__main__.py +++ b/Platforms/emscripten/__main__.py @@ -573,7 +573,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): @@ -685,6 +688,15 @@ def main(): "run", 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, @@ -694,6 +706,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 4e76b5bf9f7d2b..c474078fb48ba3 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"