Skip to content

Commit

Permalink
Rerun failed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
BoPeng committed Feb 12, 2024
1 parent cda86cd commit afb7701
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions test/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def get_testcases():
return tests


def run_tests(args, tests):
def run_tests(args, tests, show_output=False):
failed_tests = []
if not tests:
return failed_tests
Expand All @@ -40,7 +40,10 @@ def test_failed(test_names, return_code):

try:
ret = subprocess.run(
['pytest'] + list(tests), stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, timeout=60 * len(tests))
['pytest'] + list(tests),
stdout=None if show_output else subprocess.DEVNULL,
stderr=None if show_output else subprocess.DEVNULL,
timeout=60 * len(tests))
if ret.returncode != 0:
if len(tests) > 1:
for test in tests:
Expand Down Expand Up @@ -105,6 +108,10 @@ def test_failed(test_names, return_code):

if failed_tests:
print(f'Failed tests (logged to {LOGFILE}):\n' + '\n'.join(failed_tests))

for test in failed_tests:
print(f'\n\nRerunning {test}\n')
run_tests(args, [test], show_output=True)
else:
print(f'All {len(all_tests)} tests complete successfully.')
sys.exit(0 if not failed_tests else 1)

0 comments on commit afb7701

Please sign in to comment.