From e1059b5e4373517336a27e26a3f83c854b47cb89 Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Tue, 7 Jan 2025 16:55:18 +0100 Subject: [PATCH] Add a timeout to pexpect tests timeout nicer --- tests/test_driver.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/tests/test_driver.py b/tests/test_driver.py index f3cecbf0f..5deedc61b 100755 --- a/tests/test_driver.py +++ b/tests/test_driver.py @@ -169,11 +169,23 @@ def main(): print(f"{BLUE}SKIPPED{RESET}") skipcount += 1 continue - proc = subprocess.run( - ["python3", f], - capture_output=True, - env=pyenviron, - ) + try: + proc = subprocess.run( + ["python3", f], + capture_output=True, + env=pyenviron, + # Timeout of 90 seconds, about 9 times what any of these takes + timeout=90, + ) + except subprocess.TimeoutExpired as e: + print(f"{RED}FAILED due to timeout{RESET}") + if e.output: + print(e.output.decode("utf-8")) + if e.stderr: + print(e.stderr.decode("utf-8")) + failcount += 1 + continue + endtime = datetime.now() duration_ms = round((endtime - starttime).total_seconds() * 1000) if proc.returncode == 0: