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

Go package coverage is calculated inconsistently in 1.22.5 #68627

Closed
tehaksbrid opened this issue Jul 29, 2024 · 2 comments
Closed

Go package coverage is calculated inconsistently in 1.22.5 #68627

tehaksbrid opened this issue Jul 29, 2024 · 2 comments

Comments

@tehaksbrid
Copy link

Go version

1.22.5

Output of go env in your module/workspace:

set GO111MODULE=on
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\{username}\AppData\Local\go-build
set GOENV=C:\Users\{username}\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\{username}\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\zluka\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:/Program Files/Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.22.5
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=0
set GOMOD=NUL
set GOWORK=
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\{username}\AppData\Local\Temp\go-build2959683362=/tmp/go-build -gno-record-gcc-switches

What did you do?

When producing test coverage via go test -cover ./..., incorrect package summary coverage values are generated. This can be confirmed by generating coverprofiles and inspecting those.

This issue is only present in 1.22.5. Other versions summarize package coverage correctly. I have reproduced this in a working demo here.

What did you see happen?

Running make coverage-browser for with Go version 1.22.5 on the above repo yields the following coverage summary:

go test -cover -coverprofile=cover.txt ./...
?       golang-coverage-disagreement-demo/applications/packages/bar     [no test files]
        golang-coverage-disagreement-demo/applications/packages/baz             coverage: 0.0% of statements
ok      golang-coverage-disagreement-demo/applications/foo      1.098s  coverage: 75.0% of statements
go tool cover -html=cover.txt


### What did you expect to see?

Package `foo` should show 100% coverage, as it does in 1.21.12.
@seankhliao
Copy link
Member

See the -coverpkg flag.

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants