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 loses coverage of some inlined functions #23314

Closed
soniakeys opened this issue Jan 3, 2018 · 6 comments
Closed

cmd/go: go test -cover loses coverage of some inlined functions #23314

soniakeys opened this issue Jan 3, 2018 · 6 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@soniakeys
Copy link

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

Bisected to ci ee4fbbc, "stop creating nested temp directory trees". Reproduces at tip as of Jan 2.

Does this issue reproduce with the latest release?

with 1.9.2, No.

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

linux/amd64

What did you do?

go get -t github.com/soniakeys/unit
go test -cover github.com/soniakeys/unit

(The issue happens on this package of mine, github.com/soniakeys/unit. I'm very sorry I don't have a small test case at the moment. I wanted to file the issue anyway to see if the information here was enough to spark some idea of the problem.)

What did you expect to see?

With 1.9.2, or up to the ci noted above,
ok github.com/soniakeys/unit 0.003s coverage: 100.0% of statements

What did you see instead?

From the noted ci or later built in ~/pt,
$ ~/pt/bin/go test -cover github.com/soniakeys/unit
ok github.com/soniakeys/unit 0.003s coverage: 63.4% of statements

The coverprofile showed the missing statements were one-liners, likely inlined. Sure enough, with '-l':
$ ~/pt/bin/go test -cover -gcflags=-l github.com/soniakeys/unit
ok github.com/soniakeys/unit 0.003s coverage: 100.0% of statements

@agnivade
Copy link
Contributor

agnivade commented Jan 3, 2018

/cc @rsc

@namusyaka
Copy link
Member

Couldn't reproduce the issue in my local (osx) or linux/amd64.

go version:

$ go version
go version go1.9.2 linux/amd64

go env:

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/namusyaka/go"
GORACE=""
GOROOT="/home/namusyaka/.goenv/versions/1.9.2"
GOTOOLDIR="/home/namusyaka/.goenv/versions/1.9.2/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build842395550=/tmp/go-build"
CXX="g++"
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"
$ go test -cover github.com/soniakeys/unit
ok  	github.com/soniakeys/unit	0.009s	coverage: 100.0% of statements

Hope that helps.

@soniakeys
Copy link
Author

Right. It shows 100% with 1.9.2, but try it with tip and it shows 63%.

@mvdan
Copy link
Member

mvdan commented Jan 3, 2018

Conservatively marking for 1.10, unless it is proven to not be a regression.

@mvdan mvdan added this to the Go1.10 milestone Jan 3, 2018
@mvdan mvdan added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jan 3, 2018
@agnivade
Copy link
Contributor

agnivade commented Jan 4, 2018

Tried with 1.10beta and master. 63% with both and 100% with 1.9.2. Seems like a regression to me.

@gopherbot
Copy link

Change https://golang.org/cl/86237 mentions this issue: cmd/go: fix coverage rebuild corner case

@golang golang locked and limited conversation to collaborators Jan 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge 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

5 participants