run_tests: factor run_one_test to function

This commit is contained in:
Jeff Epler 2018-03-31 09:08:37 -05:00
parent 1eba580443
commit 4767d23db3
1 changed files with 9 additions and 4 deletions

View File

@ -354,7 +354,9 @@ def run_tests(pyb, tests, args, base_path="."):
skip_tests.add('micropython/heapalloc_iter.py') # requires generators
skip_tests.add('micropython/schedule.py') # native code doesn't check pending events
for test_file in tests:
def run_one_test(test_file):
nonlocal test_count, testcase_count, passed_count, failed_tests
test_file = test_file.replace('\\', '/')
test_basename = os.path.basename(test_file)
test_name = os.path.splitext(test_basename)[0]
@ -377,7 +379,7 @@ def run_tests(pyb, tests, args, base_path="."):
if skip_it:
print("skip ", test_file)
skipped_tests.append(test_name)
continue
return
# get expected output
test_file_expected = test_file + '.exp'
@ -405,7 +407,7 @@ def run_tests(pyb, tests, args, base_path="."):
output_expected = output_expected.replace(b'\r\n', b'\n')
if args.write_exp:
continue
return
# run MicroPython
output_mupy = run_micropython(pyb, args, test_file)
@ -413,7 +415,7 @@ def run_tests(pyb, tests, args, base_path="."):
if output_mupy == b'SKIP\n':
print("skip ", test_file)
skipped_tests.append(test_name)
continue
return
testcase_count += len(output_expected.splitlines())
@ -439,6 +441,9 @@ def run_tests(pyb, tests, args, base_path="."):
test_count += 1
for test_file in tests:
run_one_test(test_file)
print("{} tests performed ({} individual testcases)".format(test_count, testcase_count))
print("{} tests passed".format(passed_count))