@@ -51,6 +51,21 @@ func TestGlob(t *testing.T) { // nolint:funlen
5151 require .Equal (t , fmt .Sprintf ("&{fs:%s matchDirectoriesDirectly:false prefix:%s pattern:%s}" , prefix , prefix , pattern ), w .String ())
5252 })
5353
54+ t .Run ("real with rootfs direct file" , func (t * testing.T ) {
55+ t .Parallel ()
56+
57+ wd , err := os .Getwd ()
58+ require .NoError (t , err )
59+
60+ pattern := toNixPath (filepath .Join (wd , "prefix.go" ))
61+
62+ matches , err := Glob (pattern , MaybeRootFS )
63+ require .NoError (t , err )
64+ require .Equal (t , []string {
65+ toNixPath (filepath .Join (wd , "prefix.go" )),
66+ }, matches )
67+ })
68+
5469 t .Run ("real with rootfs on relative path to parent" , func (t * testing.T ) {
5570 t .Parallel ()
5671
@@ -258,15 +273,15 @@ func TestGlob(t *testing.T) { // nolint:funlen
258273 "./a/nope.txt" ,
259274 "./a/b/dc" ,
260275 }, nil )))
261- require .EqualError (t , err , "matching \" a/b/d\" : file does not exist" )
276+ require .EqualError (t , err , "matching \" ./ a/b/d\" : file does not exist" )
262277 require .True (t , errors .Is (err , os .ErrNotExist ))
263278 require .Empty (t , matches )
264279 })
265280
266281 t .Run ("escaped direct no match" , func (t * testing.T ) {
267282 t .Parallel ()
268283 matches , err := Glob ("a/\\ {b\\ }" , WithFs (testFs (t , nil , nil )))
269- require .EqualError (t , err , "matching \" a/{b}\" : file does not exist" )
284+ require .EqualError (t , err , "matching \" ./ a/{b}\" : file does not exist" )
270285 require .True (t , errors .Is (err , os .ErrNotExist ))
271286 require .Empty (t , matches )
272287 })
@@ -277,7 +292,7 @@ func TestGlob(t *testing.T) { // nolint:funlen
277292 "./a/nope.txt" ,
278293 "./a/b/dc" ,
279294 }, nil )))
280- require .EqualError (t , err , "matching \" a/b/c{a\" : file does not exist" )
295+ require .EqualError (t , err , "matching \" ./ a/b/c{a\" : file does not exist" )
281296 require .Empty (t , matches )
282297 })
283298
0 commit comments