test: route every stdout/stderr write swap through stream-capture

Merged
TH
2d ago
+409-604

What

Makes stream-capture.ts the one place that changes process.stdout.write / process.stderr.write (done-check: git grep -E 'std(out|err)\.write =|vi\.spyOn\(process\.(stdout|stderr), .write.\)' is empty outside the helper and its own leak test).

  • Deletes captureStderr from daemon-http-fixture.ts (its restore assigned a bound copy, leaving an own-property shadow for the rest of the file); callers use beginStdoutCapture/beginStderrCapture.
  • Migrates every hand-rolled swap: generic/screenshot stdout captures, the scripts lanes (check-affected, coverage-changed, coverage-crap incl. the new blocking-suite capture() helper, fuzz/worker.ts via the discard option, help-conformance sample producers).
  • Migrates all seven vi.spyOn(process.stdout|stderr, 'write') sites (per review): a spyOn write fake has the same own-property leak shape as the assignment swaps.
  • Slims the helper surface: beginStdoutCapture/beginStderrCapture are the primitives; scoped with* forms derive from them; withInteractiveStderr(Async) fold into { interactive: true }; withStreamTtyAsync is deleted.

Verification

  • Head 4a723e346, 33 files, +409/−604 (1,013 gross; the 13-line overshoot is retiring the three dead APPROVED_OVER_CEILING rows #3483 left on main, which keeps the blocking Coverage job green).
  • Full unit lane (13,397 tests), scripts node:test lanes, fuzz:parsers, harness, and check:affected --run all green locally.

Closes #3421