From afd3177dfab6bdfce8cb960840609a027f0d3fef Mon Sep 17 00:00:00 2001
From: Jackson Schuster <36744439+jtschuster@users.noreply.github.com>
Date: Thu, 26 Mar 2026 18:45:58 -0700
Subject: [PATCH 1/5] Add --tree flag to run.sh/run.cmd to filter test
execution by subtree
The build.sh -tree flag allows building a subtree of tests, but run.sh
had no equivalent for running a subset. This meant users had to either
run the entire test suite or manually configure test paths.
Add a --tree flag to run.sh, run.cmd, and run.py that passes a
TestSubtree MSBuild property to tests.targets. When set, the test
discovery globs are scoped to the specified subtree directory instead
of scanning the entire output tree.
Example usage:
src/tests/run.sh checked --tree=JIT/Regression
src/tests/run.cmd checked tree JIT\Regression
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
src/tests/Common/tests.targets | 7 +++++--
src/tests/run.cmd | 6 ++++++
src/tests/run.py | 9 +++++++++
src/tests/run.sh | 10 ++++++++++
4 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/src/tests/Common/tests.targets b/src/tests/Common/tests.targets
index 71765167f1a7c8..ebb91bc6e13bad 100644
--- a/src/tests/Common/tests.targets
+++ b/src/tests/Common/tests.targets
@@ -9,12 +9,15 @@
$(BaseOutputPathWithConfig)\tests\
<__TestRunHtmlLog Condition="'$(__TestRunHtmlLog)' == ''">$(__LogsDir)\TestRun.html
<__TestRunXmlLog Condition="'$(__TestRunXmlLog)' == ''">$(__LogsDir)\TestRun.xml
+
+ <_TestSearchRoot Condition="'$(TestSubtree)' == ''">$(BaseOutputPathWithConfig)\**
+ <_TestSearchRoot Condition="'$(TestSubtree)' != ''">$(BaseOutputPathWithConfig)\$(TestSubtree)\**
- <_StandaloneRunnerMarker Include="$(BaseOutputPathWithConfig)\**\*.StandaloneTestRunner" />
+ <_StandaloneRunnerMarker Include="$(_TestSearchRoot)\*.StandaloneTestRunner" />
$([System.IO.Path]::ChangeExtension('%(MergedTestWrapperScripts.Identity)', '.log'))
@@ -24,7 +27,7 @@
- <_MergedTestAssemblyMarkers Include="$(BaseOutputPathWithConfig)\**\*.MergedTestAssembly" />
+ <_MergedTestAssemblyMarkers Include="$(_TestSearchRoot)\*.MergedTestAssembly" />
$([System.IO.Path]::ChangeExtension('%(MergedTestWrapperScripts.Identity)', '.log'))
diff --git a/src/tests/run.cmd b/src/tests/run.cmd
index 56666656a7bf5e..2db201ec675f8a 100644
--- a/src/tests/run.cmd
+++ b/src/tests/run.cmd
@@ -79,6 +79,7 @@ if /i "%1" == "tieringtest" (set TieringTest=1&shift
if /i "%1" == "runnativeaottests" (set RunNativeAot=1&shift&goto Arg_Loop)
if /i "%1" == "interpreter" (set RunInterpreter=1&shift&goto Arg_Loop)
if /i "%1" == "node" (set RunWithNodeJS=1&shift&goto Arg_Loop)
+if /i "%1" == "tree" (set __TreeSubtree=%2&shift&shift&goto Arg_Loop)
if /i not "%1" == "msbuildargs" goto SkipMsbuildArgs
:: All the rest of the args will be collected and passed directly to msbuild.
@@ -195,6 +196,10 @@ if defined RunWithNodeJS (
set __RuntestPyArgs=%__RuntestPyArgs% --node
)
+if defined __TreeSubtree (
+ set __RuntestPyArgs=%__RuntestPyArgs% --tree %__TreeSubtree%
+)
+
REM Find python and set it to the variable PYTHON
set _C=-c "import sys; sys.stdout.write(sys.executable)"
(py -3 %_C% || py -2 %_C% || python3 %_C% || python2 %_C% || python %_C%) > %TEMP%\pythonlocation.txt 2> NUL
@@ -261,6 +266,7 @@ echo msbuildargs ^ - Pass all subsequent args directly to msbuild
echo ^ - Path to the runtime to test ^(if specified^).
echo interpreter - Runs the tests with the interpreter enabled.
echo node - Runs the tests with NodeJS ^(wasm only^).
+echo tree ^ - Only run tests under the specified subtree ^(e.g. JIT/Regression^).
echo.
echo Note that arguments are not case-sensitive.
echo.
diff --git a/src/tests/run.py b/src/tests/run.py
index 21b2f47eb9bb20..1cfc74d4c6ec51 100755
--- a/src/tests/run.py
+++ b/src/tests/run.py
@@ -114,6 +114,7 @@
parser.add_argument("--run_in_context", dest="run_in_context", action="store_true", default=False)
parser.add_argument("--tiering_test", dest="tiering_test", action="store_true", default=False)
parser.add_argument("--run_nativeaot_tests", dest="run_nativeaot_tests", action="store_true", default=False)
+parser.add_argument("--tree", dest="tree", default=None, help="Only run tests under the specified subtree (e.g. JIT/Regression).")
################################################################################
# Globals
@@ -575,6 +576,9 @@ def call_msbuild(args):
if args.limited_core_dumps:
command += ["/p:LimitedCoreDumps=true"]
+ if args.tree:
+ command += ["/p:TestSubtree=%s" % args.tree]
+
print(" ".join(command))
sys.stdout.flush() # flush output before creating sub-process
@@ -1019,6 +1023,11 @@ def setup_args(args):
lambda arg: True,
"Error setting run_nativeaot_tests")
+ coreclr_setup_args.verify(args,
+ "tree",
+ lambda arg: True,
+ "Error setting tree")
+
coreclr_setup_args.verify(args,
"interpreter",
lambda arg: True,
diff --git a/src/tests/run.sh b/src/tests/run.sh
index 5c3d2b53b991c1..a7f34e67f2e26e 100755
--- a/src/tests/run.sh
+++ b/src/tests/run.sh
@@ -43,6 +43,7 @@ function print_usage {
echo ' --runnativeaottests : Run NativeAOT compiled tests'
echo ' --interpreter : Runs the tests with the interpreter enabled'
echo ' --node : Runs the tests with NodeJS (wasm only)'
+ echo ' --tree= : Only run tests under the specified subtree (e.g. JIT/Regression)'
echo ' --limitedDumpGeneration : '
}
@@ -73,6 +74,7 @@ runSequential=0
runincontext=0
tieringtest=0
nativeaottest=0
+treeSubtree=
for i in "$@"
do
@@ -189,6 +191,9 @@ do
--runnativeaottests)
nativeaottest=1
;;
+ --tree=*)
+ treeSubtree=${i#*=}
+ ;;
--interpreter)
export RunInterpreter=1
;;
@@ -316,6 +321,11 @@ if [[ -n "$RunWithNodeJS" ]]; then
runtestPyArguments+=("--node")
fi
+if [[ -n "$treeSubtree" ]]; then
+ echo "Running tests under subtree : ${treeSubtree}"
+ runtestPyArguments+=("--tree" "$treeSubtree")
+fi
+
# Default to python3 if it is installed
__Python=python
if command -v python3 &>/dev/null; then
From 5da961875fd5020e4910303433c37dee370a9dfd Mon Sep 17 00:00:00 2001
From: Jackson Schuster <36744439+jtschuster@users.noreply.github.com>
Date: Thu, 26 Mar 2026 19:30:08 -0700
Subject: [PATCH 2/5] Improve error message when --tree matches no tests
When TestSubtree is set but no tests are found, show a specific error
mentioning the subtree path instead of the generic 'Tests must be built'
message, which would be misleading in this case.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
src/tests/Common/tests.targets | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/tests/Common/tests.targets b/src/tests/Common/tests.targets
index ebb91bc6e13bad..dbf46c9d45dc6d 100644
--- a/src/tests/Common/tests.targets
+++ b/src/tests/Common/tests.targets
@@ -43,7 +43,9 @@
+ Condition="'$(TestSubtree)' == '' and '@(StandaloneRunnerScripts)' == '' and '@(MergedTestWrapperScripts)' == ''" />
+
From 64e7b354c3d5e1355220c1be075b89eb130e47eb Mon Sep 17 00:00:00 2001
From: Jackson Schuster <36744439+jtschuster@users.noreply.github.com>
Date: Sat, 28 Mar 2026 10:24:35 -0700
Subject: [PATCH 3/5] Update src/tests/run.cmd
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
---
src/tests/run.cmd | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/tests/run.cmd b/src/tests/run.cmd
index 2db201ec675f8a..6b5b8a15f9087a 100644
--- a/src/tests/run.cmd
+++ b/src/tests/run.cmd
@@ -197,7 +197,7 @@ if defined RunWithNodeJS (
)
if defined __TreeSubtree (
- set __RuntestPyArgs=%__RuntestPyArgs% --tree %__TreeSubtree%
+ set __RuntestPyArgs=%__RuntestPyArgs% --tree "%__TreeSubtree%"
)
REM Find python and set it to the variable PYTHON
From ccf9c09e9ac0df7f19afeabe131d87aa0a323d2b Mon Sep 17 00:00:00 2001
From: Jackson Schuster <36744439+jtschuster@users.noreply.github.com>
Date: Mon, 30 Mar 2026 11:14:37 -0700
Subject: [PATCH 4/5] Update src/tests/Common/tests.targets
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
---
src/tests/Common/tests.targets | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/tests/Common/tests.targets b/src/tests/Common/tests.targets
index dbf46c9d45dc6d..3e54b0671210eb 100644
--- a/src/tests/Common/tests.targets
+++ b/src/tests/Common/tests.targets
@@ -44,7 +44,7 @@
DependsOnTargets="FindBuildAllTestsAsStandaloneRunnerScripts;FindMergedTestDirectories">
-
From 0153dd0b67e7f3783eb2b64dee2e5ec05396ac9a Mon Sep 17 00:00:00 2001
From: Jackson Schuster <36744439+jtschuster@users.noreply.github.com>
Date: Mon, 30 Mar 2026 11:26:01 -0700
Subject: [PATCH 5/5] Accept -tree/--tree//tree prefixes in run.cmd and run.sh
run.cmd: Normalize '/', '-', '--' prefixes for the tree argument
like build.cmd does, and quote the value when passing to run.py.
run.sh: Accept --tree , --tree:, and -tree variants
in addition to --tree=, matching build.sh conventions.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
src/tests/run.cmd | 8 ++++++--
src/tests/run.sh | 14 +++++++++++++-
2 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/src/tests/run.cmd b/src/tests/run.cmd
index 2db201ec675f8a..f8aeda3a9ea99a 100644
--- a/src/tests/run.cmd
+++ b/src/tests/run.cmd
@@ -79,7 +79,11 @@ if /i "%1" == "tieringtest" (set TieringTest=1&shift
if /i "%1" == "runnativeaottests" (set RunNativeAot=1&shift&goto Arg_Loop)
if /i "%1" == "interpreter" (set RunInterpreter=1&shift&goto Arg_Loop)
if /i "%1" == "node" (set RunWithNodeJS=1&shift&goto Arg_Loop)
-if /i "%1" == "tree" (set __TreeSubtree=%2&shift&shift&goto Arg_Loop)
+@REM For tree, support '/', '-', and '--' prefixes like build.cmd
+set __treeArg=%~1
+set __treeArg=%__treeArg:/=%
+set __treeArg=%__treeArg:-=%
+if /i "%__treeArg%" == "tree" (set __TreeSubtree=%~2&shift&shift&goto Arg_Loop)
if /i not "%1" == "msbuildargs" goto SkipMsbuildArgs
:: All the rest of the args will be collected and passed directly to msbuild.
@@ -197,7 +201,7 @@ if defined RunWithNodeJS (
)
if defined __TreeSubtree (
- set __RuntestPyArgs=%__RuntestPyArgs% --tree %__TreeSubtree%
+ set __RuntestPyArgs=%__RuntestPyArgs% --tree "%__TreeSubtree%"
)
REM Find python and set it to the variable PYTHON
diff --git a/src/tests/run.sh b/src/tests/run.sh
index a7f34e67f2e26e..45c68d304fec3a 100755
--- a/src/tests/run.sh
+++ b/src/tests/run.sh
@@ -78,6 +78,12 @@ treeSubtree=
for i in "$@"
do
+ if [[ "$__nextTreeArg" == "1" ]]; then
+ treeSubtree="$i"
+ __nextTreeArg=
+ continue
+ fi
+
case $i in
-h|--help)
print_usage
@@ -191,9 +197,15 @@ do
--runnativeaottests)
nativeaottest=1
;;
- --tree=*)
+ --tree=*|-tree=*)
treeSubtree=${i#*=}
;;
+ --tree:*|-tree:*)
+ treeSubtree=${i#*:}
+ ;;
+ --tree|-tree)
+ __nextTreeArg=1
+ ;;
--interpreter)
export RunInterpreter=1
;;