codeburn/mac/Tests
ozymandiashh 714e1b3a70 test(menubar): make ServeConnection cancellation tests deterministic under load
Three ServeConnectionTests failed on roughly half of all macOS Menubar CI
runs and always passed on re-run. Each one raced a real clock or a real
child process against Swift-side work. A cooperative pool starved by
CPU-heavy suites that swift-testing schedules alongside can delay that work
by seconds.

- "cancelling a hung request returns promptly" asserted a 500 ms wall-clock
  budget, and its fixture child exited after `sleep 1`. When the cancellation
  hop was starved past those exits, the connection retried the request on
  replacement children until the death budget answered ServeUnavailable. The
  timeout path never fired, because the test used the real ten-minute budget.
  The child now stays alive, the timeout comes from the manual clock, and the
  test asserts that the caller sees CancellationError before any timeout fires.
- "a request queued during cancelled hydration completes on the same child"
  read the child's event log as soon as the reply resumed the caller, but the
  child appends "second-replied" only after writing that reply. The test now
  waits for the log line. The manual clock also replaces its timeout recorder,
  which really fired after 5 s.
- "external cancellations keep one child and safely discard late replies" let
  the fixture reply 50 ms after reading, so a delayed cancel lost to the reply.
  The child now holds each reply until the test has observed the cancellation.

Polling is bounded by a 30 s hang guard instead of 2 s. When a guarded await
expires, the guard releases the fixture, so a regression fails its assertions
instead of hanging the run. No production code changes.

Closes #1333
2026-09-13 06:52:39 +03:00
..
CodeBurnMenubarTests test(menubar): make ServeConnection cancellation tests deterministic under load 2026-09-13 06:52:39 +03:00