From b5da4e31ba816d9be5aeb692284bc587137e3358 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fe=CC=81lix=20Saparelli?= Date: Wed, 29 Dec 2021 19:56:02 +1300 Subject: [PATCH] Add -h testing --- cli/tests/help.rs | 22 +++++++++++++++++++++ cli/tests/snapshots/help__help_unix.snap | 2 +- cli/tests/snapshots/help__help_windows.snap | 2 +- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/cli/tests/help.rs b/cli/tests/help.rs index aacd67a..f291bd4 100644 --- a/cli/tests/help.rs +++ b/cli/tests/help.rs @@ -22,3 +22,25 @@ fn help() { String::from_utf8(output.stdout).unwrap() ); } + +#[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::::new(), "-h stderr is empty"); + assert_eq!( + long.stdout, short.stdout, + "--help and -h output are the same" + ); +} diff --git a/cli/tests/snapshots/help__help_unix.snap b/cli/tests/snapshots/help__help_unix.snap index 06ab89e..2041c2b 100644 --- a/cli/tests/snapshots/help__help_unix.snap +++ b/cli/tests/snapshots/help__help_unix.snap @@ -17,7 +17,7 @@ FLAGS: --no-global-ignore Skip auto-loading of global or environment-wide ignore files --no-meta Ignore metadata changes --no-process-group Do not use a process group when running the command - --no-ignore Skip auto-loading of project ignore files (.gitignore, .ignore, etc.) + --no-ignore Skip auto-loading of project ignore files (.gitignore, .ignore, etc) -n, --no-shell Do not wrap command in a shell. Deprecated: use --shell=none instead. --no-vcs-ignore Skip auto-loading of VCS (Git, etc) ignore files -N, --notify Send a desktop notification when the command ends diff --git a/cli/tests/snapshots/help__help_windows.snap b/cli/tests/snapshots/help__help_windows.snap index 627f1c2..4f16eb2 100644 --- a/cli/tests/snapshots/help__help_windows.snap +++ b/cli/tests/snapshots/help__help_windows.snap @@ -17,7 +17,7 @@ FLAGS: --no-global-ignore Skip auto-loading of global or environment-wide ignore files --no-meta Ignore metadata changes --no-process-group Do not use a process group when running the command - --no-ignore Skip auto-loading of project ignore files (.gitignore, .ignore, etc.) + --no-ignore Skip auto-loading of project ignore files (.gitignore, .ignore, etc) -n, --no-shell Do not wrap command in a shell. Deprecated: use --shell=none instead. --no-vcs-ignore Skip auto-loading of VCS (Git, etc) ignore files -N, --notify Send a desktop notification when the command ends