From 9d1b9ec582c56c09547ae8c95c62f7123963b206 Mon Sep 17 00:00:00 2001 From: Saurabh Misra Date: Tue, 29 Apr 2025 19:59:53 -0700 Subject: [PATCH 1/2] add more pytest plugins to blocklist --- codeflash/verification/test_runner.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/codeflash/verification/test_runner.py b/codeflash/verification/test_runner.py index 483695b1a..d4990ef56 100644 --- a/codeflash/verification/test_runner.py +++ b/codeflash/verification/test_runner.py @@ -15,8 +15,8 @@ if TYPE_CHECKING: from codeflash.models.models import TestFiles -BEHAVIORAL_BLOCKLISTED_PLUGINS = ["benchmark"] -BENCHMARKING_BLOCKLISTED_PLUGINS = ["codspeed", "cov", "benchmark", "profiling"] +BEHAVIORAL_BLOCKLISTED_PLUGINS = ["benchmark", "codspeed", "xdist", "sugar"] +BENCHMARKING_BLOCKLISTED_PLUGINS = ["codspeed", "cov", "benchmark", "profiling", "xdist", "sugar"] def execute_test_subprocess( @@ -141,6 +141,7 @@ def run_behavioral_tests( coverage_config_file if enable_coverage else None, ) + def run_line_profile_tests( test_paths: TestFiles, pytest_cmd: str, @@ -154,7 +155,6 @@ def run_line_profile_tests( pytest_min_loops: int = 5, pytest_max_loops: int = 100_000, line_profiler_output_file: Path | None = None, - ) -> tuple[Path, subprocess.CompletedProcess]: if test_framework == "pytest": pytest_cmd_list = ( @@ -191,7 +191,7 @@ def run_line_profile_tests( pytest_test_env = test_env.copy() pytest_test_env["PYTEST_PLUGINS"] = "codeflash.verification.pytest_plugin" blocklist_args = [f"-p no:{plugin}" for plugin in BENCHMARKING_BLOCKLISTED_PLUGINS] - pytest_test_env["LINE_PROFILE"]="1" + pytest_test_env["LINE_PROFILE"] = "1" results = execute_test_subprocess( pytest_cmd_list + pytest_args + blocklist_args + result_args + test_files, cwd=cwd, @@ -203,6 +203,7 @@ def run_line_profile_tests( raise ValueError(msg) return line_profiler_output_file, results + def run_benchmarking_tests( test_paths: TestFiles, pytest_cmd: str, From 9ce56d51ec5156ee6d3e6fc29eb8f4aa2856d7b7 Mon Sep 17 00:00:00 2001 From: Saurabh Misra Date: Tue, 29 Apr 2025 21:11:15 -0700 Subject: [PATCH 2/2] catch yet one more crash.. --- codeflash/verification/parse_test_output.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/codeflash/verification/parse_test_output.py b/codeflash/verification/parse_test_output.py index 2228559f9..7f8c34841 100644 --- a/codeflash/verification/parse_test_output.py +++ b/codeflash/verification/parse_test_output.py @@ -107,6 +107,7 @@ def parse_sqlite_test_results(sqlite_file_path: Path, test_files: TestFiles, tes logger.warning(f"No test results for {sqlite_file_path} found.") console.rule() return test_results + db = None try: db = sqlite3.connect(sqlite_file_path) cur = db.cursor() @@ -114,6 +115,11 @@ def parse_sqlite_test_results(sqlite_file_path: Path, test_files: TestFiles, tes "SELECT test_module_path, test_class_name, test_function_name, " "function_getting_tested, loop_index, iteration_id, runtime, return_value,verification_type FROM test_results" ).fetchall() + except Exception as e: + logger.warning(f"Failed to parse test results from {sqlite_file_path}. Exception: {e}") + if db is not None: + db.close() + return test_results finally: db.close() for val in data: