use std::process::Command;
const BIN: &str = env!("CARGO_BIN_EXE_pathlint");
#[test]
fn invalid_config_path_error_uses_canonical_flag_name() {
let out = Command::new(BIN)
.args([
"--config",
"/definitely/does/not/exist/pathlint.toml",
"check",
])
.output()
.expect("failed to run pathlint");
let stderr = String::from_utf8_lossy(&out.stderr);
assert!(
stderr.contains("--config"),
"stderr must mention --config: {stderr}"
);
assert!(
!stderr.contains("--rules"),
"stale --rules name leaked into error: {stderr}"
);
}
#[test]
fn rules_alias_no_longer_accepted() {
let out = Command::new(BIN)
.args([
"--rules",
"/definitely/does/not/exist/pathlint.toml",
"check",
])
.output()
.expect("failed to run pathlint");
let code = out.status.code().unwrap_or(-1);
let stderr = String::from_utf8_lossy(&out.stderr);
assert_eq!(
code, 2,
"removed alias must surface as a clap parse error (exit 2); stderr: {stderr}"
);
assert!(
stderr.contains("--rules") || stderr.contains("rules"),
"clap's error should name the unknown argument: {stderr}"
);
}
#[test]
fn where_alias_no_longer_accepted() {
let out = Command::new(BIN)
.args(["where", "ls"])
.output()
.expect("failed to run pathlint");
let code = out.status.code().unwrap_or(-1);
let stderr = String::from_utf8_lossy(&out.stderr);
assert_eq!(
code, 2,
"removed alias must surface as a clap parse error (exit 2); stderr: {stderr}"
);
assert!(
stderr.contains("where"),
"clap's error should name the unknown subcommand: {stderr}"
);
}
#[test]
fn canonical_names_emit_no_deprecation_warning() {
let out = Command::new(BIN)
.args(["trace", "definitely_no_such_command_xyz"])
.output()
.expect("failed to run pathlint");
let stderr = String::from_utf8_lossy(&out.stderr);
assert!(
!stderr.contains("deprecated"),
"canonical 'trace' must not surface deprecation: {stderr}"
);
let out = Command::new(BIN)
.args([
"--config",
"/definitely/does/not/exist/pathlint.toml",
"check",
])
.output()
.expect("failed to run pathlint");
let stderr = String::from_utf8_lossy(&out.stderr);
assert!(
!stderr.contains("deprecated"),
"canonical '--config' must not surface deprecation: {stderr}"
);
}