aboutsummaryrefslogtreecommitdiff
path: root/internal/engine/exclude_test.go
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-09-15 22:10:44 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-09-15 22:10:44 +0200
commit6b38d302daa54140e4e26ad903297a1bba0cbd41 (patch)
tree2f32472e751de41f8fbbbeed739f0e66a4cb5211 /internal/engine/exclude_test.go
parentbbc9b103acac96b83b150b81f2effe1b65c3f8a2 (diff)
downloadkrino-6b38d302daa54140e4e26ad903297a1bba0cbd41.tar.gz
krino-6b38d302daa54140e4e26ad903297a1bba0cbd41.zip
a failed duplicate lookup is unknown, like unreadable content
Diffstat (limited to 'internal/engine/exclude_test.go')
-rw-r--r--internal/engine/exclude_test.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/internal/engine/exclude_test.go b/internal/engine/exclude_test.go
index 6381a04..7069623 100644
--- a/internal/engine/exclude_test.go
+++ b/internal/engine/exclude_test.go
@@ -547,3 +547,32 @@ func TestNotMatchedAfterAnUnknownRuleDoesNotAct(t *testing.T) {
}
}
}
+
+// TestDuplicateExcludeFailsClosed: an exclude whose duplicate lookup fails
+// holds, marked as such (plan 12).
+func TestDuplicateExcludeFailsClosed(t *testing.T) {
+ if os.Getuid() == 0 {
+ t.Skip("root reads a chmod 000 file")
+ }
+ h, dl := excludeTree(t, map[string]string{"a.txt": "same size", "b.txt": "same size"})
+ os.Chmod(filepath.Join(dl, "a.txt"), 0)
+ t.Cleanup(func() { os.Chmod(filepath.Join(dl, "a.txt"), 0o644) })
+ main := writeConfig(t, h, `(include "dl")`, map[string]string{"dl": `
+(path "~/dl")
+(exclude (duplicate))
+(rule "all" (move "Out"))
+`})
+ e, errs := Load(main)
+ if len(errs) > 0 {
+ t.Fatal(errs)
+ }
+ r, err := e.Match(context.Background(), e.Dirs[0])
+ if err != nil {
+ t.Fatal(err)
+ }
+ for _, fm := range r.Matched {
+ if fm.File.Rel == "a.txt" && fm.Excluded != "(exclude (duplicate)) (duplicate check failed)" {
+ t.Errorf("a.txt: Excluded %q, rules %d; want set aside as duplicate check failed", fm.Excluded, len(fm.Rules))
+ }
+ }
+}