https://github.com/syncthing/syncthing/issues/6487
(t *testing.T)
| 884 | |
| 885 | // https://github.com/syncthing/syncthing/issues/6487 |
| 886 | func TestIncludedSubdir(t *testing.T) { |
| 887 | fss := fs.NewFilesystem(fs.FilesystemTypeFake, "") |
| 888 | |
| 889 | name := filepath.Clean("foo/bar/included") |
| 890 | err := fss.MkdirAll(name, 0o777) |
| 891 | if err != nil { |
| 892 | t.Fatal(err) |
| 893 | } |
| 894 | |
| 895 | pats := ignore.New(fss, ignore.WithCache(true)) |
| 896 | |
| 897 | stignore := ` |
| 898 | !/foo/bar |
| 899 | * |
| 900 | ` |
| 901 | if err := pats.Parse(bytes.NewBufferString(stignore), ".stignore"); err != nil { |
| 902 | t.Fatal(err) |
| 903 | } |
| 904 | |
| 905 | fchan := Walk(context.TODO(), Config{ |
| 906 | CurrentFiler: make(fakeCurrentFiler), |
| 907 | Filesystem: fss, |
| 908 | Matcher: pats, |
| 909 | }) |
| 910 | |
| 911 | found := false |
| 912 | for f := range fchan { |
| 913 | if f.Err != nil { |
| 914 | t.Fatalf("Error while scanning %v: %v", f.Err, f.Path) |
| 915 | } |
| 916 | if f.File.IsIgnored() { |
| 917 | t.Error("File is ignored:", f.File.Name) |
| 918 | } |
| 919 | if f.File.Name == name { |
| 920 | found = true |
| 921 | } |
| 922 | } |
| 923 | |
| 924 | if !found { |
| 925 | t.Errorf("File not present in scan results") |
| 926 | } |
| 927 | } |
| 928 | |
| 929 | // Verify returns nil or an error describing the mismatch between the block |
| 930 | // list and actual reader contents |