Two hashWorker cancellation checks have no test that always fails without them #83

Closed
opened 2026-10-04 12:25:45 +02:00 by clawbot · 1 comment
Collaborator

Two cancellation checks in hashWorker in scan.go have no test that
fails every time without them:

  • hashWorker drops the runs still queued once the scan is cancelled
    (the ctx.Err() check at the top of its loop).
    TestHashWorkerDropsQueuedRuns catches its removal in some runs only:
    a worker that hashes the run anyway then picks at random between
    sending the result and leaving through the second check.
  • hashWorker abandons the send of a result once the scan is cancelled
    (the ctx.Done() case beside that send). Removing it leaves
    make test passing, because stop() drains results and so frees a
    waiting worker anyway. The tests that stop a scan mid-hash,
    TestScanHashWriteFailureUnwindsPool among them, reach it in some
    runs only.

Found while reworking #59.

Definition of done

A test fails every time either check is removed, each on its own.

Model: opus-5-5

Two cancellation checks in `hashWorker` in `scan.go` have no test that fails every time without them: - `hashWorker` drops the runs still queued once the scan is cancelled (the `ctx.Err()` check at the top of its loop). `TestHashWorkerDropsQueuedRuns` catches its removal in some runs only: a worker that hashes the run anyway then picks at random between sending the result and leaving through the second check. - `hashWorker` abandons the send of a result once the scan is cancelled (the `ctx.Done()` case beside that send). Removing it leaves `make test` passing, because `stop()` drains results and so frees a waiting worker anyway. The tests that stop a scan mid-hash, `TestScanHashWriteFailureUnwindsPool` among them, reach it in some runs only. Found while reworking https://git.eeqj.de/sneak/sfdupes/pulls/59. ## Definition of done A test fails every time either check is removed, each on its own. Model: opus-5-5
clawbot added this to the 1.0.0 milestone 2026-10-04 12:25:45 +02:00
clawbot self-assigned this 2026-10-04 12:25:45 +02:00
Author
Collaborator

Implemented in #88: TestHashWorkerDropsQueuedRuns now fails every time the drop check is removed, and the new TestHashWorkerAbandonsBlockedSend fails every time the cancellation case beside the send is removed. scan.go is unchanged.

Model: opus-5-5

Implemented in https://git.eeqj.de/sneak/sfdupes/pulls/88: `TestHashWorkerDropsQueuedRuns` now fails every time the drop check is removed, and the new `TestHashWorkerAbandonsBlockedSend` fails every time the cancellation case beside the send is removed. `scan.go` is unchanged. Model: opus-5-5
Sign in to join this conversation.