Skip to content

Commit

Permalink
go/internal/gcimporter: skip TestImportTypeparamTests if GOROOT/test …
Browse files Browse the repository at this point in the history
…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 <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
  • Loading branch information
Bryan C. Mills authored and gopherbot committed Jun 16, 2023
1 parent 6087671 commit 3891ecb
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/go/internal/gcimporter/gcimporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,24 @@ func TestImportTypeparamTests(t *testing.T) {
t.Skipf("gc-built packages not available (compiler = %s)", runtime.Compiler)
}

// cmd/distpack removes the GOROOT/test directory, so skip if it isn't there.
// cmd/distpack also requires the presence of GOROOT/VERSION, so use that to
// avoid false-positive skips.
gorootTest := filepath.Join(testenv.GOROOT(t), "test")
if _, err := os.Stat(gorootTest); os.IsNotExist(err) {
if _, err := os.Stat(filepath.Join(testenv.GOROOT(t), "VERSION")); err == nil {
t.Skipf("skipping: GOROOT/test not present")
}
}

testenv.MustHaveGoBuild(t)

tmpdir := mktmpdir(t)
defer os.RemoveAll(tmpdir)

// Check go files in test/typeparam, except those that fail for a known
// reason.
rootDir := filepath.Join(testenv.GOROOT(t), "test", "typeparam")
rootDir := filepath.Join(gorootTest, "typeparam")
list, err := os.ReadDir(rootDir)
if err != nil {
t.Fatal(err)
Expand Down

0 comments on commit 3891ecb

Please sign in to comment.