From 39fadf51f88d6e4977c309c6a36bd9065d2d3155 Mon Sep 17 00:00:00 2001 From: Jackson Schuster <36744439+jtschuster@users.noreply.github.com> Date: Mon, 23 Feb 2026 10:57:48 -0800 Subject: [PATCH 1/4] Clean stale test results before running tests When a test run crashes, run.py would read stale testRun.xml files from a previous run, reporting old passing results instead of an error. Fix by: 1. Deleting old test result files before running tests. 2. Returning failure (exit code 1) when tests were run but no result files were produced, indicating the run likely crashed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/tests/run.py | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/src/tests/run.py b/src/tests/run.py index 244e2dd6c8fedb..9c07f9999a7258 100755 --- a/src/tests/run.py +++ b/src/tests/run.py @@ -1201,6 +1201,26 @@ def dir_has_nested_substrings(test_path, test_item): return location +def clean_test_results(logs_dir): + """ Remove old test result files from the logs directory so that stale + results from a previous run are not mistakenly parsed if the current + run crashes before producing new results. + + Args: + logs_dir : path to the logs directory + """ + if not os.path.isdir(logs_dir): + return + + for item in os.listdir(logs_dir): + item_lower = item.lower() + if item_lower.endswith("testrun.xml") or item_lower == "standalonerunnertestresults.testrun.log": + file_path = os.path.join(logs_dir, item) + try: + os.remove(file_path) + except OSError as e: + print("Warning: failed to remove old result file %s: %s" % (file_path, e)) + def parse_test_results(args, tests, assemblies): """ Parse the test results for test execution information @@ -1208,6 +1228,9 @@ def parse_test_results(args, tests, assemblies): args : arguments tests : list of individual test results (filled in by this function) assemblies : dictionary of per-assembly aggregations (filled in by this function) + + Returns: + True if test result files were found, False otherwise. """ print("Parsing test results from (%s)" % args.logs_dir) @@ -1229,6 +1252,8 @@ def parse_test_results(args, tests, assemblies): print("Unable to find testRun.xml or StandaloneRunnerTestResults.testrun.log. This normally means the tests did not run.") print("It could also mean there was a problem logging. Please run the tests again.") + return found + def parse_standalone_runner_results_file(args, item, tests, assemblies): """ Parse test results from a standalone runner results log file @@ -1504,6 +1529,7 @@ def main(args): env = get_environment(test_env=args.test_env) if not args.analyze_results_only: + clean_test_results(args.logs_dir) if args.test_env is not None: ret_code = run_tests(args, args.test_env) else: @@ -1514,10 +1540,16 @@ def main(args): assemblies = defaultdict(lambda: None) tests = [] - parse_test_results(args, tests, assemblies) + found_results = parse_test_results(args, tests, assemblies) print_summary(tests, assemblies) repro_count = create_repro(args, env, tests) + # If we actually ran tests but found no result files, the test run + # likely crashed. Make sure we report failure. + if not args.analyze_results_only and not found_results and ret_code == 0: + print("Error: test run completed but no test result files were found. The test run may have crashed.") + ret_code = 1 + print("") print("Log files at: %s" % args.logs_dir) if repro_count > 0: From 4ab3eecdaa0013028be3caaa0703bcff1606d037 Mon Sep 17 00:00:00 2001 From: Jackson Schuster <36744439+jtschuster@users.noreply.github.com> Date: Mon, 23 Feb 2026 12:44:50 -0800 Subject: [PATCH 2/4] Use ContinueOnError instead of reporting a failure as a message --- src/tests/Common/tests.targets | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tests/Common/tests.targets b/src/tests/Common/tests.targets index 1d81103b1ec578..a13ba701a49414 100644 --- a/src/tests/Common/tests.targets +++ b/src/tests/Common/tests.targets @@ -47,7 +47,7 @@ - + @@ -72,7 +72,7 @@ - + From 3878f8615bed05d3466b3498ae628149fba7d701 Mon Sep 17 00:00:00 2001 From: Jackson Schuster <36744439+jtschuster@users.noreply.github.com> Date: Mon, 23 Feb 2026 12:54:04 -0800 Subject: [PATCH 3/4] Fix output redirection formatting in test execution targets --- src/tests/Common/tests.targets | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/tests/Common/tests.targets b/src/tests/Common/tests.targets index a13ba701a49414..919c37cf239af3 100644 --- a/src/tests/Common/tests.targets +++ b/src/tests/Common/tests.targets @@ -47,11 +47,10 @@ - + - @@ -72,7 +71,7 @@ - + From 00efb62db31467f050f929f04d1bdc93dd689112 Mon Sep 17 00:00:00 2001 From: Jackson Schuster <36744439+jtschuster@users.noreply.github.com> Date: Mon, 23 Feb 2026 12:56:58 -0800 Subject: [PATCH 4/4] Revert changes to python script --- src/tests/run.py | 34 +--------------------------------- 1 file changed, 1 insertion(+), 33 deletions(-) diff --git a/src/tests/run.py b/src/tests/run.py index 9c07f9999a7258..244e2dd6c8fedb 100755 --- a/src/tests/run.py +++ b/src/tests/run.py @@ -1201,26 +1201,6 @@ def dir_has_nested_substrings(test_path, test_item): return location -def clean_test_results(logs_dir): - """ Remove old test result files from the logs directory so that stale - results from a previous run are not mistakenly parsed if the current - run crashes before producing new results. - - Args: - logs_dir : path to the logs directory - """ - if not os.path.isdir(logs_dir): - return - - for item in os.listdir(logs_dir): - item_lower = item.lower() - if item_lower.endswith("testrun.xml") or item_lower == "standalonerunnertestresults.testrun.log": - file_path = os.path.join(logs_dir, item) - try: - os.remove(file_path) - except OSError as e: - print("Warning: failed to remove old result file %s: %s" % (file_path, e)) - def parse_test_results(args, tests, assemblies): """ Parse the test results for test execution information @@ -1228,9 +1208,6 @@ def parse_test_results(args, tests, assemblies): args : arguments tests : list of individual test results (filled in by this function) assemblies : dictionary of per-assembly aggregations (filled in by this function) - - Returns: - True if test result files were found, False otherwise. """ print("Parsing test results from (%s)" % args.logs_dir) @@ -1252,8 +1229,6 @@ def parse_test_results(args, tests, assemblies): print("Unable to find testRun.xml or StandaloneRunnerTestResults.testrun.log. This normally means the tests did not run.") print("It could also mean there was a problem logging. Please run the tests again.") - return found - def parse_standalone_runner_results_file(args, item, tests, assemblies): """ Parse test results from a standalone runner results log file @@ -1529,7 +1504,6 @@ def main(args): env = get_environment(test_env=args.test_env) if not args.analyze_results_only: - clean_test_results(args.logs_dir) if args.test_env is not None: ret_code = run_tests(args, args.test_env) else: @@ -1540,16 +1514,10 @@ def main(args): assemblies = defaultdict(lambda: None) tests = [] - found_results = parse_test_results(args, tests, assemblies) + parse_test_results(args, tests, assemblies) print_summary(tests, assemblies) repro_count = create_repro(args, env, tests) - # If we actually ran tests but found no result files, the test run - # likely crashed. Make sure we report failure. - if not args.analyze_results_only and not found_results and ret_code == 0: - print("Error: test run completed but no test result files were found. The test run may have crashed.") - ret_code = 1 - print("") print("Log files at: %s" % args.logs_dir) if repro_count > 0: