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

cmd/go: go run -cover #16537

Closed
AlekSi opened this issue Jul 29, 2016 · 9 comments
Closed

cmd/go: go run -cover #16537

AlekSi opened this issue Jul 29, 2016 · 9 comments
Labels
FrozenDueToAge NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made.
Milestone

Comments

@AlekSi
Copy link
Contributor

AlekSi commented Jul 29, 2016

Currently -cover is only supported in unit tests. Running service with -cover and then running functional/system/API tests against it will give information about what parts are tested and what are not.

It's possible to (ab)use go test -cover -c to get desirable result, but there have to be a better way.

@quentinmit quentinmit added this to the Go1.8 milestone Jul 29, 2016
@quentinmit
Copy link
Contributor

I'm not sure how "go run" would communicate to the subprocess that it should collect coverage. "go test" does so by passing a command-line flag, no?

@broady
Copy link
Member

broady commented Aug 5, 2016

This would be really nice. Here's one example of a test that builds a binary, then runs it to test the main function: app_test.go (and the associated testutil)

It would be great to have that considered for code/test coverage.

@quentinmit quentinmit added the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Oct 6, 2016
@rsc
Copy link
Contributor

rsc commented Oct 21, 2016

Need to think more but I don't really understand what this would mean.

@rsc rsc modified the milestones: Go1.9Early, Go1.8 Oct 21, 2016
@AlekSi
Copy link
Contributor Author

AlekSi commented Oct 21, 2016

I'm not sure how "go run" would communicate to the subprocess that it should collect coverage. "go test" does so by passing a command-line flag, no?

Not quite. Passing -cover to go test enables rewriting of source code. See https://blog.golang.org/cover for more info. go run -cover can do the same.

@dajoo75
Copy link
Contributor

dajoo75 commented May 1, 2017

I uploaded a fix for discussion here: https://go-review.googlesource.com/42096.
cc @rsc

@gopherbot
Copy link

CL https://golang.org/cl/42096 mentions this issue.

@bradfitz bradfitz modified the milestones: Go1.9Maybe, Go1.9Early May 3, 2017
@rsc
Copy link
Contributor

rsc commented May 22, 2017

I tend to agree that we want to keep go run limited in its scope.

But there is no 'go build -cover' so at the very least that would need to happen first. If that did happen, then go run -cover might fall out for free. That said, I'm not sure go build -cover should happen. Coverage is fairly tied to testing. If you did -cover outside of tests you'd need to recreate the testing package support that exports the coverage info.

@rsc rsc closed this as completed May 22, 2017
@AlekSi
Copy link
Contributor Author

AlekSi commented May 23, 2017

Uh. Then maybe testing support for coverage info should be extracted to some package, /x/ maybe? Right now it's private, and existing solution is too fragile.

@ianlancetaylor
Copy link
Contributor

@AlekSi Whatever you suggest, that should probably be in a different issue. We are still unlikely to add go run -cover. Thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made.
Projects
None yet
Development

No branches or pull requests

8 participants