Skip to content

test(cli): wait for FinishIndex instead of racing it - #231

Merged
dvcdsys merged 1 commit into
developfrom
fix/watcher-test-race
Aug 10, 2026
Merged

test(cli): wait for FinishIndex instead of racing it#231
dvcdsys merged 1 commit into
developfrom
fix/watcher-test-race

Conversation

@dvcdsys

@dvcdsys dvcdsys commented Aug 10, 2026

Copy link
Copy Markdown
Owner

Three tests in internal/watcher wait for BeginIndex and then assert on
FinishIndex. Those are two sequential HTTP calls from the indexer goroutine,
so the window between them is small but real, and on a loaded CI runner the
assertion lands inside it. It surfaces as expected FinishIndex to be called
on a test that took 0.02s — not a timeout, an assertion made too early.

TestDebounce_MultipleEventsOnce had a different problem with the same shape:
a deadline of ten times the 80 ms debounce interval, which reads generous and
is 800 ms. A cold macOS runner loses it, and because the flush goroutine then
ran after t.TempDir() cleanup, the failure printed as cannot read a.go: no such file or directory rather than as the assertion that actually failed.

Both showed up on macos-latest during #229 and #230 and passed on rerun.
Neither is caused by those changes — but the extra parallel load of a new test
package is enough to make latent races fire, and they will keep firing.

Test-only; no production code touched.

🤖 Generated with Claude Code

Three tests in internal/watcher wait for BeginIndex and then assert on
FinishIndex. Those are two sequential HTTP calls from the indexer goroutine,
so the window between them is small but real, and on a loaded CI runner the
assertion lands inside it. It surfaces as "expected FinishIndex to be called"
on a test that took 0.02s — not a timeout, an assertion made too early.

Adds waitForFinish for the tests that actually care about completion, and
keeps waitForCalls for those that only assert BeginIndex.

TestDebounce_MultipleEventsOnce had a different problem with the same shape:
its deadline was ten times the 80ms debounce interval, which reads generous
and is 800ms. A cold macOS runner loses that, and because the flush goroutine
then ran after t.TempDir() cleanup, the failure printed as "cannot read a.go:
no such file or directory" rather than as the assertion that failed. The
property under test is that five events collapse into one flush, not how
quickly, so it now waits on patience rather than on the interval.

The shared deadline goes to 15s. It exits the instant the condition holds, so
a long limit costs nothing when things work.

Both failures appeared on macos-latest during the mac-runtime PRs (#229, #230)
and passed on rerun; neither is caused by those changes, but the extra parallel
load of a new test package is enough to make the races fire.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@dvcdsys
dvcdsys merged commit 4a679ae into develop Aug 10, 2026
2 checks passed
@dvcdsys
dvcdsys deleted the fix/watcher-test-race branch August 10, 2026 21:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant