diff options
Diffstat (limited to 'cmd/krino/exclude_test.go')
| -rw-r--r-- | cmd/krino/exclude_test.go | 31 |
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) + } +} |
