Skip to content

Coverage incorrectly reported as 100% ( go test cover) #26760

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

Closed
vron opened this issue Aug 2, 2018 · 2 comments
Closed

Coverage incorrectly reported as 100% ( go test cover) #26760

vron opened this issue Aug 2, 2018 · 2 comments

Comments

@vron
Copy link

vron commented Aug 2, 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?

Yes

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

GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/vron/Library/Caches/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/vron/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/4m/7vzzk0153d56fs_7b1k4wqdc0000gn/T/go-build593998463=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

For code see: https://play.golang.org/p/mkWebv8IOwK . (not runnable since 3 files needed)

Using the code from the above link and running:
go test -coverpkg="..." -count=1 pkg1/pkg2

Outputs
ok pkg1/pkg2 0.005s coverage: 100.0% of statements in ...

What did you expect to see?

I expect the coverage to not be 100% since pkg1.f1 was never called.

What did you see instead?

I see 100% coverage in all packages, which is clearly wrong.

@AlexRouSg
Copy link
Contributor

Looks like a dupe of #23883

@vron
Copy link
Author

vron commented Aug 2, 2018

Yes, agreed - looks like the same issue - will close this one, unfortunate that it has been pushed to 1.12 since it makes for incorrect reportage without any warnings. Thanks for pointing out the duplicate.

@vron vron closed this as completed Aug 2, 2018
@golang golang locked and limited conversation to collaborators Aug 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants