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

Aggregate coverage value across packages #2

Closed
jnadler opened this issue Jul 14, 2018 · 5 comments
Closed

Aggregate coverage value across packages #2

jnadler opened this issue Jul 14, 2018 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@jnadler
Copy link

jnadler commented Jul 14, 2018

I just tried this out - nice work btw!
Unfortunately it doesn't seem to work with multiple packages, which is a shame because a single coverage % value across the whole project is really the key thing I'm after. The value in the badge is the coverage from the first package only.
To test across all packages I ran go test ./... -coverprofile=coverage.out && go tool cover -html=coverage.out -o=coverage.html

@jpoles1
Copy link
Owner

jpoles1 commented Jul 15, 2018

Hey @jnadler, thanks for bringing this up. I'm actually working on a project with such a structure now, and I ran into the same issue. I've got to implement a solution, I think I'll use:
go tool cover -func=coverage.out

@jpoles1 jpoles1 self-assigned this Jul 15, 2018
@jpoles1 jpoles1 added the bug Something isn't working label Jul 15, 2018
@jpoles1
Copy link
Owner

jpoles1 commented Jul 15, 2018

I think the following bash command should work for most projects:
go test ./... -coverprofile=coverage.out && go tool cover -func=coverage.out

@jnadler, when run on your project, does this seem to work, and generate a line akin to:
total: (statements) 74.6%

@jpoles1
Copy link
Owner

jpoles1 commented Jul 15, 2018

Alrighty, @jnadler I think the above fix should work. Please give it a try and let me know!

@jnadler
Copy link
Author

jnadler commented Jul 15, 2018

Well that's closer, but in this project there are still some packages with no tests whatsoever, and so we get a vastly inflated coverage number (coverage is good in the packages with tests).

That's no fault of your software however. I've just found this bug which seems to cover it:
golang/go#24570

I'll close this as there seems to be nothing you can do until they fix that one. Thanks for the speedy response, and for sharing this tool!!

@jnadler jnadler closed this as completed Jul 15, 2018
@jnadler
Copy link
Author

jnadler commented Jul 15, 2018

I should mention - I think that change is good, and I appreciate that it doesn't depend on specific makefile setup. IMO it would be good to merge that change to master, though it might require a small change to the readme.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants