Add support for test coverage merging; e.g. gocov test ./...
Closed this issue · 8 comments
go test -cover refuses to run tests from multiple package at once. I wrote a function to work around this in TestCoverage.run(), see https://github.com/maruel/pre-commit-go/blob/master/checks/checks.go#L532.
It runs each package test independently and concurrently, each with their own coverage file, then merges all the coverage files into one. It's ~130 lines of code in practice.
This feature request is to handle this automatically and transparently inside gocov so that the following command would work:
gocov test ./... | gocov report
I wrote a rough implementation; it implements support for:
gocov test ./... | gocov report
and other use like "./foo/...". Usage like:
gocov test ./isolate | gocov report
is unaffected by this change. The implementation is rough because it only look at the first argument.
I'd be fine with you proposing such a change to gocov.
Re merging, there are functions in gocov/gocovutil for merging gocov's format. It may be simpler to convert each profile to gocov's format first, then merge them together.
Maybe you missed the fact that I did attach a commit to this issue? https://github.com/maruel/gocov/commit/1b7da7b8665a89fb6d26bd25ff9eaed27891bb32
@maruel Indeed, I did, sorry. I will review and get back to you - travelling, so may take me a few days to respond.
Np, I'll be travelling in the bay area next week so I may also be slow to respond too.
Any update?
Thanks, I had totally missed the comments, will address ~tomorrow.