Files
Manas Choksiandchoksi2212 3f74eb273d test(leaf): capture output through context writers, not package globals (#3659)
* test(leaf): capture output through context writers, not package globals

Parallel tests in internal/store/leaf replaced the package-level
out.Stdout global with a per-test bytes.Buffer. Because these tests run
in parallel while other tests (and leaf store methods themselves) call
out.Printf reading the same global, the race detector reports
concurrent read/write pairs such as TestMove vs TestDelete and
TestDiagnoseRecipientsCanonical vs TestCanonicalizeRecipientsAlreadyCanonical.
The shared bytes.Buffer itself is also written concurrently through
out.Printf.

Following the direction suggested in issue #3544, the out package now
resolves writers context-first: WithWriter(ctx, stdout, stderr) attaches
per-call sinks and every Print call resolves them through the context it
already receives. Contexts without writers keep using the package-level
Stdout and Stderr, so existing callers are unchanged.

All leaf tests that mutated the globals now build their context with
captureOutput, which returns per-test capture files wired through the
context. No test touches shared output state anymore, and the -race
-count=10 -shuffle=on acceptance run from the issue passes cleanly.

Closes #3544

Signed-off-by: choksi2212 <choksi2212@users.noreply.github.com>

* fix(out): drop named returns in Writer to satisfy nonamedreturns lint

Signed-off-by: choksi2212 <choksi2212@users.noreply.github.com>

* fix(test): check the capture file close errors to satisfy errcheck

Signed-off-by: choksi2212 <choksi2212@users.noreply.github.com>

---------

Signed-off-by: choksi2212 <choksi2212@users.noreply.github.com>
Co-authored-by: choksi2212 <choksi2212@users.noreply.github.com>
2026-10-11 13:43:22 +02:00
..