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

proposal: testing: support automatic multiple package coverage #21126

Closed
dlsniper opened this issue Jul 22, 2017 · 3 comments

Comments

Projects
None yet
4 participants
@dlsniper
Copy link
Contributor

commented Jul 22, 2017

Currently it's very hard to support coverage for the tested package and all the dependencies of that package.

In order to do this today, one would need to do something like this:

go test -coverpkg `go list -f {{.Deps}} | sed 's/\[//g' | sed 's/]//g' | sed 's/ /,/g'`,tested/package/name tested/package/name

The problem is that this would also list the standard library dependencies, which is not really useful and it's hard to write as well (see the fact that one needs to append the name of the tested package to actually get the coverage for it). The above command also doesn't work on Windows.

The other option would be to use:

go test -coverpkg PACKAGE_DIR/... tested/package/name

This however will not show dependencies from GOPATH.

As such, I'm proposing adding a magical keyword named deps (like all) to solve this problem. The way it should work would be:

go test -coverpkg deps tested/package/name

This comes up pretty often, see: https://youtrack.jetbrains.com/issue/GO-1541 for the number of voters / watchers or duplicate issues. It is true that the IDE could generate the list of packages but the users that do not use such a tool wouldn't be able to benefit from it.

Please note this is different from #6909.

@gopherbot gopherbot added this to the Proposal milestone Jul 22, 2017

@gopherbot gopherbot added the Proposal label Jul 22, 2017

@AlekSi

This comment has been minimized.

Copy link
Contributor

commented Jul 25, 2017

I made a tool for that and #6909: https://github.com/AlekSi/gocovermerge.

@rsc

This comment has been minimized.

Copy link
Contributor

commented Jul 31, 2017

Note that if everything is vendored (and unnecessary things are not vendored), what you want is "PACKAGE_DIR/vendor/...". There may end up being a syntax like that in the new package management work as well. Probably good to wait for that.

@rsc rsc added the Proposal-Hold label Jul 31, 2017

@rsc

This comment has been minimized.

Copy link
Contributor

commented Nov 10, 2017

I reopened #10271 because we are in a position to make -coverpkg=all mean "all dependencies".

Closing this issue since it is now a duplicate of #10271.

@rsc rsc closed this Nov 10, 2017

@golang golang locked and limited conversation to collaborators Nov 10, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.