Skip to content

Commit 3891ecb

Browse files
Bryan C. Millsgopherbot
Bryan C. Mills
authored andcommitted
go/internal/gcimporter: skip TestImportTypeparamTests if GOROOT/test is missing
cmd/distpack removes GOROOT/test, so skip the test if it isn't there. For #24904. Change-Id: Iac381517d0540056b2ccea0dc1bd716113b18468 Reviewed-on: https://go-review.googlesource.com/c/go/+/504117 TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Auto-Submit: Bryan Mills <[email protected]> Run-TryBot: Bryan Mills <[email protected]>
1 parent 6087671 commit 3891ecb

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/go/internal/gcimporter/gcimporter_test.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,24 @@ func TestImportTypeparamTests(t *testing.T) {
137137
t.Skipf("gc-built packages not available (compiler = %s)", runtime.Compiler)
138138
}
139139

140+
// cmd/distpack removes the GOROOT/test directory, so skip if it isn't there.
141+
// cmd/distpack also requires the presence of GOROOT/VERSION, so use that to
142+
// avoid false-positive skips.
143+
gorootTest := filepath.Join(testenv.GOROOT(t), "test")
144+
if _, err := os.Stat(gorootTest); os.IsNotExist(err) {
145+
if _, err := os.Stat(filepath.Join(testenv.GOROOT(t), "VERSION")); err == nil {
146+
t.Skipf("skipping: GOROOT/test not present")
147+
}
148+
}
149+
140150
testenv.MustHaveGoBuild(t)
141151

142152
tmpdir := mktmpdir(t)
143153
defer os.RemoveAll(tmpdir)
144154

145155
// Check go files in test/typeparam, except those that fail for a known
146156
// reason.
147-
rootDir := filepath.Join(testenv.GOROOT(t), "test", "typeparam")
157+
rootDir := filepath.Join(gorootTest, "typeparam")
148158
list, err := os.ReadDir(rootDir)
149159
if err != nil {
150160
t.Fatal(err)

0 commit comments

Comments
 (0)