Skip to content

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

Open
pietern wants to merge 1 commit into
mainfrom
fix-render-test-flake
Open

cmdio: rebuild TestRender table per call to fix -count=N flake#5250
pietern wants to merge 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
},
{
name: "Workspace Iterator with no header and template",
v: makeIterator(2),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: why not keep test case data-oriented, so store v: 2 and call makeIterator(v) inside the test func.

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.

2 participants