-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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: coverpkg broken behaviour in version 1.10.1 #25093
Comments
I can reproduce the issue with package github.com/majewsky/schwift and Go 1.10.1. Downgrading to Go 1.9.4 fixes the problem for me. |
Still reproducible with Go 1.10.2. Furthermore, I noticed that the warning that @apremalal mentions also exists in 1.9.4 (where coverage is reported correctly), but is worded slightly differently. With Go 1.9.4:
Same command with Go 1.10.2:
This makes me think that e33794f is where the error was introduced. I did not have the time to do a bisect, though. |
Change https://golang.org/cl/122555 mentions this issue: |
In which release this fix is available? |
Go 1.11 |
Thanks @davecheney |
Sorry to bump this, but for the search indexers: If you're really confused about how to get code coverage for an external package or imported package in golang, you might be running into this bug. Update to 1.11+, then |
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go1.10.1 darwin/amd64
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/ag/Library/Caches/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/ag/workspace"
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/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/2t/8v5wp6zn36n2fgxf5qvd75zw0000gq/T/go-build821224783=/tmp/go-build -gno-record-gcc-switches -fno-common"
What did you do?
My repo structure is like below, and I'm executing commands indie folder
I have hosted the code in github for easy referencing.
models/math.go
models_test/math_test.go
I tried the following command which worked in golang 1.9.X versions. And gave me correct coverage results
go test -v ./models_test -coverpkg=./models -coverprofile=c.out && go tool cover -func=c.out
But with version 1.10.1 it throws a warning saying
And the coverage is always 0% with the above command
What did you expect to see?
100% test coverage
What did you see instead?
0% test coverage
The text was updated successfully, but these errors were encountered: