Skip to content

Commit 6db9c80

Browse files
committed
tests/run-multitests.py: Create a _result.json at end of run.
Reuse the `create_test_report()` function from `run-tests.py` to generate a `_result.json` file summarising the test run. If there's more than one permutation of the test run, only the last result is saved. Signed-off-by: Damien George <[email protected]>
1 parent 2bc5af6 commit 6db9c80

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

tests/run-multitests.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
import subprocess
1616
import tempfile
1717

18+
run_tests_module = __import__("run-tests")
19+
1820
test_dir = os.path.abspath(os.path.dirname(__file__))
1921

2022
if os.path.abspath(sys.path[0]) == test_dir:
@@ -488,9 +490,7 @@ def print_diff(a, b):
488490

489491

490492
def run_tests(test_files, instances_truth, instances_test):
491-
skipped_tests = []
492-
passed_tests = []
493-
failed_tests = []
493+
test_results = []
494494

495495
for test_file, num_instances in test_files:
496496
instances_str = "|".join(str(instances_test[i]) for i in range(num_instances))
@@ -526,13 +526,13 @@ def run_tests(test_files, instances_truth, instances_test):
526526
# Print result of test
527527
if skip:
528528
print("skip")
529-
skipped_tests.append(test_file)
529+
test_results.append((test_file, "skip", ""))
530530
elif output_test == output_truth:
531531
print("pass")
532-
passed_tests.append(test_file)
532+
test_results.append((test_file, "pass", ""))
533533
else:
534534
print("FAIL")
535-
failed_tests.append(test_file)
535+
test_results.append((test_file, "fail", ""))
536536
if not cmd_args.show_output:
537537
print("### TEST ###")
538538
print(output_test, end="")
@@ -549,15 +549,7 @@ def run_tests(test_files, instances_truth, instances_test):
549549
if cmd_args.show_output:
550550
print()
551551

552-
print("{} tests performed".format(len(skipped_tests) + len(passed_tests) + len(failed_tests)))
553-
print("{} tests passed".format(len(passed_tests)))
554-
555-
if skipped_tests:
556-
print("{} tests skipped: {}".format(len(skipped_tests), " ".join(skipped_tests)))
557-
if failed_tests:
558-
print("{} tests failed: {}".format(len(failed_tests), " ".join(failed_tests)))
559-
560-
return not failed_tests
552+
return test_results
561553

562554

563555
def main():
@@ -583,6 +575,12 @@ def main():
583575
default=1,
584576
help="repeat the test with this many permutations of the instance order",
585577
)
578+
cmd_parser.add_argument(
579+
"-r",
580+
"--result-dir",
581+
default=run_tests_module.base_path("results"),
582+
help="directory for test results",
583+
)
586584
cmd_parser.epilog = (
587585
"Supported instance types:\r\n"
588586
" -i pyb:<port> physical device (eg. pyboard) on provided repl port.\n"
@@ -623,13 +621,15 @@ def main():
623621
for _ in range(max_instances - len(instances_test)):
624622
instances_test.append(PyInstanceSubProcess([MICROPYTHON]))
625623

624+
os.makedirs(cmd_args.result_dir, exist_ok=True)
626625
all_pass = True
627626
try:
628627
for i, instances_test_permutation in enumerate(itertools.permutations(instances_test)):
629628
if i >= cmd_args.permutations:
630629
break
631630

632-
all_pass &= run_tests(test_files, instances_truth, instances_test_permutation)
631+
test_results = run_tests(test_files, instances_truth, instances_test_permutation)
632+
all_pass &= run_tests_module.create_test_report(cmd_args, test_results)
633633

634634
finally:
635635
for i in instances_truth:

0 commit comments

Comments
 (0)