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 test -cover fails when xtest imports main which imports package being tested #14811
Comments
@hvnsweeting can you please include the command you used to run this program. Thanks |
it's when I run -cover test for a subpackage of a subpackage of a package.
|
Is it possible for you to not anonymise your examples ? On Mon, Mar 14, 2016 at 4:13 PM, Viet Hung Nguyen notifications@github.com
|
where can I reach you to send this privately? I have to do that according to company policy, sorry |
Please don't contact me privately. If you cannot share this, that's fine, Can you please append -x to the arguement and post the whole result. Thanks. On Mon, Mar 14, 2016 at 4:22 PM, Viet Hung Nguyen notifications@github.com
|
|
Try using 'go install' first On Mon, Mar 14, 2016 at 4:47 PM, Viet Hung Nguyen notifications@github.com
|
It's shorter now
|
Is t-p a main package ? |
yes it's |
Can you also show us the output of |
here you are
|
Sorry, we're not going to get to this for Go 1.7. |
|
@chr0n1x, what does 'go version' print? And 'go tool -n cover'? It sounds like you are not using a binary distribution, and that you built from old sources from before we moved cmd/cover into the main tree. It doesn't sound like Go 1.7. In any event, that seems unrelated to this issue, so please open a separate issue or mail golang-nuts to continue debugging that problem. |
Reproduced in https://go-review.googlesource.com/31661. The problem is package p (a main package) imports package q, and package q_test imports p. The rebuilding for coverage does not handle rebuiling the coverage-aware p correctly for that import. I don't remember why we allow tests to import main packages. That may not have been intentional, in which case the bug is that the test even runs in non-cover mode. See also #17475. |
As I recall we allow tests to import the main package so that you can write main_test.go without requiring that it be in package main. |
CL https://golang.org/cl/31821 mentions this issue. |
I'm using
Go env
when I run go test with coverage (-cover), it failed to import the package that it was okay when I ran test
without -cover. I added debug log to compile and rebuild go, I got those log:
AFAIU, it should import from /Users/hvn/Github/gomeo/pkg/darwin_amd64/git.example.com/repo/_test/git.example.com/repo/t-p.a, no?
https://github.com/golang/go/blob/release-branch.go1.6/src/cmd/go/test.go#L697
I removed this line, rebuilt go and it worked https://github.com/golang/go/blob/release-branch.go1.6/src/cmd/go/test.go#L850
The text was updated successfully, but these errors were encountered: