aboutsummaryrefslogtreecommitdiff
path: root/internal/engine/exclude_test.go
diff options
context:
space:
mode:
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 5a758bb..9aafd7f 100644
--- a/internal/engine/exclude_test.go
+++ b/internal/engine/exclude_test.go
@@ -483,3 +483,32 @@ func TestPartlyReadableDocumentIsNotCached(t *testing.T) {
}
}
}
+
+// TestExplainAgreesWithMatchOnADuplicateExclude: a (duplicate) test inside
+// an exclude needs the directory's other files, as one inside a rule does,
+// so explain sets aside exactly the files Match does (plan 11 review M3).
+func TestExplainAgreesWithMatchOnADuplicateExclude(t *testing.T) {
+ h, dl := excludeTree(t, map[string]string{"a.txt": "same", "b.txt": "same", "c.txt": "other"})
+ main := writeConfig(t, h, `(include "dl")`, map[string]string{"dl": `
+(path "~/dl")
+(exclude (not (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 append(append([]FileMatch{}, r.Matched...), r.Unmatched...) {
+ x, err := e.Explain(context.Background(), filepath.Join(dl, fm.File.Rel))
+ if err != nil {
+ t.Fatal(err)
+ }
+ if x.Excluded != fm.Excluded {
+ t.Errorf("%s: explain sets it aside as %q, Match as %q", fm.File.Rel, x.Excluded, fm.Excluded)
+ }
+ }
+}