diff --git a/Packages/ICCeryCore/Sources/ICCeryCore/Argyll/ArgyllRunner.swift b/Packages/ICCeryCore/Sources/ICCeryCore/Argyll/ArgyllRunner.swift index c2eb510..fbbfb9e 100644 --- a/Packages/ICCeryCore/Sources/ICCeryCore/Argyll/ArgyllRunner.swift +++ b/Packages/ICCeryCore/Sources/ICCeryCore/Argyll/ArgyllRunner.swift @@ -192,6 +192,18 @@ public struct ArgyllRunner: Sendable { // MARK: - Shared collection + /// DEBUG-only fast path: under `ICCERY_UI_TESTING=1` polling/wait + /// intervals shrink ~10x — same env convention as `AppPaths.testRoot`. + /// Release builds compile the branch out entirely; no static state. + private static func testAwareDelay(_ nanos: UInt64) -> UInt64 { + #if DEBUG + if ProcessInfo.processInfo.environment["ICCERY_UI_TESTING"] == "1" { + return nanos / 10 + } + #endif + return nanos + } + /// Cancels any previous child with the same id and waits for it to /// finalize, so `runStreaming` / `runCaptured` never sees a /// `duplicateID` from a leftover process (#50, #52). @@ -200,7 +212,7 @@ public struct ArgyllRunner: Sendable { await processManager.kill(id: id) var attempts = 0 while await processManager.isRunning(id), attempts < 30 { - try? await Task.sleep(nanoseconds: 100_000_000) + try? await Task.sleep(nanoseconds: Self.testAwareDelay(100_000_000)) attempts += 1 } } @@ -592,7 +604,7 @@ public struct ArgyllRunner: Sendable { await processManager.setPreKillHook(id: processId) { [processManager] in if isXY { try? await processManager.sendStdin(id: processId, bytes: ChartreadInput.quit.bytes) - try? await Task.sleep(nanoseconds: 500_000_000) + try? await Task.sleep(nanoseconds: Self.testAwareDelay(500_000_000)) } }