diff options
| author | Ian Lance Taylor <iant@golang.org> | 2021-02-21 15:28:41 -0800 |
|---|---|---|
| committer | Ian Lance Taylor <iant@golang.org> | 2021-02-25 15:23:02 +0000 |
| commit | ad17b65b340d5a40d0da1b4cbcdc239061e97c65 (patch) | |
| tree | 5007f080edafd763646999970ca7768aab635cc3 /src/testing | |
| parent | 37ca84a9cd6a8a76dfe91263a17d2b92b17a24b3 (diff) | |
| download | go-ad17b65b340d5a40d0da1b4cbcdc239061e97c65.tar.xz | |
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>
Diffstat (limited to 'src/testing')
| -rw-r--r-- | src/testing/fstest/testfs.go | 2 | ||||
| -rw-r--r-- | src/testing/fstest/testfs_test.go | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/src/testing/fstest/testfs.go b/src/testing/fstest/testfs.go index 8fc8acaaf3..736bbf0590 100644 --- a/src/testing/fstest/testfs.go +++ b/src/testing/fstest/testfs.go @@ -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 } diff --git a/src/testing/fstest/testfs_test.go b/src/testing/fstest/testfs_test.go index 5b8813c343..aefb4b3361 100644 --- a/src/testing/fstest/testfs_test.go +++ b/src/testing/fstest/testfs_test.go @@ -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) + } +} |
