]> Cypherpunks repositories - gostls13.git/commitdiff
go/types: skip tests that require GOROOT/test if it is not present
authorBryan C. Mills <bcmills@google.com>
Fri, 16 Jun 2023 19:24:56 +0000 (15:24 -0400)
committerGopher Robot <gobot@golang.org>
Fri, 16 Jun 2023 20:39:14 +0000 (20:39 +0000)
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>
src/cmd/compile/internal/types2/stdlib_test.go
src/go/types/stdlib_test.go

index 9a03526b68ba4d17b1fbb5249ad0efe062eafcbc..ee852f5c4c839ae2048599505b184f4f6635d8c9 100644 (file)
@@ -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)
        }
 
index 770d3bf52abeb5f6093aea7fdd7eff2a09923d80..07c92225373ce63e37e3137262f7f9dd6b576085 100644 (file)
@@ -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)
        }