From c1bc44642db321c2f125fd043c220cac08877e95 Mon Sep 17 00:00:00 2001 From: "Bryan C. Mills" Date: Fri, 16 Jun 2023 14:46:37 -0400 Subject: [PATCH] path/filepath: avoid assuming that GOROOT/test is present GOROOT/test is pruned out by cmd/distpack. It isn't really needed for the test anyway; the test can instead use the "src/unicode" subdirectory, which is even within the same module. This test was previously adjusted in CL 13467045 and CL 31859. Unlike in previous iterations of the test, the directories used in this revision are covered by the Go 1 compatibility policy and thus unlikely to disappear. For #24904. Change-Id: I156ae18354bcbc2ddd8d22b210f16ba1e97cd5d1 Reviewed-on: https://go-review.googlesource.com/c/go/+/504116 Auto-Submit: Bryan Mills Reviewed-by: Ian Lance Taylor TryBot-Result: Gopher Robot Run-TryBot: Bryan Mills --- src/path/filepath/path_test.go | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/src/path/filepath/path_test.go b/src/path/filepath/path_test.go index 469a107d14..3c78e415d2 100644 --- a/src/path/filepath/path_test.go +++ b/src/path/filepath/path_test.go @@ -1622,36 +1622,33 @@ func TestBug3486(t *testing.T) { // https://golang.org/issue/3486 if runtime.GOOS == "ios" { t.Skipf("skipping on %s/%s", runtime.GOOS, runtime.GOARCH) } - root, err := filepath.EvalSymlinks(testenv.GOROOT(t) + "/test") - if err != nil { - t.Fatal(err) - } - bugs := filepath.Join(root, "fixedbugs") - ken := filepath.Join(root, "ken") - seenBugs := false - seenKen := false - err = filepath.Walk(root, func(pth string, info fs.FileInfo, err error) error { + root := filepath.Join(testenv.GOROOT(t), "src", "unicode") + utf16 := filepath.Join(root, "utf16") + utf8 := filepath.Join(root, "utf8") + seenUTF16 := false + seenUTF8 := false + err := filepath.Walk(root, func(pth string, info fs.FileInfo, err error) error { if err != nil { t.Fatal(err) } switch pth { - case bugs: - seenBugs = true + case utf16: + seenUTF16 = true return filepath.SkipDir - case ken: - if !seenBugs { - t.Fatal("filepath.Walk out of order - ken before fixedbugs") + case utf8: + if !seenUTF16 { + t.Fatal("filepath.Walk out of order - utf8 before utf16") } - seenKen = true + seenUTF8 = true } return nil }) if err != nil { t.Fatal(err) } - if !seenKen { - t.Fatalf("%q not seen", ken) + if !seenUTF8 { + t.Fatalf("%q not seen", utf8) } }