Open NarcisDavins opened 6 days ago
Related Issues and Documentation
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
@thanm we still list you as owner, maybe you still have background on this? otherwise, @golang/compiler
Hi @NarcisDavins you wrote:
pkg1 should not be marked as covered in the cover file, as it does not have any test and I'm not using other params such as -coverpkg.
I'm confused about what you're asking here. In the contents of cov.out
there is this line:
cov/pkg1/file.go:3.25,5.2 1 0
That indicates that package pkg1
has 1 statement and that it is not covered. When you say "marked as covered" do you mean that pkg
should not be mentioned at all?
Hi @NarcisDavins you wrote:
pkg1 should not be marked as covered in the cover file, as it does not have any test and I'm not using other params such as -coverpkg.
I'm confused about what you're asking here. In the contents of
cov.out
there is this line:cov/pkg1/file.go:3.25,5.2 1 0
That indicates that package
pkg1
has 1 statement and that it is not covered. When you say "marked as covered" do you mean thatpkg
should not be mentioned at all?
@thanm pkg1
appears twice, the line you copied where it indeed shows as not covered, and the following one where it appears as covered. I'll paste again the "What did you see happen?" part of the issue:
$->> cov $ docker run --rm -it -v .:/code -w /code golang:1.23.3 go test ./... -coverprofile cov.out
cov/pkg1 coverage: 0.0% of statements
ok cov/pkg2 0.003s coverage: 100.0% of statements
$->> cov $ cat cov.out
mode: set
cov/pkg1/file.go:3.25,5.2 1 0
cov/pkg1/file.go:3.25,5.2 1 1
cov/pkg2/file.go:3.25,5.2 1 1
Edit: that second line where it appears as covered is the one that should not be there.
Right, of course. Somehow didn't pick up on that the first time. Thanks for the clarification.
Change https://go.dev/cl/627315 mentions this issue: internal/coverage: refactor EmitTextual in preparation for bugfix
Change https://go.dev/cl/627316 mentions this issue: internal/coverage: pass selected package set to EmitTextual
Go version
go version go1.23.3 linux/amd64
Output of
go env
in your module/workspace:What did you do?
Given the following project, with
pkg1
not containing any test, andpkg2
with 1 test that is callingpkg1
, when usinggo test
with the-coverprofile
option, the cover file generated containspkg1
as coveredWhat did you see happen?
Running go test with
-coverprofile
the output correctly shows 0% coverage on the package without tests, but the generated file info is marking pkg1 as coveredWhat did you expect to see?
pkg1
should not be marked as covered in the cover file, as it does not have any test and I'm not using other params such as-coverpkg
.using
GOEXPERIMENT=nocoverageredesign
is currently a workaround we are using, but would stop being an option after: https://github.com/golang/go/issues/55953.Another workaround would be to generate empty test files on all packages, but as far as I can tell, this shouldn't be the expected behavior.