aboutsummaryrefslogtreecommitdiff
path: root/internal/engine/exclude_test.go
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-09-14 23:40:56 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-09-14 23:40:56 +0200
commitbb8b547023b0867f31d7452faceef5769a45b94b (patch)
tree9daf9efd0ac5336747483557976a83ac5725b956 /internal/engine/exclude_test.go
parentc09020c2fb01da24d5befbed78ce3b73b5efbe4c (diff)
downloadkrino-bb8b547023b0867f31d7452faceef5769a45b94b.tar.gz
krino-bb8b547023b0867f31d7452faceef5769a45b94b.zip
explain: shows a duplicate's skipped delete, leaves the cache alone, walks only for duplicate tests
Diffstat (limited to 'internal/engine/exclude_test.go')
-rw-r--r--internal/engine/exclude_test.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/internal/engine/exclude_test.go b/internal/engine/exclude_test.go
index ceb8442..cd1cc4b 100644
--- a/internal/engine/exclude_test.go
+++ b/internal/engine/exclude_test.go
@@ -426,3 +426,25 @@ func TestPartlyReadableDocument(t *testing.T) {
t.Errorf("no warning for the keyword the unreadable part might hold")
}
}
+
+// TestExplainLeavesTheCacheAlone: explain never writes the keyword cache -
+// not even to remove one a directory without content tests no longer uses
+// (triage 28e: explain runs without the directory's lock).
+func TestExplainLeavesTheCacheAlone(t *testing.T) {
+ h, dl := excludeTree(t, map[string]string{"a.txt": "x"})
+ main := writeConfig(t, h, `(include "dl")`, map[string]string{"dl": "(path \"~/dl\")\n(rule \"all\" (move \"Out\"))\n"})
+ e, errs := Load(main)
+ if len(errs) > 0 {
+ t.Fatal(errs)
+ }
+ e.CacheDir = filepath.Join(h, "cache")
+ os.MkdirAll(e.CacheDir, 0o700)
+ cache := filepath.Join(e.CacheDir, "dl.cache")
+ os.WriteFile(cache, []byte("old"), 0o600)
+ if _, err := e.Explain(context.Background(), filepath.Join(dl, "a.txt")); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := os.Stat(cache); err != nil {
+ t.Errorf("explain removed the cache: %v", err)
+ }
+}