use std::process::{Command, Stdio};
#[test]
fn enw_binary_runs_and_help_refers_to_enw() {
let enw = env!("CARGO_BIN_EXE_enw");
let output = Command::new(enw)
.arg("--help")
.stdin(Stdio::null())
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.output()
.expect("Failed to run `enw --help`");
assert!(
output.status.success(),
"`enw --help` should exit successfully, got status {:?}, stderr: {}",
output.status,
String::from_utf8_lossy(&output.stderr),
);
let stdout = String::from_utf8_lossy(&output.stdout);
let usage_line = stdout
.lines()
.map(str::trim_start)
.find(|line| line.starts_with("Usage:"))
.unwrap_or_else(|| panic!("`enw --help` stdout has no `Usage:` line, got: {stdout:?}"));
assert!(
usage_line.contains("enw"),
"Usage line must reference the `enw` binary, got: {usage_line:?}"
);
assert!(
!usage_line.contains("enwiro"),
"Usage line must not still reference `enwiro` as the bin name, got: {usage_line:?}"
);
}