From 1f1a303c617057f149b4f0d748ee0a195484642c Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Mon, 14 Sep 2026 23:51:33 +0200 Subject: output: wrap by terminal columns, names cannot fake step lines, -v lists unscanned destinations --- cmd/krino/exclude_test.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'cmd/krino/exclude_test.go') 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) + } +} -- cgit v1.3