mirror of
https://github.com/golang/go
synced 2024-11-26 07:38:00 -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:
parent
37ca84a9cd
commit
ad17b65b34
@ -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
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user