At tip, if you run the internal/coverage/cfile
tests with -coverpkg set to something that does include cfile, you get:
$ cd `go env GOROOT`
$ cd src/internal/coverage
$ go test -coverpkg=internal/coverage/decodecounter ./...
...
--- FAIL: TestCoverageSnapshot (0.00s)
ts_test.go:102: 0.276074 0.276074
ts_test.go:104: erroneous snapshots, C1 >= C2 = true C1=0.276074 C2=0.276074
This is happening because the test is calling out to a function that it expects will bump up the coverage percentage, but that func is not being instrumented.
The test needs to be rewritten to make it a bit more robust.
Comment From: gabyhelp
Similar Issues
- https://github.com/golang/go/issues/26760
- https://github.com/golang/go/issues/23314
- https://github.com/golang/go/issues/65653
- https://github.com/golang/go/issues/66464
- https://github.com/golang/go/issues/36541
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
Comment From: gopherbot
Change https://go.dev/cl/592200 mentions this issue: internal/coverage/cfile: harden the coverage snapshot test