Go: coverage profile is never matched, so every site is reported uncovered and the run exits 0
Maintainers usually reply within 3 days
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 72/100
Research direction
Start in target/coverage/go/coverage.out handling and the coverage.covered_lines / _suffix_rank / _lookup functions the issue names. Reproduce with the given Go module repro, then add a candidate that strips the module path from go.mod off profile keys (or adds a root-relative path candidate). Done: Go profiles match on a covered module, mutants are killed, and the exit code reflects killed mutants.
Written by the indexing model from the issue text.
Description
On a Go module, mutator reports every site as uncovered and exits 0, even when the tests cover the line. With --no-coverage the same sites run.
Repro (mutator a5a0cb8, crapper 6fd92c4, go 1.25.8, macOS)
go.mod: module example.com/demo
calc/calc.go:
package calc
func Max(a, b int) int {
if a > b {
return a
}
return b
}
calc/calc_test.go:
package calc
import "testing"
func TestMax(t *testing.T) {
if Max(2, 1) != 2 || Max(1, 2) != 2 {
t.Fatal("wrong max")
}
}
$ ../mutator/mutator calc/calc.go
Max example.com/demo/calc 0 0 1 1 n/a
$ echo $?
0
$ ../mutator/mutator --no-coverage calc/calc.go
Max example.com/demo/calc 0 1 0 1 0.0%
crapper reads the same profile correctly (Max example.com/demo/calc 2 100.0% 2.0).
Cause, as far as I can tell
target/coverage/go/coverage.out names the file by import path, example.com/demo/calc/calc.go. coverage.covered_lines looks it up by absolute path, /…/mutrepro/calc/calc.go. _suffix_rank only matches when one path is a suffix of the other, and these two share only the tail calc/calc.go, so _lookup returns None and every line counts as uncovered.
Why it matters
Exit 0 means every executed mutant was killed. Used as a gate on a Go project, mutator passes without running a mutant.
Possible fix
Strip the module path from go.mod off Go profile keys before matching, or add the root-relative path to the lookup candidates.
- Dominant language
- Python
- Stars
- 55
- Forks
- 7
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from unclebob/mutator
-
Difficulty 1/5 Under an hour Newbie friendliness 83/100
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Maintainers usually reply within 3 days
-
Workers leave out source in a directory named build, out, dist, target or coverage, so every mutant is reported KILLEDPossibly taken @lohmag claimed this 2 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 3 days
-
A differential run can carry a killed outcome onto a surviving mutant and exit 0Possibly taken @andrewmolyuk claimed this 1 day ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
Maintainers usually reply within 3 days
-
Edits made to the file under test during a run are reverted when the run endsPossibly taken @andrewmolyuk claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
Maintainers usually reply within 3 days
All issues in unclebob/mutator
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
NousResearch/hermes-agent#147104 ·
Maintainers usually reply within 1 day
-
premises-missing
Difficulty 1/5 Under an hour Newbie friendliness 88/100
WingedGuardian/GENesis-AGI#3801 ·
Maintainers usually reply within 1 day
-
[oblt-aw][autodoc] Document new required `shared-org-key` input for `obs-aw-dependency-review`Possibly taken @github-actions claimed this today. Open
Difficulty 1/5 Under an hour Newbie friendliness 90/100
Maintainers usually reply within 1 day
-
bot-triaged module: inductor oncall: pt2 topic: fuzzer triaged
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 4 days