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: spurious 0 line in coverprofile output #70441

Closed
ct1n opened this issue Nov 19, 2024 · 4 comments
Closed

cmd/cover: spurious 0 line in coverprofile output #70441

ct1n opened this issue Nov 19, 2024 · 4 comments
Labels
WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@ct1n
Copy link
Contributor

ct1n commented Nov 19, 2024

Go version

go1.22.9 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.9'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/build/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 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build1442515923=/tmp/go-build -gno-record-gcc-switches'

What did you do?

Running test coverage using a docker golang:1.22-alpine3.19 container. We run the following command:

go test -v -parallel 24 -p 24 -count 1 -covermode=atomic -coverprofile /coverage/coverage.out --timeout 30s ./...

What did you see happen?

The go test command sometimes generates either a line containing just the digit 0 at the end of coverage.out, or an empty line (though this seems rarer and I haven't checked that it's at the end of the file).

Trying to parse coverage.out with github.com/AlekSi/gocov-xml results in error: line "0" doesn't match expected format: couldn't find a before Count (from golang.org/x/tools.cover).

Other than the last line coverage.out seems valid: it starts with mode: atomic and contains about 15k report lines.

Not very easy to reproduce.

What did you expect to see?

A valid coverage.out profile that can be loaded by golang.org/x/tools/cover.

We can work around this pretty easily, but thought it might be useful in case others encounter this. Also it might be an easy fix.

@seankhliao seankhliao added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Nov 19, 2024
@seankhliao
Copy link
Member

I think we need some form of reproducer

@ct1n
Copy link
Contributor Author

ct1n commented Nov 19, 2024

Sorry for the noise. It seems this was because of our build process. Sometimes 2 builds ran at the same time and they weren't properly isolated, using the same output directory

@ct1n ct1n closed this as completed Nov 19, 2024
@ianlancetaylor
Copy link
Member

Thanks for following up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants