test: fix flaky TestDeps by using group output#2926
Open
vmaerten wants to merge 1 commit into
Open
Conversation
vmaerten
marked this pull request as ready for review
July 20, 2026 16:29
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.
Summary
TestDepswas intermittently failing in CI.Root cause:
TestDepsruns its dependencies in parallel (viaerrgroupinrunDeps), and they all write to the same buffer. With the defaultinterleavedoutput style nothing is serialized, and the mvdan/shechobuiltin writes the content and the trailing newline as two separateWritecalls. The test'sSyncBufferlocks each individualWritebut not the content+newline pair, so two concurrent commands can interleave at the sub-line level, corrupting the captured output.Fix: capture
TestDepsoutput with thegroupstyle, which buffers each command separately and flushes it atomically. Every line stays intact, ordering remains irrelevant (the test already sorts viaPPSortedLines), and the golden fixture is unchanged. This matches the existing pattern already used elsewhere inexecutor_test.go.No production code changes; the sub-line interleaving is expected behavior of the interleaved output style, for which
output: groupis the documented clean-output answer.Test plan
go test -run '^TestDeps$' -count=500 -race .→ 0 failures (was ~17/300 before)git diffontestdata/deps/is empty (golden unchanged)go test ./...→ no failures