test: stop tests waiting out real timeouts
Summary
Some app-host unit tests only finish when a production timeout, drain bound, poll interval or retry delay runs out. This change applies the #15329 approach to them. Each timeout is now injectable, the production default does not change, and the tests pass a short value. No assertion changes.
Durations below come from the last main CI shard logs. "Expected" assumes the rest of each test takes the same time as before.
| Test | Before | Wait removed | Expected saving |
|---|---|---|---|
| CloudPrivateRouteSelectionTests: failed dual-stack probe | 15.36 s | CloudHubConnector 15 s connect deadline, now 1 s via a new CloudMachineLinkManager init parameter | about 14 s |
| CloudLoopbackPortForwardTests: refused CONNECT closes the client | 15.06 s | CloudPortForwardRelay 15 s handshake timeout, now 1 s (the seam already existed) | about 14 s |
| LastSurfaceClosePreferenceTests (14 tests) | 29.0 s suite | drainMainQueue 1 s per call, now 0.1 s | about 25 s |
| WorkspaceCloseTabsContextMenuTests (6 tests) | 12.4 s suite | the same | about 10 s |
WorkspaceSSHFishProcessDrainTests: timeoutKillsChildThatIgnoresTermination | 6.02 s | test-local process timeout, now 1 s instead of 5 s | about 4 s |
WorkspaceSSHFishProcessDrainTests: inheritedWriterDoesNotHoldReturnUntilEOF | 2.01 s | test-local 2 s pipe drain bound, now 0.5 s | about 1.5 s |
TerminalUploadCommandTests: realProcessDoesNotHangOnBackgroundedChild | 4.03 s | TerminalCustomUploadRunner 2 s drain bound on each of 2 pipes, now 0.5 s | about 3 s |
| testVMLayoutApplyOpenGivesUpWithTheManualCommand | 4.06 s | 1 s between 5 open attempts, via CMUX_VM_LAYOUT_OPEN_RETRY_DELAY_SECONDS | about 3.8 s |
| testVMWaitPollsStatusUntilReady | 3.74 s | 3 s vm.status poll, via CMUX_VM_WAIT_POLL_SECONDS | about 3.5 s |
| CloudOperationRecorderTests: placement receipts (2 cases) | 4.05 s | CloudTelemetryUploader 2 s batch delay, now 50 ms | about 3.9 s |
| forkCapabilityProbeTerminatesSetsidDescendantHoldingOutputPipe | 3.50 s | AgentForkSupport 3 s probe output timeout, now 1 s | about 2 s |
| forkCapabilityProbeHardKillsSigtermIgnoringSetsidDescendantAfterTimedOutLeaderExits | 3.62 s | the same | about 2 s |
That adds up to roughly 87 s of app-host test time, spread over the 7 shards.
Why drainMainQueue was slow: a @MainActor Swift Testing body already runs inside a main-queue block, so the helper's DispatchQueue.main.async cannot run until the test returns. Every call therefore spun the run loop for its whole 1 s timeout. The helper now takes a timeout (default 1 s, so XCTest callers are unchanged), and these two Swift Testing suites spin for 0.1 s.
Left alone on purpose, because the wait is the behavior under test:
- The 3 s negative window in "Concurrent opens share one route check".
- The
waitUntilBlockedstability windows in the SSH startup tests. - The 2 s discovery policy in SSHStartupManualReconnectTests.
- Tests whose time is spent on work (layout, SFTP, search).
Testing
swiftc -parsepasses on every changed file.- The app compile and the app-host test shards come from this PR's CI.
- After CI, the new per-test durations will be checked against the table above in the shard logs.
Changelog
none
🤖 Generated with Claude Code
Summary by cubic
App-host unit tests no longer wait out production timeouts — each timeout is now injectable with the same production default, tests pass a short value, and no assertions change. The suites save roughly 87 seconds of test time across the shards.
Refactors
drainMainQueuetakes a timeout;@MainActorSwift Testing bodies run inside a main queue block, so each call previously spun the run loop for a full second.- The cloud handshake and private-route tests pass an injectable clock and advance it past the deadline instead of shortening it; the SSH fish kill test waits for a readiness marker so startup does not spend the kill budget.
- The CLI reads
CMUX_VM_WAIT_POLL_SECONDSandCMUX_VM_LAYOUT_OPEN_RETRY_DELAY_SECONDS; non-finite and oversized overrides fall back to production values (the wait poll capped at the remaining deadline), and new tests assert both fallbacks and the resulting poll count. TerminalCustomUploadRunnerdrain bounds,CloudTelemetryUploaderbatch delay, andAgentForkSupportprobe output timeout are injectable; the fork probe tests pass 2s instead of the 3s default.FileExplorerStatetakes an injectedUserDefaults, and sidebar mode availability now routes through it; the minimal-mode visibility test keeps the file explorer hidden so delayed workspace-root discovery cannot invalidate the chrome bodies.
Summary by CodeRabbit
-
Bug Fixes
- VM workspace retries and readiness checks honor valid timing settings while keeping waits within command deadlines.
- Cloud private-route selection uses the configured connector when checking available routes.
- Process output collection and pipe draining use bounded, configurable timeouts, helping commands finish when background processes keep output pipes open.
-
Improvements
- Cloud telemetry batching supports configurable delays.
- Custom sidebar selection and file explorer preferences use the selected settings store for availability and persistence.