瀏覽代碼

lib/ignore: Additional test case (#5672)

Jakob Borg 6 年之前
父節點
當前提交
2984d40641
共有 1 個文件被更改,包括 25 次插入0 次删除
  1. 25 0
      lib/ignore/ignore_test.go

+ 25 - 0
lib/ignore/ignore_test.go

@@ -1054,3 +1054,28 @@ func TestIssue5009(t *testing.T) {
 		t.Error("skipIgnoredDirs should not be true with includes")
 	}
 }
+
+func TestSpecialChars(t *testing.T) {
+	pats := New(fs.NewFilesystem(fs.FilesystemTypeBasic, "."), WithCache(true))
+
+	stignore := `(?i)/#recycle
+(?i)/#nosync
+(?i)/$Recycle.bin
+(?i)/$RECYCLE.BIN
+(?i)/System Volume Information`
+	if err := pats.Parse(bytes.NewBufferString(stignore), ".stignore"); err != nil {
+		t.Fatal(err)
+	}
+
+	cases := []string{
+		"#nosync",
+		"$RECYCLE.BIN",
+		filepath.FromSlash("$RECYCLE.BIN/S-1-5-18/desktop.ini"),
+	}
+
+	for _, c := range cases {
+		if !pats.Match(c).IsIgnored() {
+			t.Errorf("%q should be ignored", c)
+		}
+	}
+}