aboutsummaryrefslogtreecommitdiff
path: root/cmd/krino/exclude_test.go
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-09-14 23:51:33 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-09-14 23:51:33 +0200
commit1f1a303c617057f149b4f0d748ee0a195484642c (patch)
tree1e42ca0f53af3a5e39e31f0bc3475979a3a589dd /cmd/krino/exclude_test.go
parent1bb5097986558ee7dd3aeaf8e7defefdf91ae4b6 (diff)
downloadkrino-1f1a303c617057f149b4f0d748ee0a195484642c.tar.gz
krino-1f1a303c617057f149b4f0d748ee0a195484642c.zip
output: wrap by terminal columns, names cannot fake step lines, -v lists unscanned destinations
Diffstat (limited to 'cmd/krino/exclude_test.go')
-rw-r--r--cmd/krino/exclude_test.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/cmd/krino/exclude_test.go b/cmd/krino/exclude_test.go
index 2e9ff2a..e9d4433 100644
--- a/cmd/krino/exclude_test.go
+++ b/cmd/krino/exclude_test.go
@@ -134,3 +134,34 @@ func TestSkipSummaryCountsTooBig(t *testing.T) {
t.Errorf("line = %q, want 1 too big", got)
}
}
+
+// TestVerboseListsDirectoriesLeftOutOfTheWalk: a rule's destination inside
+// the directory is not walked, so its files never show in any count; -v
+// says so, and only for directories that exist (triage 4).
+func TestVerboseListsDirectoriesLeftOutOfTheWalk(t *testing.T) {
+ h := home(t)
+ dl := filepath.Join(h, "dl")
+ old := time.Date(2026, 1, 1, 0, 0, 0, 0, time.UTC)
+ p := filepath.Join(dl, "Work", "Acme", "old-acme.pdf")
+ os.MkdirAll(filepath.Dir(p), 0o755)
+ os.WriteFile(p, []byte("x"), 0o644)
+ os.Chtimes(p, old, old)
+ if code, _, errOut := runCLI(t, "init"); code != 0 {
+ t.Fatal(errOut)
+ }
+ if code, _, errOut := runCLI(t, "new", "dl", dl); code != 0 {
+ t.Fatal(errOut)
+ }
+ rules := "(path \"~/dl\")\n(recursive yes)\n(rule \"acme\" (when (name \"acme\")) (move \"Work/Acme\"))\n(rule \"later\" (move \"Later/{mtime:%Y}\"))\n"
+ os.WriteFile(filepath.Join(h, ".config", "krino", "dirs", "dl.conf"), []byte(rules), 0o644)
+ _, out, errOut := runCLI(t, "-n", "-v")
+ if !strings.Contains(out, "\nnot scanned (a rule's destination)\n Work/Acme/\n") {
+ t.Errorf("-v lacks the destination left out of the walk:\n%s\n%s", out, errOut)
+ }
+ if strings.Contains(out, "Later/") {
+ t.Errorf("a destination that does not exist is listed:\n%s", out)
+ }
+ if _, out, _ = runCLI(t, "-n"); strings.Contains(out, "not scanned") {
+ t.Errorf("listed without -v:\n%s", out)
+ }
+}