Test both walk cancellation checks on their own (closes #81) #85

Merged
clawbot merged 1 commits from issue-81-walk-cancel-tests into next 2026-10-04 14:01:40 +02:00
Collaborator

Removing either walk cancellation check in scan.go used to leave the tests passing (#81). Now each removal fails a test of its own; scan.go is unchanged.

  • TestWalkOneDirStopsWhenCancelled (new) calls walkOneDir on a cancelled scan for a directory holding one subdirectory. Without the check at the top of its entry loop, it returns that subdirectory to descend into.
  • TestWalkWorkersDropQueuedDirs now queues a directory that does not exist. Before, it queued a real one, and walkOneDir's own check stopped at the first entry, so a worker that walked it still emitted nothing. A missing directory fails to read before that check is reached, and the worker sends a warning.

What a reader would trip over: on a cancelled scan each send picks at random between delivering and giving up. So in the worker test one queued job catches the regression only half the time. With 64 queued, the chance of a regression passing is one in 2^64. The walkOneDir test does not depend on chance: returning the subdirectory is not a send.

Judgement call: the worker test rests on that one in 2^64 rather than on certainty. Everything a cancelled worker produces goes through such a send, so certainty would need a test-only context whose cancellation state contradicts itself.

Model: opus-5-5

Removing either walk cancellation check in `scan.go` used to leave the tests passing (https://git.eeqj.de/sneak/sfdupes/issues/81). Now each removal fails a test of its own; `scan.go` is unchanged. - `TestWalkOneDirStopsWhenCancelled` (new) calls `walkOneDir` on a cancelled scan for a directory holding one subdirectory. Without the check at the top of its entry loop, it returns that subdirectory to descend into. - `TestWalkWorkersDropQueuedDirs` now queues a directory that does not exist. Before, it queued a real one, and `walkOneDir`'s own check stopped at the first entry, so a worker that walked it still emitted nothing. A missing directory fails to read before that check is reached, and the worker sends a warning. What a reader would trip over: on a cancelled scan each send picks at random between delivering and giving up. So in the worker test one queued job catches the regression only half the time. With 64 queued, the chance of a regression passing is one in 2^64. The `walkOneDir` test does not depend on chance: returning the subdirectory is not a send. Judgement call: the worker test rests on that one in 2^64 rather than on certainty. Everything a cancelled worker produces goes through such a send, so certainty would need a test-only context whose cancellation state contradicts itself. Model: opus-5-5
clawbot added the needs-review label 2026-10-04 13:16:42 +02:00
clawbot self-assigned this 2026-10-04 13:16:42 +02:00
Author
Collaborator

Review passed; needs a rebase onto next only.

Model: opus-5-5

Review passed; needs a rebase onto next only. Model: opus-5-5
clawbot added needs-rebase and removed needs-review labels 2026-10-04 13:40:59 +02:00
clawbot added 1 commit 2026-10-04 13:50:37 +02:00
walkOneDir's check was hiding the worker's: a worker that walked a
queued directory on a cancelled scan still emitted nothing, because
walkOneDir stopped at its first entry. The worker test now queues a
missing directory, whose read fails and sends a warning before
walkOneDir's check is reached. A new test calls walkOneDir directly on
a cancelled scan and checks it returns no subdirectory to descend into.

Model: opus-5-5
clawbot force-pushed issue-81-walk-cancel-tests from 1a004e8dbb to f536c44042 2026-10-04 13:50:37 +02:00 Compare
Author
Collaborator

Rebased onto next (now on top of the fix for #64).

  • TODO.md: both PRs added an entry at the top of Completed Steps. Kept both, with this PR's #81 entry first and the #64 entry right below it.

cancel_test.go applied without conflict and is unchanged.

Model: opus-5-5

Rebased onto `next` (now on top of the fix for https://git.eeqj.de/sneak/sfdupes/issues/64). - `TODO.md`: both PRs added an entry at the top of Completed Steps. Kept both, with this PR's https://git.eeqj.de/sneak/sfdupes/issues/81 entry first and the https://git.eeqj.de/sneak/sfdupes/issues/64 entry right below it. `cancel_test.go` applied without conflict and is unchanged. Model: opus-5-5
clawbot added needs-review and removed needs-rebase labels 2026-10-04 13:50:43 +02:00
clawbot merged commit 7278c354f0 into next 2026-10-04 14:01:40 +02:00
clawbot deleted branch issue-81-walk-cancel-tests 2026-10-04 14:01:41 +02:00
Sign in to join this conversation.