Test both hashWorker cancellation checks on their own (closes #83) #88

Merged
clawbot merged 1 commits from issue-83-hashworker-cancel-tests into next 2026-10-04 16:01:37 +02:00
Collaborator

Both cancellation checks in hashWorker in scan.go now each have a test that fails every time the check is removed. scan.go is unchanged.

  • TestHashWorkerDropsQueuedRuns now passes hashWorker a hash function that records being called before it calls hashSignature. A worker that hashes a queued run after the scan is cancelled is caught whether or not it then sends a result. Before, the test only noticed a result being sent, which a worker without the check did only some of the time.
  • TestHashWorkerAbandonsBlockedSend is new. Its hash function cancels the scan before calling hashSignature. The result channel is unbuffered and never read, and the job channel stays open, so the worker can only return through the cancellation case beside its send. It mirrors TestSendEventAbandonsBlockedSend for the walk.

What a reader might trip over: the scan-level tests (TestScanHashWriteFailureUnwindsPool and others) cannot guard the send case, because stop() drains results and so frees a parked worker anyway. That is why the new test drives hashWorker directly. The comment on the drop test that described both gaps is removed, since neither gap remains.

Model: opus-5-5

Both cancellation checks in `hashWorker` in `scan.go` now each have a test that fails every time the check is removed. `scan.go` is unchanged. - `TestHashWorkerDropsQueuedRuns` now passes `hashWorker` a hash function that records being called before it calls `hashSignature`. A worker that hashes a queued run after the scan is cancelled is caught whether or not it then sends a result. Before, the test only noticed a result being sent, which a worker without the check did only some of the time. - `TestHashWorkerAbandonsBlockedSend` is new. Its hash function cancels the scan before calling `hashSignature`. The result channel is unbuffered and never read, and the job channel stays open, so the worker can only return through the cancellation case beside its send. It mirrors `TestSendEventAbandonsBlockedSend` for the walk. What a reader might trip over: the scan-level tests (`TestScanHashWriteFailureUnwindsPool` and others) cannot guard the send case, because `stop()` drains results and so frees a parked worker anyway. That is why the new test drives `hashWorker` directly. The comment on the drop test that described both gaps is removed, since neither gap remains. Model: opus-5-5
clawbot added the needs-review label 2026-10-04 14:50:35 +02:00
clawbot self-assigned this 2026-10-04 14:50:35 +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 15:30:57 +02:00
clawbot added 1 commit 2026-10-04 15:56:00 +02:00
TestHashWorkerDropsQueuedRuns now passes hashWorker a hash function
that records being called, so a worker that hashes a run after the
scan is cancelled fails the test every time instead of only when it
then chose to send its result.

TestHashWorkerAbandonsBlockedSend cancels the scan from inside the
hash function and leaves the result channel unread, so the worker can
only return through the cancellation case beside its send. The scan
tests could not show this, because stop drains results and frees a
parked worker anyway.

Model: opus-5-5
clawbot force-pushed issue-83-hashworker-cancel-tests from 1a847037ef to 712a82e08b 2026-10-04 15:56:00 +02:00 Compare
Author
Collaborator

Rebased onto current next. One file conflicted:

  • TODO.md: both this PR and #55 added an entry at the top of Completed Steps. Kept both, this PR's entry first, then the #55 entry. No other file changed in the rebase.

Model: opus-5-5

Rebased onto current `next`. One file conflicted: - `TODO.md`: both this PR and https://git.eeqj.de/sneak/sfdupes/issues/55 added an entry at the top of Completed Steps. Kept both, this PR's entry first, then the https://git.eeqj.de/sneak/sfdupes/issues/55 entry. No other file changed in the rebase. Model: opus-5-5
clawbot added needs-review and removed needs-rebase labels 2026-10-04 15:56:05 +02:00
clawbot merged commit 4a16a41bd7 into next 2026-10-04 16:01:37 +02:00
clawbot deleted branch issue-83-hashworker-cancel-tests 2026-10-04 16:01:37 +02:00
Sign in to join this conversation.