use std::process::Command;
fn alef_binary() -> std::path::PathBuf {
if let Ok(path) = std::env::var("CARGO_BIN_EXE_alef") {
return std::path::PathBuf::from(path);
}
let mut dir = std::env::current_exe()
.expect("current_exe")
.parent()
.expect("parent")
.to_path_buf();
if dir.ends_with("deps") {
dir = dir.parent().expect("parent of deps").to_path_buf();
}
dir.join("alef")
}
#[test]
fn generate_help_shows_no_format_flag() {
let output = Command::new(alef_binary())
.args(["generate", "--help"])
.output()
.expect("failed to run alef generate --help");
let stdout = String::from_utf8_lossy(&output.stdout);
let stderr = String::from_utf8_lossy(&output.stderr);
let combined = format!("{stdout}{stderr}");
assert!(
combined.contains("--no-format"),
"`alef generate --help` must list --no-format flag; got:\n{combined}"
);
assert!(
!combined.contains(" --format"),
"`alef generate --help` must not list the old --format flag; got:\n{combined}"
);
}
#[test]
fn all_help_shows_no_format_flag() {
let output = Command::new(alef_binary())
.args(["all", "--help"])
.output()
.expect("failed to run alef all --help");
let stdout = String::from_utf8_lossy(&output.stdout);
let stderr = String::from_utf8_lossy(&output.stderr);
let combined = format!("{stdout}{stderr}");
assert!(
combined.contains("--no-format"),
"`alef all --help` must list --no-format flag; got:\n{combined}"
);
assert!(
!combined.contains(" --format"),
"`alef all --help` must not list the old --format flag; got:\n{combined}"
);
}
#[test]
fn generate_rejects_old_format_flag() {
let output = Command::new(alef_binary())
.args(["generate", "--format"])
.output()
.expect("failed to spawn alef");
assert!(
!output.status.success(),
"alef generate --format (old flag) must exit non-zero; it was accepted unexpectedly"
);
}
#[test]
fn all_rejects_old_format_flag() {
let output = Command::new(alef_binary())
.args(["all", "--format"])
.output()
.expect("failed to spawn alef");
assert!(
!output.status.success(),
"alef all --format (old flag) must exit non-zero; it was accepted unexpectedly"
);
}