Scanner status tests no longer depend on a 100 ms timer (closes #124) #132

Merged
clawbot merged 1 commits from issue-124-scanner-test-timers into next 2026-10-04 09:48:51 +02:00
Collaborator

Closes #124. Tests only; no production code changes.

What changed:

  • TestSendEnumerateStatusNonBlocking and TestSendScanStatusNonBlocking (mfer/scanner_test.go) used to run the send in a goroutine and fail if it took more than 100 ms. They now call the send directly on a channel that nobody receives from. A blocking send would hang the test until the 30 s test timeout, which fails the run.
  • TestGPGTimeoutWhenChildHoldsOutput (mfer/gpg_test.go) is now TestGPGCancelWhenChildHoldsOutput. Its 100 ms deadline could fire before the fake gpg had written the process ID of its sleep child. When that happened, the cleanup failed to read the ID. The fake gpg now writes the ID to a named pipe, and the test cancels the context only after reading it. The test now cancels instead of waiting out a deadline, so it expects context.Canceled; TestGPGTimeoutKillsGPG still covers the "gpg timed out" error.
  • After cancelling, the test waits up to 10 s for the call (replacing the old 3 s check): far above the one-second wait, well under the 30 s test timeout, so a call that waits for sleep fails this test with its own message and the cleanup still kills sleep.

Disclosures:

  • Judgement call: TestGPGTimeoutKillsGPG keeps its 100 ms deadline, because its result is the same however slow the host is.
  • Deviation: syscall.Mkfifo stops the mfer package tests from compiling on Windows. The fake-gpg tests already need /bin/sh, and the repo builds nothing for Windows.
  • testing/synctest was not an option, because go.mod declares Go 1.23.

Model: opus-5-5

Closes https://git.eeqj.de/sneak/mfer/issues/124. Tests only; no production code changes. What changed: - `TestSendEnumerateStatusNonBlocking` and `TestSendScanStatusNonBlocking` (`mfer/scanner_test.go`) used to run the send in a goroutine and fail if it took more than 100 ms. They now call the send directly on a channel that nobody receives from. A blocking send would hang the test until the 30 s test timeout, which fails the run. - `TestGPGTimeoutWhenChildHoldsOutput` (`mfer/gpg_test.go`) is now `TestGPGCancelWhenChildHoldsOutput`. Its 100 ms deadline could fire before the fake gpg had written the process ID of its `sleep` child. When that happened, the cleanup failed to read the ID. The fake gpg now writes the ID to a named pipe, and the test cancels the context only after reading it. The test now cancels instead of waiting out a deadline, so it expects `context.Canceled`; `TestGPGTimeoutKillsGPG` still covers the "gpg timed out" error. - After cancelling, the test waits up to 10 s for the call (replacing the old 3 s check): far above the one-second wait, well under the 30 s test timeout, so a call that waits for `sleep` fails this test with its own message and the cleanup still kills `sleep`. Disclosures: - Judgement call: `TestGPGTimeoutKillsGPG` keeps its 100 ms deadline, because its result is the same however slow the host is. - Deviation: `syscall.Mkfifo` stops the `mfer` package tests from compiling on Windows. The fake-gpg tests already need `/bin/sh`, and the repo builds nothing for Windows. - `testing/synctest` was not an option, because `go.mod` declares Go 1.23. Model: opus-5-5
clawbot added the needs-review label 2026-10-04 08:12:26 +02:00
clawbot self-assigned this 2026-10-04 08:12:26 +02:00
Author
Collaborator

Review: needs rework.

  • mfer/gpg_test.go, TestGPGCancelWhenChildHoldsOutput: if the call does wait for the child holding gpg's output (the failure this test exists to catch), the test never returns. The 30 s test timeout then aborts the whole mfer test binary, so the cleanup never runs and the sleep 60 started by the fake gpg keeps running after the test run ends (one per pass; script/test makes a second pass). The abort also replaces the old test's plain failure message with a timeout dump of the whole package. Acceptable: sleep is killed in every outcome, failing ones included, and a call that waits for the child fails this test with a message saying so. For example, after registering the kill, wait for the call's result with a limit far above the one-second wait and well under the 30 s timeout, and give that limit and its reason one line in the PR body.

Judgement call: the syscall.Mkfifo deviation for Windows is acceptable, since the repo builds nothing for Windows.

Model: opus-5-5

Review: needs rework. - `mfer/gpg_test.go`, `TestGPGCancelWhenChildHoldsOutput`: if the call does wait for the child holding gpg's output (the failure this test exists to catch), the test never returns. The 30 s test timeout then aborts the whole `mfer` test binary, so the cleanup never runs and the `sleep 60` started by the fake gpg keeps running after the test run ends (one per pass; `script/test` makes a second pass). The abort also replaces the old test's plain failure message with a timeout dump of the whole package. Acceptable: `sleep` is killed in every outcome, failing ones included, and a call that waits for the child fails this test with a message saying so. For example, after registering the kill, wait for the call's result with a limit far above the one-second wait and well under the 30 s timeout, and give that limit and its reason one line in the PR body. Judgement call: the `syscall.Mkfifo` deviation for Windows is acceptable, since the repo builds nothing for Windows. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-04 08:36:17 +02:00
clawbot added 1 commit 2026-10-04 09:14:07 +02:00
The two status-send tests now call the send directly on a channel nobody
receives from, so a blocking send hangs the test into its timeout instead
of racing a 100 ms timer that a loaded host can miss.

The gpg test for a child holding gpg's output had the same problem: its
100 ms deadline could fire before the fake gpg wrote the PID of sleep,
and the cleanup then failed. The fake gpg now writes that PID to a named
pipe, and the test cancels only after reading it. It then waits up to
10 s for the call, so a call that waits for sleep fails the test and the
cleanup still kills sleep.

Model: opus-5-5
clawbot force-pushed issue-124-scanner-test-timers from 3f1524020d to a192f3928b 2026-10-04 09:14:07 +02:00 Compare
clawbot added needs-review and removed needs-rework labels 2026-10-04 09:14:11 +02:00
Author
Collaborator

Review finding: after cancelling, the test now waits at most 10 s for the call, then fails with its own message, and the cleanup kills sleep either way.

Model: opus-5-5

Review finding: after cancelling, the test now waits at most 10 s for the call, then fails with its own message, and the cleanup kills `sleep` either way. Model: opus-5-5
Author
Collaborator

Review passed.

Gated on next at 45eac1f.

  • Judgement call: the syscall.Mkfifo deviation for Windows is acceptable, since the repo builds nothing for Windows.
  • Judgement call, not a finding: if a change ever stops the fake gpg from starting, TestGPGCancelWhenChildHoldsOutput waits on the named pipe until the 30 s test timeout; the other gpg tests fail with their own messages first, and no sleep is started.

Model: opus-5-5

Review passed. Gated on `next` at `45eac1f`. - Judgement call: the `syscall.Mkfifo` deviation for Windows is acceptable, since the repo builds nothing for Windows. - Judgement call, not a finding: if a change ever stops the fake gpg from starting, `TestGPGCancelWhenChildHoldsOutput` waits on the named pipe until the 30 s test timeout; the other gpg tests fail with their own messages first, and no `sleep` is started. Model: opus-5-5
clawbot merged commit 64eb5cbd40 into next 2026-10-04 09:48:51 +02:00
clawbot deleted branch issue-124-scanner-test-timers 2026-10-04 09:48:52 +02:00
Sign in to join this conversation.