Skip to content

Commit d13b5c2

Browse files
committed
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 <stijn@ignitron.net>
1 parent 6ae08ea commit d13b5c2

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

tests/run-tests.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,10 @@ def run_one_test(test_file):
887887
print("skip ", test_file)
888888
test_results.append((test_file, "skip", ""))
889889
return
890+
elif args.dry_run:
891+
print("found", test_file)
892+
test_results.append((test_file, "found", ""))
893+
return
890894

891895
# Run the test on the MicroPython target.
892896
output_mupy = run_micropython(pyb, args, test_file, test_file_abspath)
@@ -1109,6 +1113,11 @@ def main():
11091113
dest="filters",
11101114
help="include test by regex on path/name.py",
11111115
)
1116+
cmd_parser.add_argument(
1117+
"--dry-run",
1118+
action="store_true",
1119+
help="Show tests which would run (though might still be skipped at runtime)",
1120+
)
11121121
cmd_parser.add_argument(
11131122
"--emit", default="bytecode", help="MicroPython emitter to use (bytecode or native)"
11141123
)

tests/test_utils.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -313,15 +313,21 @@ def create_test_report(args, test_results, testcase_count=None):
313313
r for r in test_results if r[1] == "skip" and r[2] == "too large"
314314
)
315315
failed_tests = list(r for r in test_results if r[1] == "fail")
316+
dry_run = getattr(args, "dry_run", False)
317+
if dry_run:
318+
found_tests = list(r for r in test_results if r[1] == "found")
316319

317320
num_tests_performed = len(passed_tests) + len(failed_tests)
318321

319-
testcase_count_info = ""
320-
if testcase_count is not None:
321-
testcase_count_info = " ({} individual testcases)".format(testcase_count)
322-
print("{} tests performed{}".format(num_tests_performed, testcase_count_info))
322+
if dry_run:
323+
print("{} tests found".format(len(found_tests)))
324+
else:
325+
testcase_count_info = ""
326+
if testcase_count is not None:
327+
testcase_count_info = " ({} individual testcases)".format(testcase_count)
328+
print("{} tests performed{}".format(num_tests_performed, testcase_count_info))
323329

324-
print("{} tests passed".format(len(passed_tests)))
330+
print("{} tests passed".format(len(passed_tests)))
325331

326332
if len(skipped_tests) > 0:
327333
print(

0 commit comments

Comments
 (0)