Count every line of a Swift coverage region.

crapper now reports a region as (start, end, count). The join still
unpacked (line, count), so the Swift coverage tests crashed, and a
mutation on the last line of a covered region was left uncovered.

line_covered decides each line. A nested region with count zero stays
uncovered, and a line in no region stays uncovered. An xccov summary
is unchanged.

The file-wide mutator run then found six older survivors in the path
join. A trailing slash still marks the file, the first of two equal
paths keeps its hits, and a shorter prefix beats a shorter suffix.
Comparisons that could not change a result are gone.

Proved by pytest (125 passed, 1 skipped; swift is not installed).
crapper's worst score besides parse_args is _prepare_coverage at 9.4;
_swift_hits is 6.0. dryer --threshold 0.8 reports no candidates.
mutator on src/mutator/coverage.py killed 49, with 0 survived and 0
uncovered.

Co-authored-by: Robert C. Martin <[email protected]>
This commit is contained in:
Cursor Agent
2026-11-26 02:20:07 +00:00
co-authored by Robert C. Martin
parent eb14237127
commit 9a3d4a353f
3 changed files with 144 additions and 15 deletions
+1 -1
View File
@@ -125,7 +125,7 @@ The baseline command has to pass before any mutant runs. A mutant's timeout is t
./mutator --xcode-scheme App --xcode-destination 'platform=iOS Simulator,name=iPhone 16'
```
Coverage is generated with crapper's commands unless `--use-existing-coverage` or `--no-coverage` is set. A file missing from the report is treated as uncovered, and the run says so. Swift coverage is the JSON crapper writes under `target/coverage/swift/`: llvm-cov export after `swift test --enable-code-coverage`, or `xcrun xccov view --report --json` after `xcodebuild test -enableCodeCoverage YES`. A hit region marks that line. An xccov summary has no regions, so the function's line is covered when that function has covered lines.
Coverage is generated with crapper's commands unless `--use-existing-coverage` or `--no-coverage` is set. A file missing from the report is treated as uncovered, and the run says so. Swift coverage is the JSON crapper writes under `target/coverage/swift/`: llvm-cov export after `swift test --enable-code-coverage`, or `xcrun xccov view --report --json` after `xcodebuild test -enableCodeCoverage YES`. A hit region marks every line from its start through its end. A nested region with count zero leaves those lines uncovered, and a line in no region is uncovered. An xccov summary has no regions, so the function's line is covered when that function has covered lines.
## Development