Skip to content

Commit d59e846

Browse files
committed
Skip predicate registration whenever _create_covered_cdg also excludes the node
1 parent a061224 commit d59e846

4 files changed

Lines changed: 15 additions & 4 deletions

File tree

src/pynguin/ga/algorithms/llmosalgorithm.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ def filter_gao_by_coverage(
184184
test_factory=self._test_factory,
185185
fitness_functions=self._test_case_fitness_functions,
186186
coverage_functions=self._test_suite_coverage_functions,
187-
model=self.model,
188187
)
189188

190189
def _get_random_population(self) -> list[tcc.TestCaseChromosome]:

src/pynguin/instrumentation/version/python3_10.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,12 @@ def visit_node( # noqa: D102, C901
868868
):
869869
return
870870

871+
if ast_info is not None and not any(
872+
not isinstance(instr.lineno, int) or ast_info.should_cover_line(instr.lineno)
873+
for instr in node.original_instructions
874+
):
875+
return
876+
871877
if maybe_jump.name == "FOR_ITER":
872878
self.visit_for_loop(
873879
ast_info,

src/pynguin/instrumentation/version/python3_11.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ class BranchCoverageInstrumentation(python3_10.BranchCoverageInstrumentation):
427427
"POP_JUMP_BACKWARD_IF_NONE": PynguinCompare.IS,
428428
}
429429

430-
def visit_node( # noqa: D102
430+
def visit_node( # noqa: D102, C901
431431
self,
432432
ast_info: transformer.AstInfo | None,
433433
cfg: cf.CFG,
@@ -447,6 +447,12 @@ def visit_node( # noqa: D102
447447
):
448448
return
449449

450+
if ast_info is not None and not any(
451+
not isinstance(instr.lineno, int) or ast_info.should_cover_line(instr.lineno)
452+
for instr in node.original_instructions
453+
):
454+
return
455+
450456
if maybe_jump.name == "FOR_ITER":
451457
self.visit_for_loop(
452458
ast_info,

src/pynguin/utils/controlflowdistance.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ def get_non_root_control_flow_distance(
206206
executed_predicate_id, trace.true_distances
207207
) + _predicate_fitness(executed_predicate_id, trace.false_distances)
208208
distance = min(distance, candidate)
209-
except nx.NetworkXNoPath:
210-
# No path from node to target.
209+
except (nx.NetworkXNoPath, nx.NodeNotFound):
210+
# No path from node to target, or target node not in CDG.
211211
pass
212212

213213
return distance

0 commit comments

Comments
 (0)