Compare commits

..
1 Commits
Author SHA1 Message Date
sneak a179fbaa9c Say "skipped" in scan's warnings for skipped paths (closes #170)
check / check (push) Canceled after 0s
A warning for a path the summary counts as skipped now reads
`scan: skipped PATH (REASON)`, naming the path once. This covers
unreadable directories, failed lstats, failed reads and dropped
operands. Each path of a hard-linked file that cannot be read gets its
own line, since each is counted. Lines for paths left out on purpose
(`--exclude`, default excludes, filesystems that are not persistent)
now read `scan: left out PATH (...)`, so a search for `scan: skipped`
finds only the counted paths.

Model: opus-5-5
2026-11-11 10:55:35 +00:00
+12 -4
View File
@@ -752,8 +752,9 @@ func TestWalkPassesOverRemovedPaths(t *testing.T) {
// TestScanWarnsAboutUnreadablePaths checks that a permission error is
// still warned about and counted as skipped, unlike a removed path. The
// walk reaches an unreadable directory, and a file in a directory that
// can be read but not searched. Another such file is an operand.
// walk reaches an unreadable directory. It also reaches a file and a
// subdirectory in a directory that can be read but not searched. Another
// such file is an operand.
//
//nolint:paralleltest // captureStderr replaces the process-wide os.Stderr
func TestScanWarnsAboutUnreadablePaths(t *testing.T) {
@@ -765,6 +766,7 @@ func TestScanWarnsAboutUnreadablePaths(t *testing.T) {
dir := t.TempDir()
tree := filepath.Join(dir, "tree")
walked := writeFile(t, tree, "unsearchable/f", []byte("x"))
subdir := filepath.Join(filepath.Dir(walked), "d")
operand := writeFile(t, dir, "unsearchable/f", []byte("y"))
unreadable := filepath.Join(tree, "unreadable")
@@ -773,6 +775,11 @@ func TestScanWarnsAboutUnreadablePaths(t *testing.T) {
t.Fatal(err)
}
err = os.Mkdir(subdir, 0o750)
if err != nil {
t.Fatal(err)
}
modes := map[string]fs.FileMode{
unreadable: 0,
filepath.Dir(walked): 0o400,
@@ -793,14 +800,15 @@ func TestScanWarnsAboutUnreadablePaths(t *testing.T) {
}
st := syncTree(t, openTestDB(t), tree, operand)
if st != (scanStats{skipped: 3}) {
t.Errorf("stats = %+v, want 3 skipped and nothing else", st)
if st != (scanStats{skipped: 4}) {
t.Errorf("stats = %+v, want 4 skipped and nothing else", st)
}
got := stderr()
for _, warning := range []string{
"scan: skipped " + unreadable + " (permission denied)\n",
"scan: skipped " + walked + " (permission denied)\n",
"scan: skipped " + subdir + " (permission denied)\n",
"scan: skipped " + operand + " (permission denied)\n",
} {
if !strings.Contains(got, warning) {