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
BUG: Ginkgo not calculating as expected coverage #1161
Comments
hey there - this has to do with how Ginkgo switches paths when running multiple packages: right now one needs to specify all |
I see, is there any workarround we can set at cli meanwhile? |
i really should fix it in ginkgo - i'll try to get to it soon. in the mean time if you avoid relative paths things should work. If the module you are testing is called
alternatively you can pass in a list of file paths. unfortunately it doesn't look like go lets you specify something like |
this should now be fixed in v2.9.1 - please give it a try and let me know if it works for you. then we can close this issue out. |
Yup Working, Thanks for the fix 🥇 |
Something is still wrong, I see better coverage than before but I still get less lines of code coverage than using go test directly. 4215 vs 7030 |
odd - can you share a screenshot of all the output when you run go test and then all the output when you run ginkgo? also can you share exactly what you're running on the command line so i can make sure i'm following? |
when i tested this locally i was getting identical % combined coverages on the command line. do you see a discrepancy there? or is the discrepancy only in the resulting coverprofile file? if the latter then there may be more work i need to do now when merging the cover profiles one thing you could try that would help be debug this is to see if you get the same issue when you run |
Full go test command
Full ginkgo command
NOTE: I unknown if is important but not all tests are yet migrated to ginkgo I still have standard go tests pending to migrate to ginkgo, Nevertheless I saw some of this not migrated are test generating some coverage. Executing recursive but coverage for 1 package only
758 vs 169 covered lines. Let me now how can I help you to fix this, This is really blocking us the full migration to ginkgo at the moment :( |
ok thanks - let's focus on just the single coverpkg: can you rerun this case:
but with |
also - i appreciate some suites are ginkgo and others are testing.T tests. Do you have any individual suites where you mix ginkgo and testing.T? those will not work correctly when running with also - is any of this open source so i can take a look or even try to run it locally? |
ah... wait a minute. I just tried this in a dummy repo myself and was confused about what you meant by "lines of code coverage" and now I see you mean "number of lines in the coverprofile" - which is an implementation detail and not giving you actual coverage. For that you need to use in the course of digging into this, however, I did come across some inconsistent behavior in go where the coverage percentages are computed differently if one uses |
looks like go does in fact have some subtle issues when using coverpkg in this way: i'm pretty sure ginkgo is doing ok at this point and that this is actually working now |
maybe I wrongly understood the coverage.out file :) anyway there are something wrong, when I load this file to sonarQ it shows like less lines of code are covered when loading ginkgo coverage.out file compared to go test. you did lot of questions hope I do not miss any :)
thanks for all your work! |
yeah sorry for all the questions and thanks for your answers.
that is confusing to me - but i think the most efficient next step is to find some time to jump on a call and figure this out with you; which i'd be happy to do :) i'm in Denver (so US mountain time zone) and my e-mail is onsijoe@gmail.com - send me an e-mail with some time options and we can figure something out. Also (of course 😉) I do have one very last thing for you to try. instead of using file paths to specify ginkgo -coverpkg=github.com/onsi/ginkgo/v2/... -r and you could: ginkgo -coverpkg=github.com/your/repo/... -r instead of And to do just a single package you could: ginkgo -coverpkg=github.com/your/repo/edgeproxy/cli -r The reason for all of this is because Ginkgo compiles and runs each test separately by first setting the working directory to the test and then running the test locally. this is why but specifying a package path should always work and should always produce the coverage in sonarQ. |
Hey Sorry for all confusions, 2.9.1 is working fine, I were confused as the content of coverage.out file is different generated by go test vs ginkgo, is just that go test have duplicated lines and I was asumming more lines in that file means more coverage, but it isn't.. as soon I loaded this file to sonar Coverage is just identical, Sorry to waste your time! |
hey no worries - glad you could figure it out! |
tested on
v.2.9.0
ginkgo -coverpkg=./... -coverprofile=ginko.out --output-dir build/ ./...
go test -coverpkg=./... -coverprofile=build/gotest.out ./...
number of lines in the ginkgo.out 85
number of lines in the gotest.out 773
I tried in specific folders within my project like
./cli
where my cobra commands are in placeand same behaviour but at folder level, less lines of test are covered in ginkgo.
After comparing 2 files, I have the feeling that ginkgo only take into account coverage of code of the instructed folder, but this folder is possible is calling to functions in other packages.
The text was updated successfully, but these errors were encountered: