Skip to content
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/cover: inconsistent treatment of main package in coverage reports #57169

Closed
thanm opened this issue Dec 8, 2022 · 1 comment
Closed

cmd/cover: inconsistent treatment of main package in coverage reports #57169

thanm opened this issue Dec 8, 2022 · 1 comment
Assignees
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. okay-after-rc1 Used by release team to mark a release-blocker issue as okay to resolve either before or after rc1 release-blocker
Milestone

Comments

@thanm
Copy link
Contributor

thanm commented Dec 8, 2022

What version of Go are you using (go version)?

$ go version
go version devel go1.20-ff0877e180 Wed Dec 7 12:19:22 2022 -0500 linux/amd64

Does this issue reproduce with the latest release?

No, only with Go 1.20 / tip.

What operating system and processor architecture are you using (go env)?

linux/amd64

What did you do?

Here is a small program that has a main function and a test.

Try the following with it:

// step 1
go test -cover .

// step 2
rm -rf somedata ; mkdir somedata ; GOCOVERDIR=somedata go run -cover . ; go tool covdata percent -i=somedata

What did you expect to see?

Identical results for both runs.

What did you see instead?

$ go test -cover .
ok  	mainwithtest	0.020s	coverage: 50.0% of statements
$ rm -rf somedata ; mkdir somedata ; GOCOVERDIR=somedata go run -cover . ; go tool covdata percent -i=somedata
hi mom
	main	coverage: 50.0% of statements

Note the discrepancy with the package name. For go test -cover we get the import path (which seems correct), but for the go build -cover we're getting the package name and not import path. Seems that these two should be consistent.

@thanm thanm added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker okay-after-rc1 Used by release team to mark a release-blocker issue as okay to resolve either before or after rc1 labels Dec 8, 2022
@thanm thanm added this to the Go1.20 milestone Dec 8, 2022
@thanm thanm self-assigned this Dec 8, 2022
@gopherbot
Copy link

Change https://go.dev/cl/456237 mentions this issue: cmd/{go,cover,covdata}: fix 'package main' inconsistent handling

@dmitshur dmitshur added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Dec 9, 2022
@golang golang locked and limited conversation to collaborators Dec 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. okay-after-rc1 Used by release team to mark a release-blocker issue as okay to resolve either before or after rc1 release-blocker
Projects
None yet
Development

No branches or pull requests

3 participants