From 2ab88c3d5800dd85a6678d40e51e72edbda05301 Mon Sep 17 00:00:00 2001 From: stijn Date: Mon, 9 Feb 2026 11:53:35 +0100 Subject: [PATCH] tests/run-tests.py: Add an argument for showing which tests would run. This is convenient when trying to figure out the correct values for --include/--exclude/--test-dirs/... arguments. Signed-off-by: stijn --- tests/run-tests.py | 9 +++++++++ tests/test_utils.py | 16 +++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/tests/run-tests.py b/tests/run-tests.py index 22783dd7c6..1e1831d80d 100755 --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -887,6 +887,10 @@ def run_tests(pyb, tests, args, result_dir, num_threads=1): print("skip ", test_file) test_results.append((test_file, "skip", "")) return + elif args.dry_run: + print("found", test_file) + test_results.append((test_file, "found", "")) + return # Run the test on the MicroPython target. output_mupy = run_micropython(pyb, args, test_file, test_file_abspath) @@ -1109,6 +1113,11 @@ the last matching regex is used: dest="filters", help="include test by regex on path/name.py", ) + cmd_parser.add_argument( + "--dry-run", + action="store_true", + help="Show tests which would run (though might still be skipped at runtime)", + ) cmd_parser.add_argument( "--emit", default="bytecode", help="MicroPython emitter to use (bytecode or native)" ) diff --git a/tests/test_utils.py b/tests/test_utils.py index 326a220118..99b92ea7b3 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -313,15 +313,21 @@ def create_test_report(args, test_results, testcase_count=None): r for r in test_results if r[1] == "skip" and r[2] == "too large" ) failed_tests = list(r for r in test_results if r[1] == "fail") + dry_run = getattr(args, "dry_run", False) + if dry_run: + found_tests = list(r for r in test_results if r[1] == "found") num_tests_performed = len(passed_tests) + len(failed_tests) - testcase_count_info = "" - if testcase_count is not None: - testcase_count_info = " ({} individual testcases)".format(testcase_count) - print("{} tests performed{}".format(num_tests_performed, testcase_count_info)) + if dry_run: + print("{} tests found".format(len(found_tests))) + else: + testcase_count_info = "" + if testcase_count is not None: + testcase_count_info = " ({} individual testcases)".format(testcase_count) + print("{} tests performed{}".format(num_tests_performed, testcase_count_info)) - print("{} tests passed".format(len(passed_tests))) + print("{} tests passed".format(len(passed_tests))) if len(skipped_tests) > 0: print(