From b852c358283d3b8ff0a73410e7ce81509be381e2 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 29 Jun 2023 11:15:51 -0700 Subject: [PATCH] added back timeout --- benchmark/benchmark.py | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/benchmark/benchmark.py b/benchmark/benchmark.py index 6117587bd..d093a7ddc 100755 --- a/benchmark/benchmark.py +++ b/benchmark/benchmark.py @@ -369,20 +369,27 @@ def run_unit_tests(testdir, history_fname): ] print(" ".join(command)) - result = subprocess.run( - command, - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, - text=True, - ) - - res = result.stdout - res = cleanup_test_output(res) + timeout = 60 + try: + result = subprocess.run( + command, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + text=True, + timeout=timeout, + ) + except subprocess.TimeoutExpired: + success = False + res = f"Tests timed out after {timeout} secs!" + else: + success = result.returncode == 0 + res = result.stdout + res = cleanup_test_output(res) with history_fname.open("a") as fh: fh.write(f"```\n{res}\n```") - if result.returncode != 0: + if not success: print(f"Tests failed: {testdir}") return res