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/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
Labels
help wanted NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@henghengxqc
Copy link

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
Copy link
Author

@henghengxqc henghengxqc changed the title go test -cover doesn't collect the coverage of 'second m.Run()'. go test -cover doesn't collect the coverage of 'the second m.Run()' Nov 8, 2018
@ianlancetaylor ianlancetaylor changed the title go test -cover doesn't collect the coverage of 'the second m.Run()' cmd/go: go test -cover doesn't collect the coverage of 'the second m.Run()' Nov 8, 2018
@ianlancetaylor ianlancetaylor changed the title cmd/go: go test -cover doesn't collect the coverage of 'the second m.Run()' cmd/go: go test -cover doesn't collect the coverage of a second call to m.Run Nov 8, 2018
@ianlancetaylor ianlancetaylor added help wanted NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels 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
Labels
help wanted NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

2 participants