From a5a9e47fd4ce4eea00e85eb15ce217e8eecebfec Mon Sep 17 00:00:00 2001 From: Duyet Le Date: Fri, 23 Oct 2026 11:30:54 +0700 Subject: [PATCH] test(publish): tolerate a closed stdin pipe when the CLI exits early Co-Authored-By: Claude Opus 5.5 Co-authored-by: Duyet Le Co-authored-by: duyetbot --- tests/publish.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/publish.rs b/tests/publish.rs index f743348..8284e74 100644 --- a/tests/publish.rs +++ b/tests/publish.rs @@ -77,12 +77,10 @@ fn run_with_stdin(mut cmd: Command, input: &str) -> (i32, String, String) { .stderr(Stdio::piped()) .spawn() .unwrap(); - child - .stdin - .take() - .unwrap() - .write_all(input.as_bytes()) - .unwrap(); + // A usage error exits before reading stdin; the write then hits a closed pipe. + if let Err(err) = child.stdin.take().unwrap().write_all(input.as_bytes()) { + assert_eq!(err.kind(), std::io::ErrorKind::BrokenPipe, "{err}"); + } let out = child.wait_with_output().unwrap(); ( out.status.code().unwrap_or(1),