aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan C. Mills <bcmills@google.com>2023-06-16 15:15:25 -0400
committerGopher Robot <gobot@golang.org>2023-06-16 20:38:49 +0000
commit3891ecbd3551bb9dad706175fc447dcc5c43eacf (patch)
tree3b5e71e746ebfa3587398a09e91ebbba4eeb7f26
parent60876717b402f0dd6b4f585827779a9e435400c8 (diff)
downloadgo-3891ecbd3551bb9dad706175fc447dcc5c43eacf.tar.gz
go-3891ecbd3551bb9dad706175fc447dcc5c43eacf.zip
go/internal/gcimporter: skip TestImportTypeparamTests if GOROOT/test 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>
-rw-r--r--src/go/internal/gcimporter/gcimporter_test.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/go/internal/gcimporter/gcimporter_test.go b/src/go/internal/gcimporter/gcimporter_test.go
index 9ab29f3b1c..25ff402277 100644
--- a/src/go/internal/gcimporter/gcimporter_test.go
+++ b/src/go/internal/gcimporter/gcimporter_test.go
@@ -137,6 +137,16 @@ 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)
@@ -144,7 +154,7 @@ func TestImportTypeparamTests(t *testing.T) {
// 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)