watchexec/cli/tests/help.rs

47 lines
901 B
Rust
Raw Normal View History

2021-05-10 13:02:31 +02:00
use std::process::Command;
use assert_cmd::prelude::*;
use insta::assert_snapshot;
#[test]
fn help() {
2021-08-24 10:21:21 +02:00
let output = Command::cargo_bin("watchexec")
.unwrap()
.arg("--help")
.output()
.unwrap();
2021-05-10 13:02:31 +02:00
2021-08-24 10:21:21 +02:00
assert!(output.status.success(), "--help returns 0");
assert_eq!(output.stderr, Vec::<u8>::new(), "--help stderr is empty");
assert_snapshot!(
if cfg!(windows) {
"help_windows"
} else {
"help_unix"
},
String::from_utf8(output.stdout).unwrap()
);
2021-05-10 13:02:31 +02:00
}
2021-12-29 07:56:02 +01:00
#[test]
fn help_short() {
let long = Command::cargo_bin("watchexec")
.unwrap()
.arg("--help")
.output()
.unwrap();
let short = Command::cargo_bin("watchexec")
.unwrap()
.arg("--help")
.output()
.unwrap();
assert!(short.status.success(), "-h returns 0");
assert_eq!(short.stderr, Vec::<u8>::new(), "-h stderr is empty");
assert_eq!(
long.stdout, short.stdout,
"--help and -h output are the same"
);
}