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

Unable to run on multiple packages #20

Closed
usmanismail opened this issue Jan 14, 2014 · 19 comments
Closed

Unable to run on multiple packages #20

usmanismail opened this issue Jan 14, 2014 · 19 comments

Comments

@usmanismail
Copy link

I am unable to use this tool with multiple packages

goveralls -package ./... XXXXXXXXXXXX
cannot use test profile flag with multiple packages
error: %v exit status 1
17:58:08 gocov.go:132: Error loading gocov results: exit status 1

@krak3n
Copy link

krak3n commented Jan 16, 2014

Confirmed.

@h12w
Copy link
Contributor

h12w commented Feb 12, 2014

"go test -coverprofile" does not support generating a single coverage profile for multiple packages. (see: https://groups.google.com/forum/#!msg/golang-nuts/p4WbbnJqTvk/8EBnIWXOgMAJ).

Is it possible to generate many coverage profiles and then merge them into one?

@sdboyer
Copy link

sdboyer commented Mar 21, 2014

also having this issue, any resolutions?

@mattn
Copy link
Owner

mattn commented Mar 22, 2014

It's not a problem of goveralls maybe.

@usmanismail
Copy link
Author

The output coverage reports can be concatenated and sent to goveralls. The service
is able to report correctly. See https://github.com/gopns/gopns/blob/master/test-coverage.sh for how I did it.

It would be great to have this built into the library.

@stojg
Copy link

stojg commented May 1, 2014

@usmanismail thanks for that script, it works great.

@sdboyer
Copy link

sdboyer commented May 1, 2014

fyi, i worked from what @usmanismail and made a similar version: https://github.com/sdboyer/gogl/blob/master/test-coverage.sh

@modocache
Copy link

I had the same problem. I agree with @mattn, this doesn't seem like a goveralls problem--more like a problem with go test itself.

I made a Go executable to combine the .coverprofile files. You can add it to your CI script:

go get code.google.com/p/go.tools/cmd/cover
go get github.com/modocache/gover
go get github.com/mattn/goveralls

go test ./...
gover
goveralls -coverprofile=gover.coverprofile -service drone.io -repotoken $COVERALLS_TOKEN

@h12w
Copy link
Contributor

h12w commented May 17, 2014

Please note that issue 6909 is exactly this problem and has been accepted. It is quite possible that "go test" will support this in the future release. See https://code.google.com/p/go/issues/detail?id=6909

@rafecolton
Copy link

@modocache thanks for gover! I added an example usage that combines all of the suggestions here: https://github.com/rafecolton/fmtpolice#example-coverage-usage-with-goveralls

@keighl
Copy link

keighl commented Feb 3, 2015

Thanks for writing gover, @modocache. Here's a travis config that works for one of my projects with 'sub-packages'. go test can't output multiple coverprofiles, but it's easy enough to just run it a few times.

before_install:
  - go get golang.org/x/tools/cmd/cover
  - go get github.com/axw/gocov/gocov
  - go get github.com/modocache/gover
  - go get github.com/mattn/goveralls

script:
  - go test -coverprofile=api.coverprofile ./api
  - go test -coverprofile=utils.coverprofile ./utils
  - go test -coverprofile=models.coverprofile ./models
  - go test -coverprofile=main.coverprofile
  - $HOME/gopath/bin/gover
  - $HOME/gopath/bin/goveralls -coverprofile=gover.coverprofile -service travis-ci

abesto added a commit to abesto/easyssh that referenced this issue Jun 19, 2015
ascandella pushed a commit to uber-archive/go-torch that referenced this issue Jul 22, 2015
ascandella pushed a commit to uber-archive/go-torch that referenced this issue Jul 22, 2015
ascandella pushed a commit to uber-archive/go-torch that referenced this issue Jul 22, 2015
ascandella pushed a commit to uber-archive/go-torch that referenced this issue Jul 22, 2015
ascandella pushed a commit to uber-archive/go-torch that referenced this issue Jul 22, 2015
ascandella pushed a commit to uber-archive/go-torch that referenced this issue Jul 22, 2015
@pierrebeaucamp
Copy link

any updates?

@h12w
Copy link
Contributor

h12w commented Nov 4, 2015

Workaround on this issue:
https://github.com/h12w/gosweep

@pierrebeaucamp
Copy link

gover works perfectly fine for me, but I'd rather have this functionality in goveralls built in.

0xazure added a commit to 0xazure/pdify-go that referenced this issue Nov 17, 2015
go test, and subsequently goveralls, does not support using the test
profile flag with multiple packages.

See:
mattn/goveralls#20
golang/go#6909
0xazure added a commit to 0xazure/pdify-go that referenced this issue Jan 13, 2016
go test, and subsequently goveralls, does not support using the test
profile flag with multiple packages.

See:
mattn/goveralls#20
golang/go#6909
0xazure added a commit to 0xazure/pdify-go that referenced this issue Jan 14, 2016
go test, and subsequently goveralls, does not support using the test
profile flag with multiple packages.

See:
mattn/goveralls#20
golang/go#6909
0xazure added a commit to 0xazure/pdify-go that referenced this issue Jan 14, 2016
go test, and subsequently goveralls, does not support using the test
profile flag with multiple packages.

See:
mattn/goveralls#20
golang/go#6909
@at15
Copy link

at15 commented Jul 12, 2016

https://github.com/go-playground/overalls (Multi-Package go project coverprofile for tools like goveralls ) can be used to test multiple packages in a project and more discussion about this problem can be found in golang/go#6909

@mattn
Copy link
Owner

mattn commented Jul 12, 2016

I made already branch for multiple-package. https://github.com/mattn/goveralls/tree/multiple-packages

But not tested.

@steenzout
Copy link

steenzout commented Jul 12, 2016

check https://github.com/h12w/gosweep for a simple bash script that can get you complete coverage.

you can then use the output on goveralls.

@mattn
Copy link
Owner

mattn commented Sep 12, 2016

Closed by #74

@paskal
Copy link

paskal commented Feb 18, 2024

For reference, here is how I combine two coverage profiles in the GitHub actions:

go test -timeout=60s -race -covermode=atomic -coverprofile=$GITHUB_WORKSPACE/profile.cov_tmp
cat $GITHUB_WORKSPACE/profile.cov_tmp | grep -v "_mock.go" > $GITHUB_WORKSPACE/profile.cov
cd v2
go test -timeout=60s -race -covermode=atomic -coverprofile=$GITHUB_WORKSPACE/profile.cov_tmp
# combine the coverage files
cat $GITHUB_WORKSPACE/profile.cov_tmp | grep -v "_mock.go" | grep -v "mode:" >> $GITHUB_WORKSPACE/profile.cov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests