@@ -226,7 +226,7 @@ def run_feature_check(pyb, args, base_path, test_file):
226
226
return run_micropython (pyb , args , base_path ("feature_check" , test_file ), is_special = True )
227
227
228
228
229
- def run_tests (pyb , tests , args ):
229
+ def run_tests (pyb , tests , args , result_dir ):
230
230
test_count = 0
231
231
testcase_count = 0
232
232
passed_count = 0
@@ -521,8 +521,8 @@ def run_tests(pyb, tests, args):
521
521
522
522
testcase_count += len (output_expected .splitlines ())
523
523
524
- filename_expected = base_path ( test_basename + ".exp" )
525
- filename_mupy = base_path ( test_basename + ".out" )
524
+ filename_expected = os . path . join ( result_dir , test_basename + ".exp" )
525
+ filename_mupy = os . path . join ( result_dir , test_basename + ".out" )
526
526
527
527
if output_expected == output_mupy :
528
528
print ("pass " , test_file )
@@ -584,7 +584,7 @@ this directory.
584
584
When running tests, run-tests compares the MicroPython output of the test with the output
585
585
produced by running the test through CPython unless a <test>.exp file is found, in which
586
586
case it is used as comparison.
587
- If a test fails, run-tests produces a pair of <test>.out and <test>.exp files in the current
587
+ If a test fails, run-tests produces a pair of <test>.out and <test>.exp files in the result
588
588
directory with the MicroPython output and the expectations, respectively.
589
589
''' ,
590
590
epilog = '''\
@@ -601,6 +601,7 @@ the last matching regex is used:
601
601
cmd_parser .add_argument ('-u' , '--user' , default = 'micro' , help = 'the telnet login username' )
602
602
cmd_parser .add_argument ('-p' , '--password' , default = 'python' , help = 'the telnet login password' )
603
603
cmd_parser .add_argument ('-d' , '--test-dirs' , nargs = '*' , help = 'input test directories (if no files given)' )
604
+ cmd_parser .add_argument ('-r' , '--result-dir' , default = base_path ('results' ), help = 'directory for test results' )
604
605
cmd_parser .add_argument ('-e' , '--exclude' , action = append_filter , metavar = 'REGEX' , dest = 'filters' , help = 'exclude test by regex on path/name.py' )
605
606
cmd_parser .add_argument ('-i' , '--include' , action = append_filter , metavar = 'REGEX' , dest = 'filters' , help = 'include test by regex on path/name.py' )
606
607
cmd_parser .add_argument ('--write-exp' , action = 'store_true' , help = 'use CPython to generate .exp files to run tests w/o CPython' )
@@ -616,7 +617,7 @@ the last matching regex is used:
616
617
args = cmd_parser .parse_args ()
617
618
618
619
if args .print_failures :
619
- for exp in glob (base_path ( "*.exp" )):
620
+ for exp in glob (os . path . join ( args . result_dir , "*.exp" )):
620
621
testbase = exp [:- 4 ]
621
622
print ()
622
623
print ("FAILURE {0}" .format (testbase ))
@@ -625,7 +626,7 @@ the last matching regex is used:
625
626
sys .exit (0 )
626
627
627
628
if args .clean_failures :
628
- for f in glob (base_path ( "*.exp" )) + glob (base_path ( "*.out" )):
629
+ for f in glob (os . path . join ( args . result_dir , "*.exp" )) + glob (os . path . join ( args . result_dir , "*.out" )):
629
630
os .remove (f )
630
631
631
632
sys .exit (0 )
@@ -676,7 +677,8 @@ the last matching regex is used:
676
677
os .environ ['MICROPYPATH' ] = os .pathsep + base_path ('../extmod' )
677
678
678
679
try :
679
- res = run_tests (pyb , tests , args )
680
+ os .makedirs (args .result_dir , exist_ok = True )
681
+ res = run_tests (pyb , tests , args , args .result_dir )
680
682
finally :
681
683
if pyb :
682
684
pyb .close ()
0 commit comments