diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-09-15 00:27:43 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-09-15 00:27:43 +0200 |
| commit | 59015f1f91d640502fdfc34019cf0154b5206bb8 (patch) | |
| tree | 30e3ea85407b5ece06c92f3e971cf0cdfac8656b /internal/engine/exclude_test.go | |
| parent | fc6eda20555ea33f1a8260610056b7079c8e8fd9 (diff) | |
| download | krino-59015f1f91d640502fdfc34019cf0154b5206bb8.tar.gz krino-59015f1f91d640502fdfc34019cf0154b5206bb8.zip | |
explain walks the directory for a duplicate test in an exclude too
Diffstat (limited to 'internal/engine/exclude_test.go')
| -rw-r--r-- | internal/engine/exclude_test.go | 29 |
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) + } + } +} |
