diff --git a/src/cmd/go/go_test.go b/src/cmd/go/go_test.go index 2e63de44f3..8389f86b6e 100644 --- a/src/cmd/go/go_test.go +++ b/src/cmd/go/go_test.go @@ -1945,59 +1945,6 @@ func TestGoInstallPkgdir(t *testing.T) { tg.mustExist(filepath.Join(pkg, "sync/atomic.a")) } -func TestGoBuildGOPATHOrder(t *testing.T) { - // golang.org/issue/14176#issuecomment-179895769 - // golang.org/issue/14192 - // -I arguments to compiler could end up not in GOPATH order, - // leading to unexpected import resolution in the compiler. - // This is still not a complete fix (see golang.org/issue/14271 and next test) - // but it is clearly OK and enough to fix both of the two reported - // instances of the underlying problem. It will have to do for now. - - tg := testgo(t) - defer tg.cleanup() - tg.makeTempdir() - tg.setenv("GOPATH", tg.path("p1")+string(filepath.ListSeparator)+tg.path("p2")) - - tg.tempFile("p1/src/foo/foo.go", "package foo\n") - tg.tempFile("p2/src/baz/baz.go", "package baz\n") - tg.tempFile("p2/pkg/"+runtime.GOOS+"_"+runtime.GOARCH+"/foo.a", "bad\n") - tg.tempFile("p1/src/bar/bar.go", ` - package bar - import _ "baz" - import _ "foo" - `) - - tg.run("install", "-x", "bar") -} - -func TestGoBuildGOPATHOrderBroken(t *testing.T) { - // This test is known not to work. - // See golang.org/issue/14271. - t.Skip("golang.org/issue/14271") - - tg := testgo(t) - defer tg.cleanup() - tg.makeTempdir() - - tg.tempFile("p1/src/foo/foo.go", "package foo\n") - tg.tempFile("p2/src/baz/baz.go", "package baz\n") - tg.tempFile("p1/pkg/"+runtime.GOOS+"_"+runtime.GOARCH+"/baz.a", "bad\n") - tg.tempFile("p2/pkg/"+runtime.GOOS+"_"+runtime.GOARCH+"/foo.a", "bad\n") - tg.tempFile("p1/src/bar/bar.go", ` - package bar - import _ "baz" - import _ "foo" - `) - - colon := string(filepath.ListSeparator) - tg.setenv("GOPATH", tg.path("p1")+colon+tg.path("p2")) - tg.run("install", "-x", "bar") - - tg.setenv("GOPATH", tg.path("p2")+colon+tg.path("p1")) - tg.run("install", "-x", "bar") -} - // For issue 14337. func TestParallelTest(t *testing.T) { tooSlow(t) diff --git a/src/cmd/go/testdata/script/build_gopath_order.txt b/src/cmd/go/testdata/script/build_gopath_order.txt new file mode 100644 index 0000000000..ac26c28a9f --- /dev/null +++ b/src/cmd/go/testdata/script/build_gopath_order.txt @@ -0,0 +1,35 @@ +# golang.org/issue/14176#issuecomment-179895769 +# golang.org/issue/14192 +# -I arguments to compiler could end up not in GOPATH order, +# leading to unexpected import resolution in the compiler. + +env GOPATH=$WORK/p1${:}$WORK/p2 +mkdir $WORK/p1/src/foo $WORK/p2/src/baz +mkdir $WORK/p2/pkg/${GOOS}_${GOARCH} $WORK/p1/src/bar +cp foo.go $WORK/p1/src/foo/foo.go +cp baz.go $WORK/p2/src/baz/baz.go +cp foo.a $WORK/p2/pkg/${GOOS}_${GOARCH}/foo.a +cp bar.go $WORK/p1/src/bar/bar.go + +go install -x bar + +# add in baz.a to the mix +mkdir $WORK/p1/pkg/${GOOS}_${GOARCH} +cp baz.a $WORK/p1/pkg/${GOOS}_${GOARCH}/baz.a +env GOPATH=$WORK/p1${:}$WORK/p2 +go install -x bar +env GOPATH=$WORK/p2${:}$WORK/p1 +go install -x bar + +-- foo.go -- +package foo +-- baz.go -- +package baz +-- foo.a -- +bad +-- baz.a -- +bad +-- bar.go -- +package bar +import _ "baz" +import _ "foo" \ No newline at end of file