Skip to content

cmdio: rebuild TestRender table per call to fix -count=N flake#5250

Merged
pietern merged 1 commit into
mainfrom
fix-render-test-flake
May 18, 2026
Merged

cmdio: rebuild TestRender table per call to fix -count=N flake#5250
pietern merged 1 commit into
mainfrom
fix-render-test-flake

Conversation

@pietern
Copy link
Copy Markdown
Contributor

@pietern pietern commented May 13, 2026

testCases was a package-level slice whose Workspace_Iterator rows wrapped a stateful *dummyIterator. Next consumes the iterator, so under go test -count=N the second iteration of TestRender saw an empty iterator and asserted "id name\n" instead of "id name\n123 abc\n456 def\n".

Wrap the table in a makeTestCases() helper that returns a fresh slice (and fresh iterators) on each call. Verified: -count=2 fails before this change and -count=10 passes after.

This pull request and its description were written by Isaac.

testCases was a package-level slice whose Workspace_Iterator rows wrapped a stateful *dummyIterator. Next consumes the iterator, so under `go test -count=N` the second iteration of TestRender saw an empty iterator and asserted "id  name\n" instead of "id  name\n123  abc\n456  def\n".

Wrap the table in a makeTestCases() helper that returns a fresh slice (and fresh iterators) on each call. Verified: -count=2 fails before this change and -count=10 passes after.

Co-authored-by: Isaac
@pietern pietern temporarily deployed to test-trigger-is May 13, 2026 13:41 — with GitHub Actions Inactive
@pietern pietern temporarily deployed to test-trigger-is May 13, 2026 13:41 — with GitHub Actions Inactive
Comment thread libs/cmdio/render_test.go
@pietern pietern added this pull request to the merge queue May 18, 2026
Merged via the queue into main with commit 50ce8c2 May 18, 2026
29 checks passed
@pietern pietern deleted the fix-render-test-flake branch May 18, 2026 19:42
denik pushed a commit that referenced this pull request May 20, 2026
`testCases` was a package-level slice whose `Workspace_Iterator` rows
wrapped a stateful `*dummyIterator`. `Next` consumes the iterator, so
under `go test -count=N` the second iteration of `TestRender` saw an
empty iterator and asserted `"id name\n"` instead of `"id name\n123
abc\n456 def\n"`.

Wrap the table in a `makeTestCases()` helper that returns a fresh slice
(and fresh iterators) on each call. Verified: `-count=2` fails before
this change and `-count=10` passes after.

This pull request and its description were written by Isaac.
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.

3 participants