From 8c2cfcfa50d7ce9cffec0cb3dd75bb7236686479 Mon Sep 17 00:00:00 2001 From: Tsiry Sandratraina Date: Sat, 15 Aug 2026 20:21:04 +0300 Subject: [PATCH] treat EIO as end-of-output in the TUI pty test read_to_string on the pty master panics on Linux: once the child's slave side closes, Linux reports EIO where macOS reports EOF. Drain with the same Ok(0)-or-Err loop the app's reader thread already uses. --- kbuildx/src/tui.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/kbuildx/src/tui.rs b/kbuildx/src/tui.rs index 1499faf..6bf1e22 100644 --- a/kbuildx/src/tui.rs +++ b/kbuildx/src/tui.rs @@ -1202,8 +1202,17 @@ mod tests { .stderr(stderr) .status() .unwrap(); + // Drain the master like the app's reader thread does: once the child's + // slave side closes, Linux reports EIO where macOS reports EOF — both + // just mean the output is finished. let mut captured = String::new(); - output.read_to_string(&mut captured).unwrap(); + let mut buffer = [0_u8; 4096]; + loop { + match output.read(&mut buffer) { + Ok(0) | Err(_) => break, + Ok(length) => captured.push_str(&String::from_utf8_lossy(&buffer[..length])), + } + } assert!(status.success(), "child failed; captured: {captured:?}"); assert!(captured.contains("stdout"), "captured: {captured:?}"); -- 2.51.2