Skip to content

test(cli): scope retryWithInterval logger per subtest#26023

Merged
EhabY merged 1 commit into
mainfrom
fix/cli-retrywithinterval-flake
Jun 3, 2026
Merged

test(cli): scope retryWithInterval logger per subtest#26023
EhabY merged 1 commit into
mainfrom
fix/cli-retrywithinterval-flake

Conversation

@EhabY
Copy link
Copy Markdown
Contributor

@EhabY EhabY commented Jun 3, 2026

Summary

Minor test hygiene: create the slogtest logger inside each TestRetryWithInterval subtest (bound to that subtest's own *testing.T) instead of sharing one logger bound to the parent test across parallel subtests.

Why

The shared, parent-bound logger meant warnings emitted from parallel subtest goroutines were attributed to the parent test's output stream rather than the subtest that produced them. Binding each logger to its own subtest gives correct per-subtest log attribution and matches how the rest of the codebase uses slogtest in parallel subtests.

This is not a flake fix

This does not fix coder/internal#1553, and intentionally does not close it. That report was a misattribution: TestRetryWithInterval actually passes. It was mislabeled unknown because raw stderr output from cdr.dev/slog's syncwriter (the builtin println firing when a sloghuman sink's io.Pipe writer is closed, emitted by a concurrent coder port-forward -v test during teardown) interleaved into the go test output stream and corrupted the --- PASS: TestRetryWithInterval line, so test2json/gotestsum dropped its terminal action. The real, confirmed defect is tracked in coder/slog#225.

Verification

  • go test ./cli -run TestRetryWithInterval -race -count=50 passes.
  • Retry warnings are now attributed to the subtest that emitted them rather than the parent.

Authored by Coder Agents on behalf of @EhabY.

@EhabY EhabY closed this Jun 3, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 3, 2026
@EhabY EhabY changed the title fix(cli): scope retryWithInterval test logger per subtest test(cli): scope retryWithInterval logger per subtest Jun 3, 2026
@EhabY EhabY reopened this Jun 3, 2026
TestRetryWithInterval shared a single slogtest logger bound to the parent
test across its parallel subtests, so warnings emitted from the subtest
goroutines were attributed to the parent test's output stream rather than
the subtest that produced them.

Create the logger inside each subtest, bound to that subtest's own
testing.T, so log output is attributed to the correct subtest. This is
test hygiene only; it does not fix coder/internal#1553 (a misattributed
flake whose real cause is tracked in coder/slog#225).
@EhabY EhabY force-pushed the fix/cli-retrywithinterval-flake branch from 842b1f6 to dda6a49 Compare June 3, 2026 13:11
@EhabY EhabY enabled auto-merge (squash) June 3, 2026 13:15
@EhabY EhabY merged commit b9c3eea into main Jun 3, 2026
28 checks passed
@EhabY EhabY deleted the fix/cli-retrywithinterval-flake branch June 3, 2026 13:21
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

flake: TestRetryWithInterval

2 participants