Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions codeflash/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,13 @@ class CoverageData:

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

cov = Coverage(data_file=database_path, data_suffix=True, auto_data=True, branch=True)
cov = Coverage(data_file=database_path,config_file=config_path, data_suffix=True, auto_data=True, branch=True)

if not database_path.stat().st_size or not database_path.exists():
logger.debug(f"Coverage database {database_path} is empty or does not exist")
Expand Down
4 changes: 3 additions & 1 deletion codeflash/optimization/function_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1064,9 +1064,10 @@ def run_and_parse_tests(
unittest_loop_index: int | None = None,
) -> tuple[TestResults, CoverageData | None]:
coverage_database_file = None
coverage_config_file = None
try:
if testing_type == TestingMode.BEHAVIOR:
result_file_path, run_result, coverage_database_file = run_behavioral_tests(
result_file_path, run_result, coverage_database_file, coverage_config_file = run_behavioral_tests(
test_files,
test_framework=self.test_cfg.test_framework,
cwd=self.project_root,
Expand Down Expand Up @@ -1114,6 +1115,7 @@ def run_and_parse_tests(
source_file=self.function_to_optimize.file_path,
code_context=code_context,
coverage_database_file=coverage_database_file,
coverage_config_file=coverage_config_file,
)
return results, coverage_results

Expand Down
2 changes: 2 additions & 0 deletions codeflash/verification/parse_test_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,7 @@ def parse_test_results(
function_name: str | None,
source_file: Path | None,
coverage_database_file: Path | None,
coverage_config_file: Path | None,
code_context: CodeOptimizationContext | None = None,
run_result: subprocess.CompletedProcess | None = None,
unittest_loop_index: int | None = None,
Expand Down Expand Up @@ -523,6 +524,7 @@ def parse_test_results(
all_args = True
coverage = CoverageData.load_from_sqlite_database(
database_path=coverage_database_file,
config_path=coverage_config_file,
source_code_path=source_file,
code_context=code_context,
function_name=function_name,
Expand Down
Loading