Add a race-detector test target for the concurrent scan paths #18

Closed
opened 2026-08-09 03:46:29 +02:00 by clawbot · 2 comments
Collaborator

TODO.md records "go test runs without -race" as an accepted divergence, justified by the mandated CGO_ENABLED=0 — the race detector needs cgo. The justification is correct for the shipped binary and wrong as a reason to never run the detector at all.

The riskiest code in this repo is precisely the concurrent part: the walk dispatcher (scan.go:619-648), the walk and hash worker pools (scan.go:590-613, scan.go:788-801), and the shared events / subdirs / results channels. Nothing currently checks any of it for races, and issues #5, #6 and #13 all add or change synchronization in exactly that code.

The org-standard make test recipe includes -race; this repo dropped it wholesale rather than isolating it.

Definition of done

  1. A new script/test-race runs CGO_ENABLED=1 go test -race -timeout 60s ./... (or a -run subset covering the walk, scan and hash tests if the full suite is too slow), with a matching make test-race shim.
  2. It is NOT wired into make check, so make check stays pure-Go and fast.
  3. The Dockerfile lint and build stages keep CGO_ENABLED=0; the shipped binary stays pure Go with no new dependency on a C toolchain.
  4. It is clean — any race it finds is fixed as part of this issue or filed separately with a reference here.
  5. TODO.md's accepted-divergence note is rewritten to say the detector runs in a separate cgo-enabled target rather than not at all.
  6. README §Build documents make test-race.
  7. make check green and make test-race clean.
`TODO.md` records "go test runs without `-race`" as an accepted divergence, justified by the mandated `CGO_ENABLED=0` — the race detector needs cgo. The justification is correct for the shipped binary and wrong as a reason to never run the detector at all. The riskiest code in this repo is precisely the concurrent part: the walk dispatcher (`scan.go:619-648`), the walk and hash worker pools (`scan.go:590-613`, `scan.go:788-801`), and the shared `events` / `subdirs` / `results` channels. Nothing currently checks any of it for races, and issues #5, #6 and #13 all add or change synchronization in exactly that code. The org-standard `make test` recipe includes `-race`; this repo dropped it wholesale rather than isolating it. ## Definition of done 1. A new `script/test-race` runs `CGO_ENABLED=1 go test -race -timeout 60s ./...` (or a `-run` subset covering the walk, scan and hash tests if the full suite is too slow), with a matching `make test-race` shim. 2. It is NOT wired into `make check`, so `make check` stays pure-Go and fast. 3. The Dockerfile lint and build stages keep `CGO_ENABLED=0`; the shipped binary stays pure Go with no new dependency on a C toolchain. 4. It is clean — any race it finds is fixed as part of this issue or filed separately with a reference here. 5. `TODO.md`'s accepted-divergence note is rewritten to say the detector runs in a separate cgo-enabled target rather than not at all. 6. README §Build documents `make test-race`. 7. `make check` green and `make test-race` clean.
clawbot added this to the 1.0.0 milestone 2026-08-09 03:46:29 +02:00
Author
Collaborator

Plan (implementer's brief). The race detector needs cgo and a C compiler, which the host may not have and must not need. script/test-race runs go test -race inside a digest-pinned golang image that has a C toolchain (the way script/lint runs the linter in a container), with the repo mounted read-only and the container removed after; make test-race shims it. Not part of make check; the shipped binary and the Dockerfile stay CGO_ENABLED=0. Any race it finds is fixed here if small, otherwise filed as its own issue and linked. README.md documents the target; TODO.md's divergence note is corrected.

Model: opus-5-5

Plan (implementer's brief). The race detector needs cgo and a C compiler, which the host may not have and must not need. `script/test-race` runs `go test -race` inside a digest-pinned golang image that has a C toolchain (the way `script/lint` runs the linter in a container), with the repo mounted read-only and the container removed after; `make test-race` shims it. Not part of `make check`; the shipped binary and the `Dockerfile` stay `CGO_ENABLED=0`. Any race it finds is fixed here if small, otherwise filed as its own issue and linked. `README.md` documents the target; `TODO.md`'s divergence note is corrected. Model: opus-5-5
clawbot self-assigned this 2026-10-04 12:02:37 +02:00
Author
Collaborator

Implemented in #92: make test-race runs the test suite under the race detector in a cgo-enabled container, outside make check. The detector found no races, so nothing was fixed or filed.

Model: opus-5-5

Implemented in https://git.eeqj.de/sneak/sfdupes/pulls/92: `make test-race` runs the test suite under the race detector in a cgo-enabled container, outside `make check`. The detector found no races, so nothing was fixed or filed. Model: opus-5-5
Sign in to join this conversation.