From 8b8837bcf16f03b2b6212091692e3655cb3679d5 Mon Sep 17 00:00:00 2001 From: FredApps Date: Sat, 14 Nov 2026 16:28:03 +0100 Subject: [PATCH] Tests: a FIFO read may end or report would-block, as long as it returns (FreeBSD) --- crates/engine/src/io.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/crates/engine/src/io.rs b/crates/engine/src/io.rs index bd14c87be..df08c6639 100644 --- a/crates/engine/src/io.rs +++ b/crates/engine/src/io.rs @@ -288,10 +288,17 @@ mod tests { let (tx, rx) = std::sync::mpsc::channel(); let p = fifo.clone(); std::thread::spawn(move || { - let _ = tx.send((read_whole(&p).is_err(), read_capped(&p, 9).is_ok())); + let capped = read_capped(&p, 9).map_err(|e| e.kind()); + let _ = tx.send((read_whole(&p).is_err(), capped)); }); let got = rx.recv_timeout(std::time::Duration::from_secs(10)); let _ = std::fs::remove_dir_all(&dir); - assert_eq!(got, Ok((true, true)), "reads of a FIFO must return"); + // The whole-file read refuses a FIFO. The capped read returns too: empty where a FIFO with + // no writer reads as ended (Linux, macOS), a `WouldBlock` error where it doesn't (FreeBSD). + // Either is fine; what it must not do is hang. + assert!( + matches!(&got, Ok((true, Ok(bytes))) if bytes.is_empty()) || matches!(&got, Ok((true, Err(std::io::ErrorKind::WouldBlock)))), + "reads of a FIFO must return, empty or as a would-block error: {got:?}" + ); } }