Skip to content

test: fix flaky TestDeps by using group output - #2926

Merged
vmaerten merged 1 commit into
mainfrom
test/fix-flaky-testdeps
Aug 3, 2026
Merged

test: fix flaky TestDeps by using group output#2926
vmaerten merged 1 commit into
mainfrom
test/fix-flaky-testdeps

Conversation

@vmaerten

@vmaerten vmaerten commented Jul 19, 2026

Copy link
Copy Markdown
Member

Summary

TestDeps was intermittently failing in CI.

Root cause: TestDeps runs its dependencies in parallel (via errgroup in runDeps), and they all write to the same buffer. With the default interleaved output style nothing is serialized, and the mvdan/sh echo builtin writes the content and the trailing newline as two separate Write calls. The test's SyncBuffer locks each individual Write but not the content+newline pair, so two concurrent commands can interleave at the sub-line level, corrupting the captured output.

Fix: capture TestDeps output with the group style, which buffers each command separately and flushes it atomically. Every line stays intact, ordering remains irrelevant (the test already sorts via PPSortedLines), and the golden fixture is unchanged. This matches the existing pattern already used elsewhere in executor_test.go.

No production code changes; the sub-line interleaving is expected behavior of the interleaved output style, for which output: group is the documented clean-output answer.

Test plan

  • go test -run '^TestDeps$' -count=500 -race . → 0 failures (was ~17/300 before)
  • git diff on testdata/deps/ is empty (golden unchanged)
  • go test ./... → no failures

@vmaerten
vmaerten marked this pull request as ready for review July 20, 2026 16:29
@vmaerten
vmaerten force-pushed the test/fix-flaky-testdeps branch from 14f7467 to 1d9f4c4 Compare August 3, 2026 20:41
@vmaerten
vmaerten enabled auto-merge (squash) August 3, 2026 20:43
@vmaerten
vmaerten merged commit d04748f into main Aug 3, 2026
20 checks passed
@vmaerten
vmaerten deleted the test/fix-flaky-testdeps branch August 3, 2026 20:44
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