test: bound tmux input capture waits and diagnose failed key sends

Merged
TE
2mo ago
+204-22

Summary

The tmux input-mapping tests currently record failed synthetic key sends with nonfatal assertions, then wait for commands those sends never produced. The pipe writer remains open until capture exits, so missing output can leave the test waiting until Xcode's five-minute allowance kills the host. This pattern was observed on #13117 and #13160; it does not establish either PR caused the underlying input failure.

Make failed key sends fatal preconditions. Require a usable window and report hosted-window/live-surface state to help distinguish attachment failures. Extract the command collector into a test helper with a five-second, cancellable deadline and explicit errors for incomplete output. Read events feed an async stream; deadline/cancellation can finish that stream even while the writer remains open. The read source owns a duplicate descriptor and closes it after event delivery stops.

This bounds pipe waits and improves diagnostics. It does not fix or claim to establish the underlying window/readiness cause, does not change the initial runtime-readiness wait, and does not fix the separate CI classifier that can accept timeout/restart runs.

Validation

  • First commit extracts the existing collector without changing its behavior and adds regression coverage. The incomplete-EOF test fails; the silent-pipe probe remains blocked beyond its 25 ms deadline and is terminated by a three-second external watchdog.
  • After the fix, six Swift Testing tests pass against the exact helper/test files in a small temporary Foundation-only SwiftPM harness: silent pipe, partial output, incomplete EOF, command filtering/order, failed send, and cancellation with the writer still open. Deadline tests use the existing virtual clock and assert outcomes rather than elapsed time.
  • Test wiring lint, Xcode project normalization, focused determinism checks, Swift parsing of the edited app-host suite, and git diff --check pass.
  • Full app-host target compilation/execution remains pending in hosted CI. No app runtime code changed, and no live CI runs were cancelled or retried for this investigation.

Related investigation: #13095.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Summary by cubic

Bounds tmux input-mapping test waits so failed key sends and silent pipes fail fast instead of hanging until Xcode kills the test host.

  • Failed synthetic key sends are now fatal preconditions; tests require a usable window and report hosted-window/live-surface state.
  • Extracts command collection into RemoteTmuxInputCommandCapture, a test helper with a 5-second cancellable deadline and explicit timeout/EOF errors.
  • Reads pipe output through an async stream backed by a duplicated descriptor so cancellation can finish while the writer stays open.
  • This doesn't fix or prove the underlying window/readiness cause; runtime-readiness waits and the CI classifier are unchanged.