Kill the mutation survivors in the coverage runners.

The Swift fixes left the changed files with 33 survivors. Tests now
distinguish an empty suffix, an equal path, a segment that starts on the
function's last line, the shorter extra prefix, an equal report key that
blocks a longer file, a blank candidate, a repeated source, form-html keys,
a short llvm-cov segment, a Swift export that has a profile but no binary,
and the quiet success paths for Java, Go, Rust, Python, Vitest, rustup,
and a custom coverage command.

Proved by mutator on runners.py and coverage.py: 432 killed, 0 survived,
0 uncovered.

Co-authored-by: Robert C. Martin <[email protected]>
This commit is contained in:
Cursor Agent
2026-11-26 01:51:44 +00:00
co-authored by Robert C. Martin
parent 7a0b1613f5
commit 7222b2b8e2
4 changed files with 197 additions and 1 deletions
+36
View File
@@ -376,6 +376,23 @@ def test_the_innermost_region_decides_whether_a_line_is_covered():
def test_a_segment_region_is_a_single_line():
text = json.dumps(
{
"data": [
{
"files": [
{
"filename": "Short.swift",
"segments": ["nope", [1, 2], [2, 5, 1, True]],
}
],
"functions": [],
}
]
}
)
short = parse_swift_coverage(text)["Short.swift"]
assert short.regions == [(2, 2, 1)]
text = (_FIXTURES / "segments.json").read_text(encoding="utf-8")
record = parse_swift_coverage(text)["Sources/Demo/Box.swift"]
assert (2, 2, 1) in record.regions
@@ -1002,6 +1019,25 @@ def test_a_failed_xcode_run_forgets_the_previous_report(tmp_path, monkeypatch):
assert ':name "choose", :namespace "Demo", :complexity 2, :coverage 0.0, :crap 6.0' in _snapshot(tmp_path)
def test_swift_export_needs_the_profile_the_binary_and_llvm_cov(tmp_path, monkeypatch, capsys):
_plant(tmp_path, "Package.swift", "")
source = _plant(tmp_path, "Sources/Demo/Box.swift", "func open() {}\n")
_plant_profdata(tmp_path)
exports = []
monkeypatch.setattr(
"crapper.runners.shutil.which",
lambda name: f"/usr/bin/{name}" if name in {"swift", "llvm-cov"} else None,
)
monkeypatch.setattr("crapper.runners.run_shell", lambda command, cwd: 0)
monkeypatch.setattr(
"crapper.runners.write_command_output",
lambda command, cwd, destination: exports.append(command) or 0,
)
assert run_coverage(tmp_path, [source], None) == 0
assert exports == []
assert "Swift coverage data is missing" in capsys.readouterr().err
def test_swift_without_a_toolchain_does_not_run_a_command(tmp_path, monkeypatch, capsys):
_plant(tmp_path, "Package.swift", "")
source = _plant(tmp_path, "Sources/Demo/Box.swift", "func open() {}\n")