Skip to content

cmd/go: duplicate lines in coverage file after update to 1.22 #65636

@alainstoffels

Description

@alainstoffels

Go version

go version go1.22.0 windows/amd64

Output of go env in your module/workspace:

GO111MODULE=on
GOARCH=amd64
GOBIN=
GOCACHE=C:\Users\astoffels\AppData\Local\go-build
GOENV=C:\Users\astoffels\AppData\Roaming\go\env
GOEXE=.exe
GOEXPERIMENT=
GOFLAGS=
GOHOSTARCH=amd64
GOHOSTOS=windows
GOINSECURE=
GOMODCACHE=C:\Source\golang\pkg\mod
GONOPROXY=
GONOSUMDB=
GOOS=windows
GOPATH=C:\Source\golang
GOPRIVATE=
GOPROXY=https://proxy.golang.org,direct
GOROOT=C:/Program Files/Go
GOSUMDB=sum.golang.org
GOTMPDIR=
GOTOOLCHAIN=auto
GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
GOVCS=
GOVERSION=go1.22.0
GCCGO=gccgo
GOAMD64=v1
AR=ar
CC=gcc
CXX=g++
CGO_ENABLED=0
GOMOD=C:\Source\golang\src\coverageRepro\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=-m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\ASTOFF~1\AppData\Local\Temp\go-build2371241097=/tmp/go-build -gno-record-gcc-switches

What did you do?

Clone https://github.com/alainstoffels/coverageRepro
Run inside the root of the repo: go test -cover -coverpkg=./... -coverprofile=coverage.out ./...

What did you see happen?

coverage.out now contains 2 lines for coverageRepro/bar/bar.go. One where it indicates that it's not covered, and another where it indicates that it is covered:

mode: set
coverageRepro/bar/bar.go:3.12,5.2 1 0
coverageRepro/bar/bar.go:3.12,5.2 1 1
coverageRepro/foo/foo.go:5.12,7.2 1 1

foo.Foo() calls bar.Bar(), so foo.TestFoo() should cover bar.Bar().

What did you expect to see?

I would expect it to output a single line for coverageRepro/bar/bar.go, indicating it as covered, like it did before the 1.22 update:

mode: set
coverageRepro/bar/bar.go:3.12,5.2 1 1
coverageRepro/foo/foo.go:5.12,7.2 1 1

Metadata

Metadata

Assignees

Labels

GoCommandcmd/goNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions