The -x filesystem-boundary rejection branch is never tested #17

Open
opened 2026-08-09 03:46:20 +02:00 by clawbot · 0 comments
Collaborator

TestWalkOneFilesystemSameFS (scan_test.go:280-298) only proves that -x skips nothing when every path is on one filesystem. That is the negative case. The branch that actually implements the flag — scan.go:745-747, if dev, ok := deviceOfInfo(info); ok && dev != parent.rootDev — has never been executed by a test, and neither has the !parent.rootDevOK bypass at scan.go:731-733.

-x is a documented flag (README §scan mode, GNU du/rsync convention) whose whole purpose is to not descend across a mount point. Getting it wrong on a ZFS server with many datasets means either scanning far more than asked or silently missing trees. Tests requiring a real second filesystem are not portable, but the branch is directly reachable through subdirJob.

Definition of done

  1. A unit test calls subdirJob directly with a fabricated parent dirJob{rootDev: someOtherDevice, rootDevOK: true} and oneFS = true, and asserts the subdirectory is rejected.
  2. A companion case with rootDevOK: false asserts the boundary check is bypassed and the subdirectory is accepted.
  3. A case where e.Info() returns an error asserts the warning is emitted and the path skipped.
  4. A matching case asserts the default (no -x) crosses the boundary.
  5. make check green.
`TestWalkOneFilesystemSameFS` (`scan_test.go:280-298`) only proves that `-x` skips nothing when every path is on one filesystem. That is the negative case. The branch that actually implements the flag — `scan.go:745-747`, `if dev, ok := deviceOfInfo(info); ok && dev != parent.rootDev` — has never been executed by a test, and neither has the `!parent.rootDevOK` bypass at `scan.go:731-733`. `-x` is a documented flag (README §scan mode, GNU `du`/`rsync` convention) whose whole purpose is to not descend across a mount point. Getting it wrong on a ZFS server with many datasets means either scanning far more than asked or silently missing trees. Tests requiring a real second filesystem are not portable, but the branch is directly reachable through `subdirJob`. ## Definition of done 1. A unit test calls `subdirJob` directly with a fabricated parent `dirJob{rootDev: someOtherDevice, rootDevOK: true}` and `oneFS = true`, and asserts the subdirectory is rejected. 2. A companion case with `rootDevOK: false` asserts the boundary check is bypassed and the subdirectory is accepted. 3. A case where `e.Info()` returns an error asserts the warning is emitted and the path skipped. 4. A matching case asserts the default (no `-x`) crosses the boundary. 5. `make check` green.
clawbot added this to the 1.0.0 milestone 2026-08-09 03:46:20 +02:00
Sign in to join this conversation.