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
4 changes: 2 additions & 2 deletions src/tests/Common/tests.targets
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
</Target>

<Target Name="RunSingleMergedTest">
<Exec Command="chmod +x $(TestWrapperScript)" WorkingDirectory="$(BaseOutputPathWithConfig)" EchoOff="true" Condition="'$(TargetOS)' != 'windows'" />
<Exec Command="chmod +x $(TestWrapperScript)" WorkingDirectory="$(BaseOutputPathWithConfig)" EchoOff="true" Condition="'$(OS)' != 'Windows_NT'" />
<Exec Command="$(TestWrapperScript) &gt;$(RedirectOutputToFile) 2&gt;&amp;1" WorkingDirectory="$(BaseOutputPathWithConfig)" Timeout="$(__TestTimeout)" IgnoreExitCode="true">
<Output TaskParameter="ExitCode" PropertyName="MergedTestExitCode" />
</Exec>
Expand All @@ -70,7 +70,7 @@
-->
<Target Name="RunOneStandaloneRunnerTest" Returns="@(StandaloneRunnerResult)">

<Exec Command="chmod +x $(StandaloneRunnerScript)" WorkingDirectory="$(BaseOutputPathWithConfig)" EchoOff="true" Condition="'$(TargetOS)' != 'windows'" />
<Exec Command="chmod +x $(StandaloneRunnerScript)" WorkingDirectory="$(BaseOutputPathWithConfig)" EchoOff="true" Condition="'$(OS)' != 'Windows_NT'" />

<Exec Command="$(StandaloneRunnerScript) -usewatcher &gt;$(StandaloneRunnerScript).log 2&gt;&amp;1" WorkingDirectory="$(BaseOutputPathWithConfig)" Timeout="$(__TestTimeout)" IgnoreExitCode="true">
<Output TaskParameter="ExitCode" PropertyName="StandaloneRunnerExitCode" />
Expand Down
22 changes: 21 additions & 1 deletion src/tests/run.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand All @@ -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)
Expand Down Expand Up @@ -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%

Expand All @@ -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%
)
Expand Down Expand Up @@ -210,7 +229,7 @@ echo.
echo where:
echo.
echo./? -? /h -h /help -help - View this message.
echo ^<build_architecture^> - Specifies build architecture: x64, x86, or arm64 ^(default: x64^).
echo ^<build_architecture^> - Specifies build architecture: x64, x86, arm64, or wasm ^(default: x64^).
echo ^<build_type^> - Specifies build type: Debug, Release, or Checked ^(default: Debug^).
echo TestEnv ^<test_env_script^> - Run a custom script before every test to set custom test environment settings.
echo sequential - Run tests sequentially ^(no parallelism^).
Expand Down Expand Up @@ -248,4 +267,5 @@ echo.
echo Examples:
echo %0 x86 checked
echo %0 x64 release
echo %0 wasm debug
exit /b 1
25 changes: 13 additions & 12 deletions src/tests/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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,
Expand Down Expand Up @@ -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__()
Expand Down Expand Up @@ -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
Expand All @@ -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"
Expand All @@ -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
"""
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand this is for consistency, but these two options (before and after) should be equivalent.

test_name_wo_extension, test_name_extension = os.path.splitext(test_name)
if test_name_extension == ".cmd":
test_name = test_name_wo_extension + ".sh"
Expand Down
Loading