Skip to content

Commit 4767d23

Browse files
committed
run_tests: factor run_one_test to function
1 parent 1eba580 commit 4767d23

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

tests/run-tests

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,9 @@ def run_tests(pyb, tests, args, base_path="."):
354354
skip_tests.add('micropython/heapalloc_iter.py') # requires generators
355355
skip_tests.add('micropython/schedule.py') # native code doesn't check pending events
356356

357-
for test_file in tests:
357+
def run_one_test(test_file):
358+
nonlocal test_count, testcase_count, passed_count, failed_tests
359+
358360
test_file = test_file.replace('\\', '/')
359361
test_basename = os.path.basename(test_file)
360362
test_name = os.path.splitext(test_basename)[0]
@@ -377,7 +379,7 @@ def run_tests(pyb, tests, args, base_path="."):
377379
if skip_it:
378380
print("skip ", test_file)
379381
skipped_tests.append(test_name)
380-
continue
382+
return
381383

382384
# get expected output
383385
test_file_expected = test_file + '.exp'
@@ -405,15 +407,15 @@ def run_tests(pyb, tests, args, base_path="."):
405407
output_expected = output_expected.replace(b'\r\n', b'\n')
406408

407409
if args.write_exp:
408-
continue
410+
return
409411

410412
# run MicroPython
411413
output_mupy = run_micropython(pyb, args, test_file)
412414

413415
if output_mupy == b'SKIP\n':
414416
print("skip ", test_file)
415417
skipped_tests.append(test_name)
416-
continue
418+
return
417419

418420
testcase_count += len(output_expected.splitlines())
419421

@@ -439,6 +441,9 @@ def run_tests(pyb, tests, args, base_path="."):
439441

440442
test_count += 1
441443

444+
for test_file in tests:
445+
run_one_test(test_file)
446+
442447
print("{} tests performed ({} individual testcases)".format(test_count, testcase_count))
443448
print("{} tests passed".format(passed_count))
444449

0 commit comments

Comments
 (0)