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/go: go test -cover doesn't collect the coverage of a second call to m.Run #28651

Open
henghengxqc opened this Issue Nov 8, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@henghengxqc

henghengxqc commented Nov 8, 2018

What version of Go are you using (go version)?

$ go version
go1.10.3 darwin/amd64

Does this issue reproduce with the latest release?

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/wangheng/Library/Caches/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/wangheng/go"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.10.3/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.10.3/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
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/qf/_x6np3lx7qb9sn_0ymk53fqr0000gn/T/go-build681943823=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I wrote a very simple code to describe the issue. Please see the go files I attached. It seems 'golang cover' only counted the first main thread coverage and cast the coverage of second m.Run() away.
➜ first go test -cover
PASS
coverage: 0.0% of statements
PASS
ok go/test/first 0.013s

What did you expect to see?

What did you see instead?

@henghengxqc

This comment has been minimized.

henghengxqc commented Nov 8, 2018

@henghengxqc henghengxqc changed the title from go test -cover doesn't collect the coverage of 'second m.Run()'. to go test -cover doesn't collect the coverage of 'the second m.Run()' Nov 8, 2018

@ianlancetaylor ianlancetaylor changed the title from go test -cover doesn't collect the coverage of 'the second m.Run()' to cmd/go: go test -cover doesn't collect the coverage of 'the second m.Run()' Nov 8, 2018

@ianlancetaylor ianlancetaylor changed the title from cmd/go: go test -cover doesn't collect the coverage of 'the second m.Run()' to cmd/go: go test -cover doesn't collect the coverage of a second call to m.Run Nov 8, 2018

@ianlancetaylor ianlancetaylor added this to the Unplanned milestone Nov 8, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment