From 990c49a436cb5e7c50c06eb3005dfa4f7d40adfe Mon Sep 17 00:00:00 2001 From: Gronod Date: Sat, 12 Sep 2026 16:55:56 +0100 Subject: [PATCH] test(m9): collapse ArgyllRunner waits under ICCERY_UI_TESTING (#141) Add a DEBUG-gated testAwareDelay helper (same ICCERY_UI_TESTING=1 convention as AppPaths.testRoot) and apply it to the ensureNotRunning 100ms poll and the XY chartread 500ms pre-kill wait. Under UI tests the intervals shrink ~10x; release builds compile the branch out entirely, so production timing is unchanged. No current UI test exercises XY cancel, so the 500ms site is future-proofing at zero risk today. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- .../Sources/ICCeryCore/Argyll/ArgyllRunner.swift | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) 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)) } } -- 2.39.5