Merge pull request #2797 from FredApps/fix-fifo-test-freebsd

Tests: the FIFO read test accepts a would-block error (main's FreeBSD nightly is red)
This commit is contained in:
FredApps authored and GitHub committed 2026-11-14 16:43:25 +01:00
commit 8b169f8ee7
1 file changed
+9 -2
+9 -2
View File
@@ -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:?}"
);
}
}