Skip to content

Commit 2cfc5e2

Browse files
committed
cmd/go: convert TestGoBuildGOPATHOrder to the script framework
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>
1 parent 4d6c171 commit 2cfc5e2

File tree

2 files changed

+35
-53
lines changed

2 files changed

+35
-53
lines changed

src/cmd/go/go_test.go

-53
Original file line numberDiff line numberDiff line change
@@ -1945,59 +1945,6 @@ func TestGoInstallPkgdir(t *testing.T) {
19451945
tg.mustExist(filepath.Join(pkg, "sync/atomic.a"))
19461946
}
19471947

1948-
func TestGoBuildGOPATHOrder(t *testing.T) {
1949-
// golang.org/issue/14176#issuecomment-179895769
1950-
// golang.org/issue/14192
1951-
// -I arguments to compiler could end up not in GOPATH order,
1952-
// leading to unexpected import resolution in the compiler.
1953-
// This is still not a complete fix (see golang.org/issue/14271 and next test)
1954-
// but it is clearly OK and enough to fix both of the two reported
1955-
// instances of the underlying problem. It will have to do for now.
1956-
1957-
tg := testgo(t)
1958-
defer tg.cleanup()
1959-
tg.makeTempdir()
1960-
tg.setenv("GOPATH", tg.path("p1")+string(filepath.ListSeparator)+tg.path("p2"))
1961-
1962-
tg.tempFile("p1/src/foo/foo.go", "package foo\n")
1963-
tg.tempFile("p2/src/baz/baz.go", "package baz\n")
1964-
tg.tempFile("p2/pkg/"+runtime.GOOS+"_"+runtime.GOARCH+"/foo.a", "bad\n")
1965-
tg.tempFile("p1/src/bar/bar.go", `
1966-
package bar
1967-
import _ "baz"
1968-
import _ "foo"
1969-
`)
1970-
1971-
tg.run("install", "-x", "bar")
1972-
}
1973-
1974-
func TestGoBuildGOPATHOrderBroken(t *testing.T) {
1975-
// This test is known not to work.
1976-
// See golang.org/issue/14271.
1977-
t.Skip("golang.org/issue/14271")
1978-
1979-
tg := testgo(t)
1980-
defer tg.cleanup()
1981-
tg.makeTempdir()
1982-
1983-
tg.tempFile("p1/src/foo/foo.go", "package foo\n")
1984-
tg.tempFile("p2/src/baz/baz.go", "package baz\n")
1985-
tg.tempFile("p1/pkg/"+runtime.GOOS+"_"+runtime.GOARCH+"/baz.a", "bad\n")
1986-
tg.tempFile("p2/pkg/"+runtime.GOOS+"_"+runtime.GOARCH+"/foo.a", "bad\n")
1987-
tg.tempFile("p1/src/bar/bar.go", `
1988-
package bar
1989-
import _ "baz"
1990-
import _ "foo"
1991-
`)
1992-
1993-
colon := string(filepath.ListSeparator)
1994-
tg.setenv("GOPATH", tg.path("p1")+colon+tg.path("p2"))
1995-
tg.run("install", "-x", "bar")
1996-
1997-
tg.setenv("GOPATH", tg.path("p2")+colon+tg.path("p1"))
1998-
tg.run("install", "-x", "bar")
1999-
}
2000-
20011948
// For issue 14337.
20021949
func TestParallelTest(t *testing.T) {
20031950
tooSlow(t)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# golang.org/issue/14176#issuecomment-179895769
2+
# golang.org/issue/14192
3+
# -I arguments to compiler could end up not in GOPATH order,
4+
# leading to unexpected import resolution in the compiler.
5+
6+
env GOPATH=$WORK/p1${:}$WORK/p2
7+
mkdir $WORK/p1/src/foo $WORK/p2/src/baz
8+
mkdir $WORK/p2/pkg/${GOOS}_${GOARCH} $WORK/p1/src/bar
9+
cp foo.go $WORK/p1/src/foo/foo.go
10+
cp baz.go $WORK/p2/src/baz/baz.go
11+
cp foo.a $WORK/p2/pkg/${GOOS}_${GOARCH}/foo.a
12+
cp bar.go $WORK/p1/src/bar/bar.go
13+
14+
go install -x bar
15+
16+
# add in baz.a to the mix
17+
mkdir $WORK/p1/pkg/${GOOS}_${GOARCH}
18+
cp baz.a $WORK/p1/pkg/${GOOS}_${GOARCH}/baz.a
19+
env GOPATH=$WORK/p1${:}$WORK/p2
20+
go install -x bar
21+
env GOPATH=$WORK/p2${:}$WORK/p1
22+
go install -x bar
23+
24+
-- foo.go --
25+
package foo
26+
-- baz.go --
27+
package baz
28+
-- foo.a --
29+
bad
30+
-- baz.a --
31+
bad
32+
-- bar.go --
33+
package bar
34+
import _ "baz"
35+
import _ "foo"

0 commit comments

Comments
 (0)