golang / go

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

cmd/covdata: percent does not support ./... for the -pkg pattern #66507

Open mitar opened 5 months ago

mitar commented 5 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 ran:

GOCOVERDIR=coverage go test -timeout 10m -cover -covermode atomic -args -test.gocoverdir=coverage ./...

to collect coverage data into coverage dir and then I ran:

go tool covdata percent -i=coverage -pkg=./...

What did you see happen?

No output was made.

What did you expect to see?

To get the coverage matching the ./... package(s). Same as what was reported during a test run.

The use case here is that I have also some additional e2e main programs calling into the library I am testing and I want those to not be reported. But to report everything under the ./... pattern.

Note, help text says:

  -pkg string
        Restrict output to package(s) matching specified package pattern.

Which makes me think that ./... should already be supported.

mitar commented 5 months ago

(attn @thanm)

dr2chase commented 5 months ago

@golang/compiler