@@ -35,7 +35,7 @@ var matchTests = []MatchTest{
35
35
{"/*" , "/debug/" , false , false , nil , false , false , true , false , 0 , 0 },
36
36
{"/*" , "//" , false , false , nil , false , false , true , false , 0 , 0 },
37
37
{"abc" , "abc" , true , true , nil , false , false , true , true , 1 , 1 },
38
- {"*" , "abc" , true , true , nil , false , false , true , true , 23 , 18 },
38
+ {"*" , "abc" , true , true , nil , false , false , true , true , 24 , 18 },
39
39
{"*c" , "abc" , true , true , nil , false , false , true , true , 2 , 2 },
40
40
{"*/" , "a/" , true , true , nil , false , false , true , false , 0 , 0 },
41
41
{"a*" , "a" , true , true , nil , false , false , true , true , 9 , 9 },
@@ -63,8 +63,8 @@ var matchTests = []MatchTest{
63
63
{"a[!a]b" , "a☺b" , true , true , nil , false , false , false , true , 1 , 1 },
64
64
{"a???b" , "a☺b" , false , false , nil , false , false , true , true , 0 , 0 },
65
65
{"a[^a][^a][^a]b" , "a☺b" , false , false , nil , false , false , true , true , 0 , 0 },
66
- {"[a-ζ]*" , "α" , true , true , nil , false , false , true , true , 20 , 17 },
67
- {"*[a-ζ]" , "A" , false , false , nil , false , false , true , true , 20 , 17 },
66
+ {"[a-ζ]*" , "α" , true , true , nil , false , false , true , true , 21 , 17 },
67
+ {"*[a-ζ]" , "A" , false , false , nil , false , false , true , true , 21 , 17 },
68
68
{"a?b" , "a/b" , false , false , nil , false , false , true , true , 1 , 1 },
69
69
{"a*b" , "a/b" , false , false , nil , false , false , true , true , 1 , 1 },
70
70
{"[\\ ]a]" , "]" , true , true , nil , false , false , true , ! onWindows , 2 , 2 },
@@ -297,8 +297,8 @@ func TestMatchUnvalidated(t *testing.T) {
297
297
{"[" , "a" , ErrBadPattern , ErrBadPattern }, // Error right up front, needs to fail whether validate or not
298
298
}
299
299
for idx , tt := range unvalidatedTests {
300
- _ , errValidated := matchWithSeparator (tt .pattern , tt .testPath , '/' , true )
301
- _ , errUnvalidated := matchWithSeparator (tt .pattern , tt .testPath , '/' , false )
300
+ _ , errValidated := matchWithSeparator (tt .pattern , tt .testPath , '/' , true , false )
301
+ _ , errUnvalidated := matchWithSeparator (tt .pattern , tt .testPath , '/' , false , false )
302
302
if errValidated != tt .expectedErrValidated {
303
303
t .Errorf ("#%v. Validated error of Match(%#q, %#q) = %v want %v" , idx , tt .pattern , tt .testPath , errValidated , tt .expectedErrValidated )
304
304
}
@@ -393,7 +393,7 @@ func testPathMatchFakeWith(t *testing.T, idx int, tt MatchTest) {
393
393
394
394
pattern := strings .ReplaceAll (tt .pattern , "/" , "\\ " )
395
395
testPath := strings .ReplaceAll (tt .testPath , "/" , "\\ " )
396
- ok , err := matchWithSeparator (pattern , testPath , '\\' , true )
396
+ ok , err := matchWithSeparator (pattern , testPath , '\\' , true , false )
397
397
if ok != tt .shouldMatch || err != tt .expectedErr {
398
398
t .Errorf ("#%v. PathMatch(%#q, %#q) = %v, %v want %v, %v" , idx , pattern , testPath , ok , err , tt .shouldMatch , tt .expectedErr )
399
399
}
@@ -535,26 +535,36 @@ func testStandardGlob(t *testing.T, idx int, fn string, tt MatchTest, fsys fs.FS
535
535
}
536
536
537
537
func TestFilepathGlob (t * testing.T ) {
538
- doFilepathGlobTest (t )
538
+ doFilepathGlobTest (t , matchTests )
539
539
}
540
540
541
541
func TestFilepathGlobWithFailOnIOErrors (t * testing.T ) {
542
- doFilepathGlobTest (t , WithFailOnIOErrors ())
542
+ doFilepathGlobTest (t , matchTests , WithFailOnIOErrors ())
543
543
}
544
544
545
545
func TestFilepathGlobWithFailOnPatternNotExist (t * testing.T ) {
546
- doFilepathGlobTest (t , WithFailOnPatternNotExist ())
546
+ doFilepathGlobTest (t , matchTests , WithFailOnPatternNotExist ())
547
547
}
548
548
549
549
func TestFilepathGlobWithFilesOnly (t * testing.T ) {
550
- doFilepathGlobTest (t , WithFilesOnly ())
550
+ doFilepathGlobTest (t , matchTests , WithFilesOnly ())
551
551
}
552
552
553
553
func TestFilepathGlobWithNoFollow (t * testing.T ) {
554
- doFilepathGlobTest (t , WithNoFollow ())
554
+ doFilepathGlobTest (t , matchTests , WithNoFollow ())
555
555
}
556
556
557
- func doFilepathGlobTest (t * testing.T , opts ... GlobOption ) {
557
+ func TestFilepathGlobWithCaseInsensitive (t * testing.T ) {
558
+ var insensitiveTest , sensitiveTest MatchTest
559
+ insensitiveTest = MatchTest {"**/test" , "cases" , false , false , nil , false , false , false , ! onWindows , 1 , 1 }
560
+ sensitiveTest = insensitiveTest
561
+ sensitiveTest .numResults = 3
562
+
563
+ doFilepathGlobTest (t , []MatchTest {insensitiveTest })
564
+ doFilepathGlobTest (t , []MatchTest {sensitiveTest }, WithCaseInsensitive ())
565
+ }
566
+
567
+ func doFilepathGlobTest (t * testing.T , tests []MatchTest , opts ... GlobOption ) {
558
568
glob := newGlob (opts ... )
559
569
fsys := os .DirFS ("test" )
560
570
@@ -564,7 +574,7 @@ func doFilepathGlobTest(t *testing.T, opts ...GlobOption) {
564
574
}()
565
575
os .Chdir ("test" )
566
576
567
- for idx , tt := range matchTests {
577
+ for idx , tt := range tests {
568
578
// Patterns ending with a slash are treated semantically different by
569
579
// FilepathGlob vs Glob because FilepathGlob runs filepath.Clean, which
570
580
// will remove the trailing slash.
@@ -822,6 +832,9 @@ func TestMain(m *testing.M) {
822
832
mkdirp ("test" , "axbxcxdxexxx" )
823
833
mkdirp ("test" , "b" )
824
834
mkdirp ("test" , "e" , "[x]" , "[y]" )
835
+ mkdirp ("test" , "cases" , "test_a" )
836
+ mkdirp ("test" , "cases" , "test_b" )
837
+ mkdirp ("test" , "cases" , "test_c" )
825
838
826
839
// create test files
827
840
touch ("test" , "1" )
@@ -853,6 +866,10 @@ func TestMain(m *testing.M) {
853
866
touch ("test" , "e" , "[]" )
854
867
touch ("test" , "e" , "[x]" , "[y]" , "z" )
855
868
869
+ touch ("test" , "cases" , "test_a" , "test" )
870
+ touch ("test" , "cases" , "test_b" , "TEST" )
871
+ touch ("test" , "cases" , "test_c" , "Test" )
872
+
856
873
touch ("test" , "}" )
857
874
858
875
if ! onWindows {
0 commit comments