cmdio: rebuild TestRender table per call to fix -count=N flake#5250
Open
pietern wants to merge 1 commit into
Open
cmdio: rebuild TestRender table per call to fix -count=N flake#5250pietern wants to merge 1 commit into
pietern wants to merge 1 commit into
Conversation
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
denik
approved these changes
May 15, 2026
| }, | ||
| { | ||
| name: "Workspace Iterator with no header and template", | ||
| v: makeIterator(2), |
Contributor
There was a problem hiding this comment.
nit: why not keep test case data-oriented, so store v: 2 and call makeIterator(v) inside the test func.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
testCaseswas a package-level slice whoseWorkspace_Iteratorrows wrapped a stateful*dummyIterator.Nextconsumes the iterator, so undergo test -count=Nthe second iteration ofTestRendersaw 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=2fails before this change and-count=10passes after.This pull request and its description were written by Isaac.