Skip to content

Commit

Permalink
all: fix x/tools tests that fail with a go1.23.1 go.work file
Browse files Browse the repository at this point in the history
Delete or selectively skip tests that made either of the following
assumptions:
- The default GODEBUG is that of Go 1.22 (not true given a go.work
  file).
- GOROOT is a development version of Go (not true if GOROOT is prepared
  by cmd/distpack).

Fixes golang/go#70081
Fixes golang/go#70082

Change-Id: I47dfb225427f75e3be833eed3ba677ff454935f1
Reviewed-on: https://go-review.googlesource.com/c/tools/+/622896
Reviewed-by: Alan Donovan <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
  • Loading branch information
findleyr committed Oct 28, 2024
1 parent 5e6a32d commit 4d48798
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions internal/testenv/testenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,3 +490,17 @@ func NeedsGoExperiment(t testing.TB, flag string) {
t.Skipf("skipping test: flag %q is not set in GOEXPERIMENT=%q", flag, goexp)
}
}

// NeedsGOROOTDir skips the test if GOROOT/dir does not exist, and GOROOT is a
// released version of Go (=has a VERSION file). Some GOROOT directories are
// removed by cmd/distpack.
//
// See also golang/go#70081.
func NeedsGOROOTDir(t *testing.T, dir string) {
gorootTest := filepath.Join(GOROOT(t), dir)
if _, err := os.Stat(gorootTest); os.IsNotExist(err) {
if _, err := os.Stat(filepath.Join(GOROOT(t), "VERSION")); err == nil {
t.Skipf("skipping: GOROOT/%s not present", dir)
}
}
}

0 comments on commit 4d48798

Please sign in to comment.