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.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)
+ }
+}