#![cfg(unix)]
mod common;
use common::Repo;
#[test]
fn a_closed_pipe_kills_list_quietly() {
let r = Repo::new();
let mut manifest = String::new();
for i in 0..4000 {
manifest.push_str(&format!("pre-commit check-{i} * warn echo {i}\n"));
}
r.write("amont.conf", &manifest);
let out = std::process::Command::new("sh")
.arg("-c")
.arg(format!(
"'{}' list | head -c 1 > /dev/null",
env!("CARGO_BIN_EXE_amont")
))
.current_dir(&r.dir)
.output()
.expect("run the pipeline");
let stderr = String::from_utf8_lossy(&out.stderr);
assert!(
!stderr.contains("panicked"),
"list panicked on the closed pipe instead of dying quietly:\n{stderr}"
);
}