This commit is contained in:
@@ -48,9 +48,11 @@ def planted(mutator: dict, diff: str, files: list[str]) -> Mutant | None:
|
||||
the longest of `files` that ends that path."""
|
||||
logged = mutator["originalFilePath"]
|
||||
path = max((path for path in files if logged == path or logged.endswith(f"/{path}")), key=len, default=None)
|
||||
if path is None:
|
||||
return None
|
||||
start = mutator["originalStartLine"]
|
||||
found = changed(diff, mutator["originalSourceCode"].split("\n"), start) if path else None
|
||||
return Mutant(path, found[0], f"{path}:{start} {mutator['mutatorName']}", found[1], found[2]) if path and found else None
|
||||
found = changed(diff, mutator["originalSourceCode"].split("\n"), start)
|
||||
return Mutant(path, found[0], f"{path}:{start} {mutator['mutatorName']}", found[1], found[2]) if found else None
|
||||
|
||||
|
||||
def changed(diff: str, lines: list[str], start: int) -> tuple[int, tuple[bytes, ...], tuple[bytes, ...]] | None:
|
||||
@@ -59,7 +61,7 @@ def changed(diff: str, lines: list[str], start: int) -> tuple[int, tuple[bytes,
|
||||
|
||||
The diff's one hunk gives no line numbers. So the hunk's lines are found among `lines`, the file's, around `start`, the line
|
||||
Infection logs as the one the mutated code starts on. None where the diff holds no change, or where its lines stand around
|
||||
`start` nowhere or more than once."""
|
||||
`start` nowhere or more than once, as do those of a diff with a second hunk."""
|
||||
hunk = diff.partition("@@ @@\n")[2].split("\n")
|
||||
# An empty line of the file is an empty line of the hunk; any other line opens with a space, a minus or a plus.
|
||||
body = [(line[:1] if line[:1] in ("-", "+") else " ", line[1:]) for line in hunk]
|
||||
|
||||
Reference in New Issue
Block a user