Skip to content

Commit

Permalink
go/types: skip tests that require GOROOT/test if it is not present
Browse files Browse the repository at this point in the history
cmd/distpack removes GOROOT/test from its archive of the distribution.

For #24904.

Change-Id: Ifde441f048f8af52f8973555b196ab0520b48ab7
Reviewed-on: https://go-review.googlesource.com/c/go/+/504057
Auto-Submit: Bryan Mills <[email protected]>
Run-TryBot: Bryan Mills <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
  • Loading branch information
Bryan C. Mills authored and gopherbot committed Jun 16, 2023
1 parent 3891ecb commit a48f9c2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/cmd/compile/internal/types2/stdlib_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,14 @@ func firstComment(filename string) (first string) {
func testTestDir(t *testing.T, path string, ignore ...string) {
files, err := os.ReadDir(path)
if err != nil {
// cmd/distpack deletes GOROOT/test, so skip the test if it isn't present.
// cmd/distpack also requires GOROOT/VERSION to exist, so use that to
// suppress false-positive skips.
if _, err := os.Stat(filepath.Join(testenv.GOROOT(t), "test")); os.IsNotExist(err) {
if _, err := os.Stat(filepath.Join(testenv.GOROOT(t), "VERSION")); err == nil {
t.Skipf("skipping: GOROOT/test not present")
}
}
t.Fatal(err)
}

Expand Down
8 changes: 8 additions & 0 deletions src/go/types/stdlib_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,14 @@ func firstComment(filename string) string {
func testTestDir(t *testing.T, path string, ignore ...string) {
files, err := os.ReadDir(path)
if err != nil {
// cmd/distpack deletes GOROOT/test, so skip the test if it isn't present.
// cmd/distpack also requires GOROOT/VERSION to exist, so use that to
// suppress false-positive skips.
if _, err := os.Stat(filepath.Join(testenv.GOROOT(t), "test")); os.IsNotExist(err) {
if _, err := os.Stat(filepath.Join(testenv.GOROOT(t), "VERSION")); err == nil {
t.Skipf("skipping: GOROOT/test not present")
}
}
t.Fatal(err)
}

Expand Down

0 comments on commit a48f9c2

Please sign in to comment.