Add retries for boost unit test timeouts.
This commit is contained in:
parent
13f87fdebb
commit
e18d2ff314
1 changed files with 25 additions and 21 deletions
|
@ -22,15 +22,25 @@ def run_with_rerun_for_sdl_video(executable, test_name):
|
|||
# Sanity check on the number of retries.
|
||||
# It's a rare failure, a single retry would probably be enough.
|
||||
sdl_retries = 0
|
||||
while sdl_retries < 10:
|
||||
res = subprocess.run([executable, "--run_test="+test_name, "--color_output"], timeout=20, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
retry = False
|
||||
if b"Could not initialize SDL_video" in res.stdout:
|
||||
retry = True
|
||||
if not retry:
|
||||
timeout_retries = 0
|
||||
while sdl_retries < 10 and timeout_retries < 5:
|
||||
sdl_retry = False
|
||||
timeout_retry = False
|
||||
|
||||
try:
|
||||
res = subprocess.run([executable, "--run_test="+test_name, "--color_output"], timeout=20, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
except subprocess.TimeoutExpired as t:
|
||||
timeout_retries += 1
|
||||
timeout_retry = True
|
||||
print("Test timed out, attempt", timeout_retries)
|
||||
else:
|
||||
if b"Could not initialize SDL_video" in res.stdout:
|
||||
sdl_retries += 1
|
||||
sdl_retry = True
|
||||
print("Could not initialise SDL_video error, attempt", sdl_retries)
|
||||
|
||||
if not sdl_retry and not timeout_retry:
|
||||
return res
|
||||
sdl_retries += 1
|
||||
print("Could not initialise SDL_video error, attempt", sdl_retries)
|
||||
|
||||
if __name__ == '__main__':
|
||||
ap = argparse.ArgumentParser()
|
||||
|
@ -46,20 +56,14 @@ if __name__ == '__main__':
|
|||
failure=0
|
||||
|
||||
for test in tests:
|
||||
try:
|
||||
res = run_with_rerun_for_sdl_video(os.path.join(options.path, executable), test)
|
||||
except subprocess.TimeoutExpired as t:
|
||||
failure+=1
|
||||
output = str(t.output) or ""
|
||||
print("Test "+test+" timed out: "+output)
|
||||
res = run_with_rerun_for_sdl_video(os.path.join(options.path, executable), test)
|
||||
if res.returncode == 0:
|
||||
success+=1
|
||||
print("Test "+test+" passed")
|
||||
else:
|
||||
if res.returncode == 0:
|
||||
success+=1
|
||||
print("Test "+test+" passed")
|
||||
else:
|
||||
failure+=1
|
||||
print("Test "+test+" failed with return code "+str(res.returncode)+":")
|
||||
print(res.stdout.decode('utf-8'))
|
||||
failure+=1
|
||||
print("Test "+test+" failed with return code "+str(res.returncode)+":")
|
||||
print(res.stdout.decode('utf-8'))
|
||||
|
||||
print("Tests passed: "+str(success))
|
||||
print("Tests failed: "+str(failure))
|
||||
|
|
Loading…
Add table
Reference in a new issue