ginkgo icon indicating copy to clipboard operation
ginkgo copied to clipboard

Go 1.20 : -test.gocoverdir

Open gfyrag opened this issue 2 years ago • 5 comments

Hi!

I'm using Ginkgo for integration testings and would like to use the flag -test.gocoverdir introduced with Go 1.20. If using plain "go test", it works as expected, but not with the ginkgo cli. Unfortunately, using "go test" involve no parallel testing. I tried to "go test" with the flags -ginkgo.parallel.XXX, but ginkgo complains about it. Not surprising as i'm not supposed to do that.

Do you have any plan tu support it? Or maybe a workaround?

gfyrag avatar Mar 30 '23 14:03 gfyrag

hey there i haven't played with it myself yet but my understanding from the integration coverage docs and the latest set of go test flags is they you simply set a GOCOVERDIR environment variable to have your precompiled binaries emit coverage information. each invocation of the binary will generate a new file that you can inspect and merge with go tool covdata and i would assume that the go community has done the work to ensure that concurrent invocations of the binary do not generate issue so you can simply run GOCOVERDIR=/path/to/dir ginkgo -p and things should work. My only recommendation is that you use an absolute path for GOCOVERDIR as Ginkgo will change the working directory when invoking specs in subdirectories.

Give it a try!

onsi avatar Mar 30 '23 14:03 onsi

I have a Similar Issue.

  • I have an Integration Test for Which I am Able to Generate Binary Coverage Files.
  • Now I have Set of Unit Tests which i want to merge coverage with Integration Tests.

Here Running go test works but i have used Labels to exclude few tests which i am unable to do.

export GOCOVERDIR=`pwd`
ginkgo -r '--label-filter=!setup'

This is not Generating Binary Coverage Files which can be processed by covdata.

Eg go tool covdata percent -i=.

amanhigh avatar Nov 12 '23 22:11 amanhigh