From ce7906510f2fff4e88836558e541a72187656588 Mon Sep 17 00:00:00 2001 From: VallierDev <24893073+VallierDev@users.noreply.github.com> Date: Thu, 15 Oct 2026 22:26:35 +0800 Subject: [PATCH] Test: read the assist PTY banner until complete (flaky single read on CI) Co-Authored-By: Claude Opus 5.5 --- src/assist.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/assist.rs b/src/assist.rs index ab2e9dd..3e6685e 100644 --- a/src/assist.rs +++ b/src/assist.rs @@ -477,10 +477,15 @@ mod tests { let ui = LocalUi::Tty(tokio::io::unix::AsyncFd::new(slave).unwrap()); let mut master = std::fs::File::from(pair.master); ui.show("fixture-123", "FIXTURE8", false, Verify::Temporary, Refresh::Session, false).unwrap(); - let mut bytes = [0u8; 1024]; - let n = master.read(&mut bytes).unwrap(); - let text = std::str::from_utf8(&bytes[..n]).unwrap(); - assert!(text.contains("fixture-123") && text.contains("FIXTURE8") && text.contains("false")); + // A PTY may deliver the banner in several chunks: read until complete (bounded). + let mut text = String::new(); + let deadline = std::time::Instant::now() + std::time::Duration::from_secs(3); + let complete = |t: &str| t.contains("fixture-123") && t.contains("FIXTURE8") && t.contains("false") && t.contains("off="); + while !complete(&text) && std::time::Instant::now() < deadline { + let mut bytes = [0u8; 1024]; + match master.read(&mut bytes) { Ok(n) if n > 0 => text.push_str(&String::from_utf8_lossy(&bytes[..n])), _ => break } + } + assert!(complete(&text)); for (input, expected) in [(b"unknown\nallow\n".as_slice(), 0), (b"reset\n".as_slice(), 1), (b"off\n".as_slice(), 2)] { master.write_all(input).unwrap(); let command = tokio::time::timeout(std::time::Duration::from_secs(2), ui.command()).await.unwrap();