From 4b40ac379f64a713ad81bceb2e1f40d1d71dab6b Mon Sep 17 00:00:00 2001 From: Radek Doulik Date: Tue, 24 Feb 2026 15:00:46 +0100 Subject: [PATCH] [wasm][coreclr] Make run.cmd work with wasm arch --- src/tests/Common/tests.targets | 4 ++-- src/tests/run.cmd | 22 +++++++++++++++++++++- src/tests/run.py | 25 +++++++++++++------------ 3 files changed, 36 insertions(+), 15 deletions(-) diff --git a/src/tests/Common/tests.targets b/src/tests/Common/tests.targets index 1d81103b1ec578..97142837bc7aeb 100644 --- a/src/tests/Common/tests.targets +++ b/src/tests/Common/tests.targets @@ -46,7 +46,7 @@ - + @@ -70,7 +70,7 @@ --> - + diff --git a/src/tests/run.cmd b/src/tests/run.cmd index 2862c8e364883f..56666656a7bf5e 100644 --- a/src/tests/run.cmd +++ b/src/tests/run.cmd @@ -21,6 +21,7 @@ set "__RootBinDir=%__RepoRootDir%\artifacts" set __ToolsDir=%__ProjectDir%\..\Tools set "DotNetCli=%__RepoRootDir%\dotnet.cmd" +set __HostOS= set __Sequential= set __ParallelType= set __msbuildExtraArgs= @@ -47,6 +48,7 @@ if /i "%1" == "-help" goto Usage if /i "%1" == "x64" (set __BuildArch=x64&shift&goto Arg_Loop) if /i "%1" == "x86" (set __BuildArch=x86&shift&goto Arg_Loop) if /i "%1" == "arm64" (set __BuildArch=arm64&shift&goto Arg_Loop) +if /i "%1" == "wasm" (set __BuildArch=wasm&shift&goto Arg_Loop) if /i "%1" == "debug" (set __BuildType=Debug&shift&goto Arg_Loop) if /i "%1" == "release" (set __BuildType=Release&shift&goto Arg_Loop) @@ -96,6 +98,19 @@ shift if defined __TestEnv (if not exist %__TestEnv% echo %__MsgPrefix%Error: Test Environment script %__TestEnv% not found && exit /b 1) +:: Set default for RunWithNodeJS when using wasm architecture +if /i "%__BuildArch%" == "wasm" ( + if not defined RunWithNodeJS set RunWithNodeJS=1 +) + +:: Set default HostOS to browser when using wasm architecture +if /i "%__BuildArch%" == "wasm" ( + if not defined __HostOS set __HostOS=browser +) + +:: Override TargetOS when HostOS is set +if defined __HostOS set __TargetOS=%__HostOS% + :: Set the remaining variables based upon the determined configuration set __MSBuildBuildArch=%__BuildArch% @@ -112,6 +127,10 @@ REM Set up arguments to call run.py set __RuntestPyArgs=-arch %__BuildArch% -build_type %__BuildType% +if defined __HostOS ( + set __RuntestPyArgs=!__RuntestPyArgs! -os %__HostOS% +) + if defined LogsDirArg ( set __RuntestPyArgs=%__RuntestPyArgs% -logs_dir %LogsDirArg% ) @@ -210,7 +229,7 @@ echo. echo where: echo. echo./? -? /h -h /help -help - View this message. -echo ^ - Specifies build architecture: x64, x86, or arm64 ^(default: x64^). +echo ^ - Specifies build architecture: x64, x86, arm64, or wasm ^(default: x64^). echo ^ - Specifies build type: Debug, Release, or Checked ^(default: Debug^). echo TestEnv ^ - Run a custom script before every test to set custom test environment settings. echo sequential - Run tests sequentially ^(no parallelism^). @@ -248,4 +267,5 @@ echo. echo Examples: echo %0 x86 checked echo %0 x64 release +echo %0 wasm debug exit /b 1 diff --git a/src/tests/run.py b/src/tests/run.py index 244e2dd6c8fedb..f7374c56ad0bee 100755 --- a/src/tests/run.py +++ b/src/tests/run.py @@ -201,7 +201,7 @@ def __add_configuration_to_launch_json__(self): configurations = launch_json["configurations"] - dbg_type = "cppvsdbg" if self.host_os == "windows" else "" + dbg_type = "cppvsdbg" if sys.platform == "win32" else "" env = { "DOTNET_AssertOnNYI": "1", @@ -227,7 +227,7 @@ def __add_configuration_to_launch_json__(self): environment.append(env) unique_name = "%s_%s_%s_%s" % (self.test_path, self.args.host_os, self.args.arch, self.args.build_type) - corerun_path = os.path.join(self.args.core_root, "corerun%s" % (".exe" if self.args.host_os == "windows" else "")) + corerun_path = os.path.join(self.args.core_root, "corerun%s" % (".exe" if sys.platform == "win32" else "")) configuration = defaultdict(lambda: None, { "name": unique_name, "type": dbg_type, @@ -264,7 +264,7 @@ def __create_repro_wrapper__(self): """ Create the repro wrapper """ - if self.args.host_os == "windows": + if sys.platform == "win32": self.__create_batch_wrapper__() else: self.__create_bash_wrapper__() @@ -400,12 +400,12 @@ def create_and_use_test_env(_os, env, func): # # errors. - tempfile_suffix = ".bat" if _os == "windows" else "" + tempfile_suffix = ".bat" if sys.platform == "win32" else "" test_env = tempfile.NamedTemporaryFile(mode="w", suffix=tempfile_suffix, delete=False) try: file_header = None - if _os == "windows": + if sys.platform == "win32": file_header = """\ @REM Temporary test env for test run. @echo on @@ -421,7 +421,7 @@ def create_and_use_test_env(_os, env, func): for key in dotnet_vars: value = dotnet_vars[key] command = None - if _os == "windows": + if sys.platform == "win32": command = "set" else: command = "export" @@ -439,7 +439,7 @@ def create_and_use_test_env(_os, env, func): contents += line - if _os == "windows": + if sys.platform == "win32": file_suffix = """\ @echo off """ @@ -1060,11 +1060,12 @@ def setup_args(args): print("logs_dir : %s" % coreclr_setup_args.logs_dir) coreclr_setup_args.repro_location = os.path.join(coreclr_setup_args.logs_dir, "repro") - coreclr_setup_args.dotnetcli_script_path = os.path.join(coreclr_setup_args.runtime_repo_location, "dotnet%s" % (".cmd" if coreclr_setup_args.host_os == "windows" else ".sh")) + script_ext = ".cmd" if sys.platform == "win32" else ".sh" + coreclr_setup_args.dotnetcli_script_path = os.path.join(coreclr_setup_args.runtime_repo_location, "dotnet%s" % script_ext) coreclr_setup_args.coreclr_tests_src_dir = os.path.join(coreclr_setup_args.runtime_repo_location, "src", "tests") - coreclr_setup_args.runincontext_script_path = os.path.join(coreclr_setup_args.coreclr_tests_src_dir, "Common", "scripts", "runincontext%s" % (".cmd" if coreclr_setup_args.host_os == "windows" else ".sh")) - coreclr_setup_args.tieringtest_script_path = os.path.join(coreclr_setup_args.coreclr_tests_src_dir, "Common", "scripts", "tieringtest%s" % (".cmd" if coreclr_setup_args.host_os == "windows" else ".sh")) - coreclr_setup_args.nativeaottest_script_path = os.path.join(coreclr_setup_args.coreclr_tests_src_dir, "Common", "scripts", "nativeaottest%s" % (".cmd" if coreclr_setup_args.host_os == "windows" else ".sh")) + coreclr_setup_args.runincontext_script_path = os.path.join(coreclr_setup_args.coreclr_tests_src_dir, "Common", "scripts", "runincontext%s" % script_ext) + coreclr_setup_args.tieringtest_script_path = os.path.join(coreclr_setup_args.coreclr_tests_src_dir, "Common", "scripts", "tieringtest%s" % script_ext) + coreclr_setup_args.nativeaottest_script_path = os.path.join(coreclr_setup_args.coreclr_tests_src_dir, "Common", "scripts", "nativeaottest%s" % script_ext) return coreclr_setup_args @@ -1141,7 +1142,7 @@ def dir_has_nested_substrings(test_path, test_item): # For some reason, out-of-process tests on Linux are named with ".cmd" wrapper script names, # not .sh extension names. Fix that before trying to find the test filename. - if host_os != "windows": + if sys.platform != "win32": test_name_wo_extension, test_name_extension = os.path.splitext(test_name) if test_name_extension == ".cmd": test_name = test_name_wo_extension + ".sh"