wadey/gocovmerge

Issue: failed to parse profiles: line...doesn't match expected format: couldn't find a before

devplayerJoe opened this issue · 4 comments

Go version (go version)?

$ go version
go version go1.13.9 darwin/amd64

Details about the operating system and processor architecture (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="$HOME/Library/Caches/go-build"
GOENV="$HOME/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="$HOME/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="$HOME/go/project1/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/nt/gc7658bs1132ttlcjdmlwwxm0000gn/T/go-build221587211=/tmp/go-build -gno-record-gcc-switches -fno-common"

Problem statement

I am generating respective coverage files for each _test.go file. However, I am getting an error while executing the gocovmerge command from last few days. I first encountered it on 25 March, then on 26-27 March, it worked fine. But again from 28-29 March, I am facing the same issue again.

Executed below command to generate merged coverage profile file

gocovmerge ${coverageDir}/myTest-*-coverage.profile

Expected outcome?

Merged coverage profile file being generated without any error

Observed output?

2021/03/30 01:43:34 failed to parse profiles: line "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" doesn't match expected format: couldn't find a   before Count

Kindly assist in nailing down the issue.

@wadey, could you please assist?

wadey commented

Check all of your myTest-*-coverage.profile files, it looks like one of them has invalid binary data in it (zero bytes). These should all be text files and not contain zero bytes.

Got one coverage file having binary data. There are 40 ish test patterns for unit tests and all of them are creating separate coverage profile file ${profileName}.profile with command:
go test -p 1 -cover -v ./${pkgName} -run ${pattern} -coverprofile=${profileName}.profile ./${pkgName}
All other files are 1M in size and only file containing binary data in end has size 148K.
Any pointers on why it could happen?

wadey commented

Perhaps the go test run is failing or calling os.Exit incorrectly? I would regenerate all of your .profile files to see which one is the issue and then investigate that test suite to see why it's being generated incorrectly.