-
Notifications
You must be signed in to change notification settings - Fork 17.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/go: inconsistent coverage when using -coverprofile with packages without tests #70244
Comments
@thanm we still list you as owner, maybe you still have background on this? |
Hi @NarcisDavins you wrote:
I'm confused about what you're asking here. In the contents of
That indicates that package |
@thanm
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: |
Change https://go.dev/cl/627316 mentions this issue: |
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: #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.
The text was updated successfully, but these errors were encountered: