Navigation Menu

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
Labels
FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@bradfitz
Copy link
Contributor

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

@bradfitz bradfitz added help wanted NeedsFix The path to resolution is known, but the work has not been done. labels Jul 14, 2017
@bradfitz bradfitz added this to the Go1.10 milestone Jul 14, 2017
@dlsniper
Copy link
Contributor

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

Hope it helps.

@jessfraz
Copy link
Contributor

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?

@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

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

@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.
Labels
FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

5 participants