]> Cypherpunks repositories - gostls13.git/commitdiff
path/filepath: avoid assuming that GOROOT/test is present
authorBryan C. Mills <bcmills@google.com>
Fri, 16 Jun 2023 18:46:37 +0000 (14:46 -0400)
committerGopher Robot <gobot@golang.org>
Fri, 16 Jun 2023 19:37:46 +0000 (19:37 +0000)
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 <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>

src/path/filepath/path_test.go

index 469a107d147acb8904cc18e52ba60664e9d23ee5..3c78e415d22766f47d21d0653ec308c83f9f820d 100644 (file)
@@ -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)
        }
 }