Skip to content

Commit 65f8ae7

Browse files
committed
fix: only_mutate_file_paths option not working
1 parent 4ddefa2 commit 65f8ae7

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed

src/mutahunter/core/controller.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@
1111
from mutahunter.core.db import MutationDatabase
1212
from mutahunter.core.entities.config import MutationTestControllerConfig
1313
from mutahunter.core.error_parser import extract_error_message
14-
from mutahunter.core.exceptions import (CoverageAnalysisError,
15-
MutantKilledError, MutantSurvivedError,
16-
MutationTestingError,
17-
ReportGenerationError,
18-
UnexpectedTestResultError)
14+
from mutahunter.core.exceptions import (
15+
CoverageAnalysisError,
16+
MutantKilledError,
17+
MutantSurvivedError,
18+
MutationTestingError,
19+
ReportGenerationError,
20+
UnexpectedTestResultError,
21+
)
1922
from mutahunter.core.git_handler import GitHandler
2023
from mutahunter.core.io import FileOperationHandler
2124
from mutahunter.core.llm_mutation_engine import LLMMutationEngine
@@ -93,7 +96,9 @@ def run_mutation_testing_all(self) -> None:
9396
all_covered_files = self.coverage_processor.file_lines_executed.keys()
9497
for covered_file_path in tqdm(all_covered_files):
9598
if FileOperationHandler.should_skip_file(
96-
covered_file_path, self.config.exclude_files
99+
covered_file_path,
100+
exclude_files=self.config.exclude_files,
101+
only_mutate_file_paths=self.config.only_mutate_file_paths,
97102
):
98103
continue
99104
executed_lines = self.coverage_processor.file_lines_executed[
@@ -114,7 +119,9 @@ def run_mutation_testing_diff(self) -> None:
114119
)
115120
for file_path in tqdm(modified_files):
116121
if FileOperationHandler.should_skip_file(
117-
file_path, self.config.exclude_files
122+
file_path,
123+
exclude_files=self.config.exclude_files,
124+
only_mutate_file_paths=self.config.only_mutate_file_paths,
118125
):
119126
continue
120127
modified_lines = GitHandler.get_modified_lines(file_path)

src/mutahunter/core/io.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,16 @@ def prepare_mutant_file(
4747
return mutant_path
4848

4949
@staticmethod
50-
def should_skip_file(filename: str, exclude_files: List[str]) -> bool:
51-
for file_path in exclude_files:
52-
if not os.path.exists(file_path):
53-
raise FileNotFoundError(f"File {file_path} does not exist.")
54-
return all(file_path != filename for file_path in exclude_files)
50+
def should_skip_file(
51+
filename: str, exclude_files: List[str], only_mutate_file_paths: List[str]
52+
) -> bool:
53+
if only_mutate_file_paths:
54+
for file_path in only_mutate_file_paths:
55+
if not os.path.exists(file_path):
56+
raise FileNotFoundError(f"File {file_path} does not exist.")
57+
return all(file_path != filename for file_path in only_mutate_file_paths)
5558
if filename in exclude_files:
5659
return True
57-
return any(keyword in filename for keyword in TEST_FILE_PATTERNS)
5860

5961
@staticmethod
6062
def check_syntax(source_file_path: str, source_code: str) -> bool:

0 commit comments

Comments
 (0)