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: app.test -test.coverprofile fails silently #30542

Closed
networkimprov opened this issue Mar 3, 2019 · 1 comment

Comments

Projects
None yet
1 participant
@networkimprov
Copy link

commented Mar 3, 2019

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

$ go version
go version go1.12 linux/amd64

Does this issue reproduce with the latest release?

y

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

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/root/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/lib/go"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/root/mnm-hammer/go.mod"
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build417943255=/tmp/go-build -gno-record-gcc-switches"

What did you do?

file main.go:

package main
import "flag"
func main() { flag.Parse() }
func m2() int { return t2() }

file test.go:

package main
import "flag"
var sT = "b"
func init() { flag.StringVar(&sT, "b", sT, "B") }
func t2() int { return 0 }

file main_test.go:

package main
import "testing"
func TestCoverage(i *testing.T) {
   if m2() != 0 { i.Fail() }
}

build:

$ cd app
$ go test -c -covermode=count -coverpkg ./...
$ ./app.test -b a:b -test.coverprofile z.cov #fails silently
$ ./app.test        -test.coverprofile z.cov #works

What did you expect to see?

z.cov in directory

What did you see instead?

z.cov missing

@networkimprov

This comment has been minimized.

Copy link
Author

commented Mar 3, 2019

Problem is unrelated to -test.coverprofile; never mind!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.