]> Cypherpunks repositories - gostls13.git/commitdiff
testing/fstest: treat dash specially when building glob
authorIan Lance Taylor <iant@golang.org>
Sun, 21 Feb 2021 23:28:41 +0000 (15:28 -0800)
committerIan Lance Taylor <iant@golang.org>
Thu, 25 Feb 2021 15:23:02 +0000 (15:23 +0000)
"[-]" is not a valid path.Match pattern.

Fixes #44474

Change-Id: I0932bbf08ffb8ad0c5337d69d0893f53c1ba89ad
Reviewed-on: https://go-review.googlesource.com/c/go/+/294869
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
src/testing/fstest/testfs.go
src/testing/fstest/testfs_test.go

index 8fc8acaaf3bf1bb88fda7138002f5678a8266178..736bbf0590e981828382eba6deff2dc1e2c755ac 100644 (file)
@@ -303,7 +303,7 @@ func (t *fsTester) checkGlob(dir string, list []fs.DirEntry) {
                for i, e := range elem {
                        var pattern []rune
                        for j, r := range e {
-                               if r == '*' || r == '?' || r == '\\' || r == '[' {
+                               if r == '*' || r == '?' || r == '\\' || r == '[' || r == '-' {
                                        pattern = append(pattern, '\\', r)
                                        continue
                                }
index 5b8813c3431339fb98ea9e2ecacf188103550770..aefb4b33617ab119e30d259517d37694defbe560 100644 (file)
@@ -29,3 +29,12 @@ func TestSymlink(t *testing.T) {
                t.Fatal(err)
        }
 }
+
+func TestDash(t *testing.T) {
+       m := MapFS{
+               "a-b/a": {Data: []byte("a-b/a")},
+       }
+       if err := TestFS(m, "a-b/a"); err != nil {
+               t.Error(err)
+       }
+}