From c5919f0c15356ba741914e439d72a017ef80e082 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Sat, 4 Jan 2025 10:55:11 -0800 Subject: [PATCH] refactor: improve cleanup error handling and verbose logging --- benchmark/benchmark.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/benchmark/benchmark.py b/benchmark/benchmark.py index efbb3a466..51050b13a 100755 --- a/benchmark/benchmark.py +++ b/benchmark/benchmark.py @@ -859,28 +859,33 @@ def run_test_real( if target_dir.exists(): try: shutil.rmtree(target_dir) - print(f"Cleaned up Rust target/debug directory: {target_dir}") - except Exception as e: - # ignore all these exceptions on cleanup. ai! - print(f"Failed to clean up Rust target/debug directory: {e}") + if verbose: + print(f"Cleaned up Rust target/debug directory: {target_dir}") + except (OSError, shutil.Error, PermissionError) as e: + if verbose: + print(f"Failed to clean up Rust target/debug directory: {e}") # Java build directories java_build_dir = testdir / "build" if java_build_dir.exists(): try: shutil.rmtree(java_build_dir) - print(f"Cleaned up Java build directory: {java_build_dir}") - except Exception as e: - print(f"Failed to clean up Java build directory: {e}") + if verbose: + print(f"Cleaned up Java build directory: {java_build_dir}") + except (OSError, shutil.Error, PermissionError) as e: + if verbose: + print(f"Failed to clean up Java build directory: {e}") # Node.js node_modules directories node_modules_dir = testdir / "node_modules" if node_modules_dir.exists(): try: shutil.rmtree(node_modules_dir) - print(f"Cleaned up Node.js node_modules directory: {node_modules_dir}") - except Exception as e: - print(f"Failed to clean up Node.js node_modules directory: {e}") + if verbose: + print(f"Cleaned up Node.js node_modules directory: {node_modules_dir}") + except (OSError, shutil.Error, PermissionError) as e: + if verbose: + print(f"Failed to clean up Node.js node_modules directory: {e}") results = dict( testdir=str(testdir),