From 3c63552628dfecdc5fedc76a9b37035eb0be1fc9 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Thu, 29 Jun 2023 07:08:53 -0700 Subject: [PATCH] Revert "aider: Refactor `run_unit_tests` to kill the subprocess when it times out." This reverts commit 663236797854b1802909ed0ed1d66bc8ed71baa6. --- benchmark/benchmark.py | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/benchmark/benchmark.py b/benchmark/benchmark.py index 9a1f54c26..746ff4a49 100755 --- a/benchmark/benchmark.py +++ b/benchmark/benchmark.py @@ -374,18 +374,23 @@ def run_unit_tests(testdir, history_fname): ] print(" ".join(command)) - with subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True) as proc: - try: - stdout, _ = proc.communicate(timeout=timeout) - if proc.returncode != 0: - all_tests_passed = False - print(f"Test {test_file} failed") - res = cleanup_test_output(stdout) - except subprocess.TimeoutExpired: - proc.kill() - proc.wait() + try: + result = subprocess.run( + command, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + text=True, + timeout=timeout, + ) + if result.returncode != 0: all_tests_passed = False - res = f"Test {test_file} timed out after {timeout} seconds." + print(f"Test {test_file} failed") + + res = cleanup_test_output(result.stdout) + + except subprocess.TimeoutExpired: + all_tests_passed = False + res = f"Test {test_file} timed out after {timeout} seconds." with history_fname.open("a") as fh: fh.write(f"```\n{res}\n```")