Skip to content

Commit 7c78efd

Browse files
committed
When parsing results, we use the Coverage class. we need to pass in the config file to this class too.
1 parent eaa30aa commit 7c78efd

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

codeflash/models/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,13 +225,13 @@ class CoverageData:
225225

226226
@staticmethod
227227
def load_from_sqlite_database(
228-
database_path: Path, function_name: str, code_context: CodeOptimizationContext, source_code_path: Path
228+
database_path: Path, config_path: Path, function_name: str, code_context: CodeOptimizationContext, source_code_path: Path
229229
) -> CoverageData:
230230
"""Load coverage data from an SQLite database, mimicking the behavior of load_from_coverage_file."""
231231
from coverage import Coverage
232232
from coverage.jsonreport import JsonReporter
233233

234-
cov = Coverage(data_file=database_path, data_suffix=True, auto_data=True, branch=True)
234+
cov = Coverage(data_file=database_path,config_file=config_path, data_suffix=True, auto_data=True, branch=True)
235235

236236
if not database_path.stat().st_size or not database_path.exists():
237237
logger.debug(f"Coverage database {database_path} is empty or does not exist")

codeflash/optimization/function_optimizer.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1064,9 +1064,10 @@ def run_and_parse_tests(
10641064
unittest_loop_index: int | None = None,
10651065
) -> tuple[TestResults, CoverageData | None]:
10661066
coverage_database_file = None
1067+
coverage_config_file = None
10671068
try:
10681069
if testing_type == TestingMode.BEHAVIOR:
1069-
result_file_path, run_result, coverage_database_file = run_behavioral_tests(
1070+
result_file_path, run_result, coverage_database_file, coverage_config_file = run_behavioral_tests(
10701071
test_files,
10711072
test_framework=self.test_cfg.test_framework,
10721073
cwd=self.project_root,
@@ -1114,6 +1115,7 @@ def run_and_parse_tests(
11141115
source_file=self.function_to_optimize.file_path,
11151116
code_context=code_context,
11161117
coverage_database_file=coverage_database_file,
1118+
coverage_config_file=coverage_config_file,
11171119
)
11181120
return results, coverage_results
11191121

codeflash/verification/parse_test_output.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,7 @@ def parse_test_results(
478478
function_name: str | None,
479479
source_file: Path | None,
480480
coverage_database_file: Path | None,
481+
coverage_config_file: Path | None,
481482
code_context: CodeOptimizationContext | None = None,
482483
run_result: subprocess.CompletedProcess | None = None,
483484
unittest_loop_index: int | None = None,
@@ -523,6 +524,7 @@ def parse_test_results(
523524
all_args = True
524525
coverage = CoverageData.load_from_sqlite_database(
525526
database_path=coverage_database_file,
527+
config_path=coverage_config_file,
526528
source_code_path=source_file,
527529
code_context=code_context,
528530
function_name=function_name,

0 commit comments

Comments
 (0)