-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/go: inconsistent coverage when using -coverprofile with packages without tests #70244
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
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: |
Refactor cformat.EmitTextual to accept a package filter (list of packages to report). This is a no-op in terms of exposed coverage functionality, but we will need this feature in a subsequent patch. Updates #70244. Change-Id: I1e6bcbfb5e68187d4d69d54b667e97bc1fdfa2d4 Reviewed-on: https://go-review.googlesource.com/c/go/+/627315 Reviewed-by: David Chase <[email protected]> Reviewed-by: Michael Knyszek <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
Change https://go.dev/cl/646355 mentions this issue: |
The new test was committed after the removal was tested. For #51430 For #65570 For #70244 Change-Id: I5f94c36a68ea96ba76d018dc06a5a233ad684aa5 Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest Reviewed-on: https://go-review.googlesource.com/c/go/+/646355 Reviewed-by: Ian Lance Taylor <[email protected]> TryBot-Bypass: Ian Lance Taylor <[email protected]> Reviewed-by: Robert Griesemer <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]>
Noticed that with
This lists all import paths (delimited using ",") that contain test files |
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: