From e00ab8a578af596607a2218eddb61002ad21f044 Mon Sep 17 00:00:00 2001 From: Leo Li Date: Thu, 24 Sep 2026 20:52:11 -0400 Subject: [PATCH] test: let the CLI no-socket test shorten the restore startup wait testLaunchCapableCommandsReachTheirDispatchPathWithoutLiveImplicitSocket took 90 s: restore and fork each waited the full 45 s for an app socket that the test deliberately never starts. Co-Authored-By: Claude Opus 5.5 --- CLI/cmux.swift | 14 +++++++++++++- cmuxTests/CMUXCLIErrorOutputRegressionTests.swift | 3 +++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CLI/cmux.swift b/CLI/cmux.swift index a54a2402b672..3c7b658062f9 100644 --- a/CLI/cmux.swift +++ b/CLI/cmux.swift @@ -4197,7 +4197,19 @@ struct CMUXCLI { /// Restored terminals start the app and then race its listener bind. Keep /// the implicit restore connection alive long enough for that lifecycle, /// while explicit socket paths retain their immediate failure semantics. - private static let restoreSocketStartupTimeoutSeconds: TimeInterval = 45 + private static let defaultRestoreSocketStartupTimeoutSeconds: TimeInterval = 45 + /// Tests that exercise the "still opening" failure set + /// `CMUX_RESTORE_SOCKET_STARTUP_TIMEOUT_SECONDS` so they do not wait out + /// the full startup budget. It can only shorten the default. + private static var restoreSocketStartupTimeoutSeconds: TimeInterval { + let key = "CMUX_RESTORE_SOCKET_STARTUP_TIMEOUT_SECONDS" + guard let raw = ProcessInfo.processInfo.environment[key]?.trimmingCharacters(in: .whitespacesAndNewlines), + let value = TimeInterval(raw), + value.isFinite else { + return defaultRestoreSocketStartupTimeoutSeconds + } + return min(max(value, 0.05), defaultRestoreSocketStartupTimeoutSeconds) + } // Stable per-user slot for the pinned Cloud VM. This value is intentionally reused as // both the backend create idempotency key and the local daemon slot so every open, // reconnect, session restore, and mobile attach targets the same provider VM once diff --git a/cmuxTests/CMUXCLIErrorOutputRegressionTests.swift b/cmuxTests/CMUXCLIErrorOutputRegressionTests.swift index ffa1c86055c5..ac7ed9577246 100644 --- a/cmuxTests/CMUXCLIErrorOutputRegressionTests.swift +++ b/cmuxTests/CMUXCLIErrorOutputRegressionTests.swift @@ -2351,6 +2351,9 @@ import Testing } environment["CMUX_CLI_SENTRY_DISABLED"] = "1" environment["CFFIXED_USER_HOME"] = home.path + // restore and fork wait for the app's socket before reporting that + // cmux is still opening; the default 45 s wait made this test 90 s. + environment["CMUX_RESTORE_SOCKET_STARTUP_TIMEOUT_SECONDS"] = "1" let cases: [(arguments: [String], expectedError: String)] = [ (["settings", "invalid-target"], "Unknown settings subcommand 'invalid-target'"),