golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
122.93k stars 17.52k forks source link

cmd/covdata: percent does not support -coverpkg #66464

Open mitar opened 6 months ago

mitar commented 6 months ago

Go version

go version go1.22.1 linux/amd64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/root/.cache/go-build'
GOENV='/root/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.22.1'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='0'
GOMOD='/code/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build1985924870=/tmp/go-build -gno-record-gcc-switches'

What did you do?

I am trying to use -test.gocoverdir= to combine multiple runs of tests. But I use -coverpkg ./... flag because I want to have coverage calculated across sub-packages. This works well when running without coverage dir.

What did you see happen?

I see that reported numbers by go tool covdata percent -i=coverage is the same as those I get when running go test without -coverpkg ./....

What did you expect to see?

I expected that I can pass -coverpkg ./... to go tool covdata percent -i=coverage to get the same numbers as reported by the go test tool when it runs (when testing on one run).

mitar commented 6 months ago

(attn @thanm)

dr2chase commented 5 months ago

@thanm