15
15
import subprocess
16
16
import tempfile
17
17
18
+ run_tests_module = __import__ ("run-tests" )
19
+
18
20
test_dir = os .path .abspath (os .path .dirname (__file__ ))
19
21
20
22
if os .path .abspath (sys .path [0 ]) == test_dir :
@@ -488,9 +490,7 @@ def print_diff(a, b):
488
490
489
491
490
492
def run_tests (test_files , instances_truth , instances_test ):
491
- skipped_tests = []
492
- passed_tests = []
493
- failed_tests = []
493
+ test_results = []
494
494
495
495
for test_file , num_instances in test_files :
496
496
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):
526
526
# Print result of test
527
527
if skip :
528
528
print ("skip" )
529
- skipped_tests .append (test_file )
529
+ test_results .append (( test_file , "skip" , "" ) )
530
530
elif output_test == output_truth :
531
531
print ("pass" )
532
- passed_tests .append (test_file )
532
+ test_results .append (( test_file , "pass" , "" ) )
533
533
else :
534
534
print ("FAIL" )
535
- failed_tests .append (test_file )
535
+ test_results .append (( test_file , "fail" , "" ) )
536
536
if not cmd_args .show_output :
537
537
print ("### TEST ###" )
538
538
print (output_test , end = "" )
@@ -549,15 +549,7 @@ def run_tests(test_files, instances_truth, instances_test):
549
549
if cmd_args .show_output :
550
550
print ()
551
551
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
561
553
562
554
563
555
def main ():
@@ -583,6 +575,12 @@ def main():
583
575
default = 1 ,
584
576
help = "repeat the test with this many permutations of the instance order" ,
585
577
)
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
+ )
586
584
cmd_parser .epilog = (
587
585
"Supported instance types:\r \n "
588
586
" -i pyb:<port> physical device (eg. pyboard) on provided repl port.\n "
@@ -623,13 +621,15 @@ def main():
623
621
for _ in range (max_instances - len (instances_test )):
624
622
instances_test .append (PyInstanceSubProcess ([MICROPYTHON ]))
625
623
624
+ os .makedirs (cmd_args .result_dir , exist_ok = True )
626
625
all_pass = True
627
626
try :
628
627
for i , instances_test_permutation in enumerate (itertools .permutations (instances_test )):
629
628
if i >= cmd_args .permutations :
630
629
break
631
630
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 )
633
633
634
634
finally :
635
635
for i in instances_truth :
0 commit comments