From ec095f1df0ff1b2937205e17b3c011f31d3737ca Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 13 Jul 2020 22:24:52 -0400 Subject: path: avoid import of strings Pushing path lower in the hierarchy, to allow path < io/fs < os in the io/fs prototype. But this change is worth doing even if io/fs is not accepted. Change-Id: Id51b3a638167ca005dadfb9b730287e518ec12a8 Reviewed-on: https://go-review.googlesource.com/c/go/+/243904 Trust: Russ Cox Run-TryBot: Russ Cox TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor Reviewed-by: Rob Pike --- src/path/match_test.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/path/match_test.go') diff --git a/src/path/match_test.go b/src/path/match_test.go index 127180e570..3e027e1f68 100644 --- a/src/path/match_test.go +++ b/src/path/match_test.go @@ -2,9 +2,12 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package path +package path_test -import "testing" +import ( + . "path" + "testing" +) type MatchTest struct { pattern, s string -- cgit v1.2.1 From b5ddc42b465dd5b9532ee336d98343d81a6d35b2 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 22 Oct 2020 12:11:29 -0400 Subject: io/fs, path, path/filepath, testing/fstest: validate patterns in Match, Glob According to #28614, proposal review agreed in December 2018 that Match should return an error for failed matches where the unmatched part of the pattern has a syntax error. (The failed match has to date caused the scan of the pattern to stop early.) This change implements that behavior: the match loop continues scanning to the end of the pattern, even after a confirmed mismatch, to check whether the pattern is even well-formed. The change applies to both path.Match and filepath.Match. Then filepath.Glob and fs.Glob make a single validity-checking call to Match before beginning their usual processing. Also update fstest.TestFS to check for correct validation in custom Glob implementations. Fixes #28614. Change-Id: Ic1d35a4bb9c3565184ae83dbefc425c5c96318e7 Reviewed-on: https://go-review.googlesource.com/c/go/+/264397 Trust: Russ Cox Reviewed-by: Rob Pike --- src/path/match_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/path/match_test.go') diff --git a/src/path/match_test.go b/src/path/match_test.go index 3e027e1f68..996bd691eb 100644 --- a/src/path/match_test.go +++ b/src/path/match_test.go @@ -67,8 +67,10 @@ var matchTests = []MatchTest{ {"[", "a", false, ErrBadPattern}, {"[^", "a", false, ErrBadPattern}, {"[^bc", "a", false, ErrBadPattern}, - {"a[", "a", false, nil}, + {"a[", "a", false, ErrBadPattern}, {"a[", "ab", false, ErrBadPattern}, + {"a[", "x", false, ErrBadPattern}, + {"a/b[", "x", false, ErrBadPattern}, {"*x", "xxx", true, nil}, } -- cgit v1.2.1