use std::io::Read;
use std::process::{Command, Stdio};
#[test]
fn closing_the_pipe_is_not_a_panic() {
let mut child = Command::new(env!("CARGO_BIN_EXE_semlith"))
.arg("languages")
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.spawn()
.expect("semlith runs");
drop(child.stdout.take().expect("a pipe"));
let mut said = String::new();
child
.stderr
.take()
.expect("a pipe")
.read_to_string(&mut said)
.expect("stderr reads");
let status = child.wait().expect("semlith exits");
assert!(
!said.contains("panicked at"),
"printing to a closed pipe panicked:\n{said}"
);
assert_ne!(
status.code(),
Some(101),
"the process exited with a panic status: {said}"
);
}