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 test <single file> no longer works with new vendoring support #14842

Closed
bschoch opened this issue Mar 16, 2016 · 4 comments
Closed
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. Vendoring WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@bschoch
Copy link

bschoch commented Mar 16, 2016

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?
go version go1.6 darwin/amd64

What operating system and processor architecture are you using (go env)?
go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/Bradley/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GO15VENDOREXPERIMENT="1"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common"
CXX="clang++"
CGO_ENABLED="1"

What did you do?
I am not sure if
go test <single file>
is officially supported but it used to work. If any of the packages imported by the test file are in the new vendor directory I get an error. If none of the packages are in the vendor directory the test runs fine.

What did you expect to see?

I expect it to first print the path to my projects vendor directory, then look in the GOROOT, and then look in the GOPATH.

What did you see instead?

Bradleys-MacBook-Pro:wallet-api Bradley$ go test ./integration/api_test.go 
# command-line-arguments
integration/api_test.go:19:2: cannot find package "command-li/vendor/golang.org/x/net/context" in any of:
    /usr/local/go/src/command-li/vendor/golang.org/x/net/context (from $GOROOT)
    /Users/Bradley/go/src/command-li/vendor/golang.org/x/net/context (from $GOPATH)

It seems to be manipulating the string wrong to determine the paths for where it is supposed to look.
I can change how we run certain tests regardless but this behavior does not seem correct.

@ianlancetaylor ianlancetaylor changed the title go test <single file> no longer works with new vendorring support cmd/go: go test <single file> no longer works with new vendoring support Mar 16, 2016
@ianlancetaylor ianlancetaylor added this to the Go1.7 milestone Mar 16, 2016
@davecheney
Copy link
Contributor

What's happening is the single file you provided is being compiled in a
"fake" package. That package is no longer a sibling of the correct vendor/
directory so those paths are invisible.

I cannot comment on if this is supported behaviour or not, but can tell you
that the go tool really wants to work with packages, not single files, and
you will get much better results if you do things its way.

On Thu, 17 Mar 2016, 09:37 Bradley, notifications@github.com wrote:

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?
go version go1.6 darwin/amd64

What operating system and processor architecture are you using (go env)?
go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/Bradley/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GO15VENDOREXPERIMENT="1"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments
-fmessage-length=0 -fno-common"
CXX="clang++"
CGO_ENABLED="1"

What did you do?
I am not sure if
go test
is officially supported but it used to work. If any of the packages
imported by the test file are in the new vendor directory I get an error.
If none of the packages are in the vendor directory the test runs fine.

What did you expect to see?

I expect it to first print the path to my projects vendor directory, then
look in the GOPATH, and then look in the GOROOT.

What did you see instead?

Bradleys-MacBook-Pro:wallet-api Bradley$ go test ./integration/api_test.go

command-line-arguments

integration/api_test.go:19:2: cannot find package "command-li/vendor/golang.org/x/net/context" in any of:
/usr/local/go/src/command-li/vendor/golang.org/x/net/context (from $GOROOT)
/Users/Bradley/go/src/command-li/vendor/golang.org/x/net/context (from $GOPATH)

It seems to be manipulating the string wrong to determine the paths for
where it is supposed to look.
I can change how we run certain tests regardless but this behavior does
not seem correct.


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#14842

@mdempsky mdempsky modified the milestones: Go1.8, Go1.7 May 20, 2016
@quentinmit quentinmit added the NeedsFix The path to resolution is known, but the work has not been done. label Oct 6, 2016
@rsc
Copy link
Contributor

rsc commented Oct 21, 2016

Sorry for the delayed questions, but I need to know more about the file tree.

What is the import statement at integration/api_test.go line 19?

What directory is the go test command being run in?

That is, where is the integration directory relative to the command-li/vendor directory?

Thanks.

@rsc rsc added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Oct 21, 2016
@rsc rsc modified the milestones: Go1.9, Go1.8 Nov 3, 2016
@bschoch
Copy link
Author

bschoch commented Nov 3, 2016

The import statement is "golang.org/x/net/context"

I ran the tests from the base project directory, the vendor and the integration directory are in the directory that I run the tests from.
wallet-api/integration
wallet-api/vendor

cd wallet-api
go test ./integration/api_test.go

@bschoch
Copy link
Author

bschoch commented Jul 15, 2017

This appears to be fixed.

@bschoch bschoch closed this as completed Jul 15, 2017
@golang golang locked and limited conversation to collaborators Jul 15, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. Vendoring WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

8 participants