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

go/types: unset GOPATH before running tests #21013

Closed
bradfitz opened this issue Jul 14, 2017 · 3 comments
Closed

go/types: unset GOPATH before running tests #21013

bradfitz opened this issue Jul 14, 2017 · 3 comments

Comments

@bradfitz
Copy link
Contributor

@bradfitz bradfitz commented Jul 14, 2017

I was just debugging a mysterious test failure at d5da104 (almost Go 1.9).

I was getting:

bradfitz@gdev:~/go/src$ go test -short go/types
--- FAIL: TestFailedImport (0.26s)
        api_test.go:1328: for source importer, got unexpected error: src:6:11: undeclared name: foo
        api_test.go:1328: for source importer, got unexpected error: src:7:10: undeclared name: foo
        api_test.go:1328: for source importer, got unexpected error: src:9:24: undeclared name: foo
        api_test.go:1328: for source importer, got unexpected error: src:4:8: "foo" imported but not used as main
        api_test.go:1351: for source importer, got "main", want "foo"
FAIL
FAIL    go/types        0.694s

After debugging, it turns out it was because I had a $GOPATH/src/foo directory with a package main in it that I was previously using to debug something else.

I don't expect that go/types (or any other test in std) should respect or be affected by the user's $GOPATH.

/cc @griesemer @alandonovan

@dlsniper
Copy link
Contributor

@dlsniper dlsniper commented Jul 15, 2017

As part of the GopherCon Contrib Workshop, I've managed to find that this got broken by: 2ad7453

Hope it helps.

Loading

@jessfraz
Copy link
Contributor

@jessfraz jessfraz commented Jul 17, 2017

so make.bash unsets the GOPATH so this only happens when called by go test
should that test just unset the GOPATH in the beginning as well?

Loading

@rsc rsc changed the title go/types: user's GOPATH interferes with TestFailedImport go/types: unset GOPATH before running tests Nov 22, 2017
@griesemer griesemer self-assigned this Nov 29, 2017
@gopherbot
Copy link

@gopherbot gopherbot commented Dec 1, 2017

Change https://golang.org/cl/81578 mentions this issue: go/types: don't use directory foo which might exist under GOPATH

Loading

@gopherbot gopherbot closed this in 22b4c83 Dec 1, 2017
@golang golang locked and limited conversation to collaborators Dec 1, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants