Skip to content

Commit a48f9c2

Browse files
Bryan C. Millsgopherbot
Bryan C. Mills
authored andcommitted
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 <[email protected]> Run-TryBot: Bryan Mills <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent 3891ecb commit a48f9c2

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/cmd/compile/internal/types2/stdlib_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,14 @@ func firstComment(filename string) (first string) {
206206
func testTestDir(t *testing.T, path string, ignore ...string) {
207207
files, err := os.ReadDir(path)
208208
if err != nil {
209+
// cmd/distpack deletes GOROOT/test, so skip the test if it isn't present.
210+
// cmd/distpack also requires GOROOT/VERSION to exist, so use that to
211+
// suppress false-positive skips.
212+
if _, err := os.Stat(filepath.Join(testenv.GOROOT(t), "test")); os.IsNotExist(err) {
213+
if _, err := os.Stat(filepath.Join(testenv.GOROOT(t), "VERSION")); err == nil {
214+
t.Skipf("skipping: GOROOT/test not present")
215+
}
216+
}
209217
t.Fatal(err)
210218
}
211219

src/go/types/stdlib_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,14 @@ func firstComment(filename string) string {
209209
func testTestDir(t *testing.T, path string, ignore ...string) {
210210
files, err := os.ReadDir(path)
211211
if err != nil {
212+
// cmd/distpack deletes GOROOT/test, so skip the test if it isn't present.
213+
// cmd/distpack also requires GOROOT/VERSION to exist, so use that to
214+
// suppress false-positive skips.
215+
if _, err := os.Stat(filepath.Join(testenv.GOROOT(t), "test")); os.IsNotExist(err) {
216+
if _, err := os.Stat(filepath.Join(testenv.GOROOT(t), "VERSION")); err == nil {
217+
t.Skipf("skipping: GOROOT/test not present")
218+
}
219+
}
212220
t.Fatal(err)
213221
}
214222

0 commit comments

Comments
 (0)