]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: convert TestGoBuildGOPATHOrder to the script framework
authorMichael Matloob <matloob@golang.org>
Mon, 13 Jan 2020 18:51:14 +0000 (13:51 -0500)
committerMichael Matloob <matloob@golang.org>
Thu, 27 Feb 2020 21:31:52 +0000 (21:31 +0000)
It looks like TestGoBuildGOPATHOrderBroken has been fixed so I've converted
that too, without the skip.

Part of converting all tests to script framework to improve
test parallelism.

Updates #36320
Updates #17751

Change-Id: I7ee77f22fb888811c175bcdc5eb814c80fbec420
Reviewed-on: https://go-review.googlesource.com/c/go/+/214432
Reviewed-by: Jay Conrod <jayconrod@google.com>
src/cmd/go/go_test.go
src/cmd/go/testdata/script/build_gopath_order.txt [new file with mode: 0644]

index 2e63de44f3e90e73b20f19f18b0fcc0de48ba50c..8389f86b6e03f5662df184e38a51af71eea1ef95 100644 (file)
@@ -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 (file)
index 0000000..ac26c28
--- /dev/null
@@ -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