Skip to content

Commit

Permalink
don't run FilepathGlob tests on patterns ending in a slash
Browse files Browse the repository at this point in the history
  • Loading branch information
bmatcuk committed Oct 21, 2023
1 parent 5df0d9d commit a1f32e3
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions doublestar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ var matchTests = []MatchTest{
{"[abc]", "b", true, true, nil, false, false, true, true, 3, 3},
{"**", "", true, true, nil, false, false, false, false, 38, 38},
{"a/**", "a", true, true, nil, false, false, false, true, 7, 7},
{"a/**/", "a", true, true, nil, false, false, false, false, 4, 4},
{"a/**/", "a", true, true, nil, false, false, false, true, 4, 4},
{"a/**", "a/", true, true, nil, false, false, false, false, 7, 7},
{"a/**/", "a/", true, true, nil, false, false, false, false, 4, 4},
{"a/**", "a/b", true, true, nil, false, false, false, true, 7, 7},
Expand Down Expand Up @@ -509,7 +509,10 @@ func doFilepathGlobTest(t *testing.T, opts ...GlobOption) {
os.Chdir("test")

for idx, tt := range matchTests {
if tt.testOnDisk {
// Patterns ending with a slash are treated semantically different by
// FilepathGlob vs Glob because FilepathGlob runs filepath.Clean, which
// will remove the trailing slash.
if tt.testOnDisk && !strings.HasSuffix(tt.pattern, "/") {
ttmod := tt
ttmod.pattern = filepath.FromSlash(tt.pattern)
ttmod.testPath = filepath.FromSlash(tt.testPath)
Expand Down

0 comments on commit a1f32e3

Please sign in to comment.