use std::ffi::OsString;
use std::os::unix::ffi::OsStringExt;
use std::process::Command;
fn cctop(args: &[OsString]) -> std::process::Output {
Command::new(env!("CARGO_BIN_EXE_cctop"))
.args(args)
.env("CCTOP_LOG", "off")
.output()
.expect("the binary is built")
}
#[test]
fn a_hook_with_a_non_utf8_argument_still_exits_zero() {
let out = cctop(&[
OsString::from("hook"),
OsString::from("Stop"),
OsString::from_vec(b"\xff\xfe".to_vec()),
]);
assert_eq!(
out.status.code(),
Some(0),
"stderr: {}",
String::from_utf8_lossy(&out.stderr)
);
}
#[test]
fn a_near_miss_first_argument_is_not_answered_as_the_hook() {
let out = cctop(&[OsString::from_vec(b"hoo\xffk".to_vec())]);
assert_ne!(out.status.code(), Some(0), "it fell into the hook path");
}