use std::process::Command;
fn smix() -> Command {
Command::new(env!("CARGO_BIN_EXE_smix"))
}
#[test]
fn swipe_is_a_subcommand() {
let out = smix().args(["swipe", "--help"]).output().expect("run smix");
assert!(
out.status.success(),
"`smix swipe --help` failed — MCP has smix_swipe and the CLI must \
too.\nstderr: {}",
String::from_utf8_lossy(&out.stderr)
);
}
#[test]
fn swipe_help_names_all_four_directions() {
let out = smix().args(["swipe", "--help"]).output().expect("run smix");
let help = format!(
"{}{}",
String::from_utf8_lossy(&out.stdout),
String::from_utf8_lossy(&out.stderr)
);
for dir in ["up", "down", "left", "right"] {
assert!(
help.contains(dir),
"`smix swipe --help` does not mention `{dir}`. The MCP tool takes \
all four; a CLI that takes fewer is a narrower capability wearing \
the same name.\n{help}"
);
}
}
#[test]
fn swipe_help_says_the_direction_is_what_you_want_to_see() {
let out = smix().args(["swipe", "--help"]).output().expect("run smix");
let help = format!(
"{}{}",
String::from_utf8_lossy(&out.stdout),
String::from_utf8_lossy(&out.stderr)
);
assert!(
help.contains("reveals") || help.contains("want to see"),
"`smix swipe --help` does not say that the direction names what you \
want to see rather than which way the finger moves. `smix_swipe`'s \
description does, and a user reading only one of them would guess \
wrong half the time.\n{help}"
);
}
#[test]
fn an_unknown_direction_is_refused_as_a_direction() {
let out = smix()
.args(["swipe", "sideways"])
.output()
.expect("run smix");
let said = format!(
"{}{}",
String::from_utf8_lossy(&out.stdout),
String::from_utf8_lossy(&out.stderr)
);
assert!(
!out.status.success(),
"`smix swipe sideways` succeeded. A direction the driver cannot \
express has to fail loudly, not pick something."
);
assert!(
said.contains("sideways") || said.contains("direction"),
"`smix swipe sideways` failed without saying the direction was the \
problem. The reader has to learn which word was wrong.\n{said}"
);
}