1
0
mirror of https://github.com/golang/go synced 2024-11-26 11:08:38 -07:00

testing/fstest: treat dash specially when building glob

"[-]" 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>
This commit is contained in:
Ian Lance Taylor 2021-02-21 15:28:41 -08:00
parent 37ca84a9cd
commit ad17b65b34
2 changed files with 10 additions and 1 deletions

View 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
}

View 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)
}
}