From 5a96d8b2132702ba272f5f0782a44ad01dfc6782 Mon Sep 17 00:00:00 2001 From: Ratul Sarna Date: Fri, 6 Feb 2026 14:09:16 +0530 Subject: [PATCH] Stabilize PTY CI timing tests --- Tests/CodexBarTests/TTYCommandRunnerTests.swift | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Tests/CodexBarTests/TTYCommandRunnerTests.swift b/Tests/CodexBarTests/TTYCommandRunnerTests.swift index 7b0553ada..4c0257067 100644 --- a/Tests/CodexBarTests/TTYCommandRunnerTests.swift +++ b/Tests/CodexBarTests/TTYCommandRunnerTests.swift @@ -92,9 +92,9 @@ struct TTYCommandRunnerEnvTests { binary: scriptURL.path, send: "", options: .init( - timeout: 3, + timeout: 6, // Use LF for portability: some PTY/termios setups do not translate CR → NL for shell reads. - sendOnSubstrings: ["Do you trust the files in this folder?": "y\n"], + sendOnSubstrings: ["trust the files in this folder?": "y\n"], stopOnSubstrings: ["accepted", "rejected"], settleAfterStop: 0.1)) @@ -118,15 +118,18 @@ struct TTYCommandRunnerEnvTests { try fm.setAttributes([.posixPermissions: 0o755], ofItemAtPath: scriptURL.path) let runner = TTYCommandRunner() + let timeout: TimeInterval = 12 + let scriptedSleep: TimeInterval = 10 let startedAt = Date() let result = try runner.run( binary: scriptURL.path, send: "", - options: .init(timeout: 6, idleTimeout: 0.2)) + options: .init(timeout: timeout, idleTimeout: 0.2)) let elapsed = Date().timeIntervalSince(startedAt) #expect(result.text.contains("hello")) - #expect(elapsed < 3.0) + // CI runners can delay PTY scheduling/reads; assert we stop well before script completion. + #expect(elapsed < (scriptedSleep - 1.0)) } @Test