aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan C. Mills <bcmills@google.com>2023-06-16 15:24:56 -0400
committerGopher Robot <gobot@golang.org>2023-06-16 20:39:14 +0000
commita48f9c26d5735e7612d919ffe7809e701ffe0a76 (patch)
tree4d3cf16da54968f7a8b963196f1a58ffee494abd
parent3891ecbd3551bb9dad706175fc447dcc5c43eacf (diff)
downloadgo-a48f9c26d5735e7612d919ffe7809e701ffe0a76.tar.gz
go-a48f9c26d5735e7612d919ffe7809e701ffe0a76.zip
go/types: skip tests that require GOROOT/test if it is not present
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 <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
-rw-r--r--src/cmd/compile/internal/types2/stdlib_test.go8
-rw-r--r--src/go/types/stdlib_test.go8
2 files changed, 16 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/types2/stdlib_test.go b/src/cmd/compile/internal/types2/stdlib_test.go
index 9a03526b68..ee852f5c4c 100644
--- a/src/cmd/compile/internal/types2/stdlib_test.go
+++ b/src/cmd/compile/internal/types2/stdlib_test.go
@@ -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)
}
diff --git a/src/go/types/stdlib_test.go b/src/go/types/stdlib_test.go
index 770d3bf52a..07c9222537 100644
--- a/src/go/types/stdlib_test.go
+++ b/src/go/types/stdlib_test.go
@@ -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)
}