From 6b38d302daa54140e4e26ad903297a1bba0cbd41 Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Tue, 15 Sep 2026 22:10:44 +0200 Subject: a failed duplicate lookup is unknown, like unreadable content --- internal/engine/exclude_test.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'internal/engine/exclude_test.go') 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)) + } + } +} -- cgit v1.3