test(cli): scope retryWithInterval logger per subtest#26023
Merged
Conversation
mtojek
approved these changes
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).
842b1f6 to
dda6a49
Compare
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
Minor test hygiene: create the
slogtestlogger inside eachTestRetryWithIntervalsubtest (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
slogtestin 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:
TestRetryWithIntervalactually passes. It was mislabeledunknownbecause raw stderr output fromcdr.dev/slog'ssyncwriter(the builtinprintlnfiring when asloghumansink'sio.Pipewriter is closed, emitted by a concurrentcoder port-forward -vtest during teardown) interleaved into thego testoutput stream and corrupted the--- PASS: TestRetryWithIntervalline, sotest2json/gotestsumdropped its terminal action. The real, confirmed defect is tracked in coder/slog#225.Verification
go test ./cli -run TestRetryWithInterval -race -count=50passes.Authored by Coder Agents on behalf of @EhabY.