Skip to content

Commit a1f32e3

Browse files
committed
don't run FilepathGlob tests on patterns ending in a slash
1 parent 5df0d9d commit a1f32e3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

doublestar_test.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ var matchTests = []MatchTest{
9999
{"[abc]", "b", true, true, nil, false, false, true, true, 3, 3},
100100
{"**", "", true, true, nil, false, false, false, false, 38, 38},
101101
{"a/**", "a", true, true, nil, false, false, false, true, 7, 7},
102-
{"a/**/", "a", true, true, nil, false, false, false, false, 4, 4},
102+
{"a/**/", "a", true, true, nil, false, false, false, true, 4, 4},
103103
{"a/**", "a/", true, true, nil, false, false, false, false, 7, 7},
104104
{"a/**/", "a/", true, true, nil, false, false, false, false, 4, 4},
105105
{"a/**", "a/b", true, true, nil, false, false, false, true, 7, 7},
@@ -509,7 +509,10 @@ func doFilepathGlobTest(t *testing.T, opts ...GlobOption) {
509509
os.Chdir("test")
510510

511511
for idx, tt := range matchTests {
512-
if tt.testOnDisk {
512+
// Patterns ending with a slash are treated semantically different by
513+
// FilepathGlob vs Glob because FilepathGlob runs filepath.Clean, which
514+
// will remove the trailing slash.
515+
if tt.testOnDisk && !strings.HasSuffix(tt.pattern, "/") {
513516
ttmod := tt
514517
ttmod.pattern = filepath.FromSlash(tt.pattern)
515518
ttmod.testPath = filepath.FromSlash(tt.testPath)

0 commit comments

Comments
 (0)