MCPcopy
hub / github.com/syncthing/syncthing / TestSkipIgnoredDirs

Function TestSkipIgnoredDirs

lib/scanner/walk_test.go:846–883  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

844}
845
846func TestSkipIgnoredDirs(t *testing.T) {
847 fss := fs.NewFilesystem(fs.FilesystemTypeFake, "")
848
849 name := "foo/ignored"
850 err := fss.MkdirAll(name, 0o777)
851 if err != nil {
852 t.Fatal(err)
853 }
854
855 stat, err := fss.Lstat(name)
856 if err != nil {
857 t.Fatal(err)
858 }
859
860 w := &walker{}
861
862 pats := ignore.New(fss, ignore.WithCache(true))
863
864 stignore := `
865 /foo/ign*
866 !/f*
867 *
868 `
869 if err := pats.Parse(bytes.NewBufferString(stignore), ".stignore"); err != nil {
870 t.Fatal(err)
871 }
872 if m := pats.Match("whatever"); !m.CanSkipDir() {
873 t.Error("CanSkipDir should be true", m)
874 }
875
876 w.Matcher = pats
877
878 fn := w.walkAndHashFiles(context.Background(), nil, nil)
879
880 if err := fn(name, stat, nil); err != fs.SkipDir {
881 t.Errorf("Expected %v, got %v", fs.SkipDir, err)
882 }
883}
884
885// https://github.com/syncthing/syncthing/issues/6487
886func TestIncludedSubdir(t *testing.T) {

Callers

nothing calls this directly

Calls 11

MkdirAllMethod · 0.95
LstatMethod · 0.95
walkAndHashFilesMethod · 0.95
NewFilesystemFunction · 0.92
NewFunction · 0.92
WithCacheFunction · 0.92
FatalMethod · 0.80
ParseMethod · 0.80
CanSkipDirMethod · 0.80
MatchMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected