diff options
author | Ed Santiago <santiago@redhat.com> | 2020-05-05 07:18:03 -0600 |
---|---|---|
committer | Ed Santiago <santiago@redhat.com> | 2020-05-05 07:19:58 -0600 |
commit | 29d39e35e460e0b48df8a28c7672d8e11bf29648 (patch) | |
tree | 3b756b85fbdabd22151e12b2d24228f816a74ed7 /test/system/015-help.bats | |
parent | e1be837a4ff149e00ff6af9e71cf9ea625e33e6f (diff) | |
download | podman-29d39e35e460e0b48df8a28c7672d8e11bf29648.tar.gz podman-29d39e35e460e0b48df8a28c7672d8e11bf29648.tar.bz2 podman-29d39e35e460e0b48df8a28c7672d8e11bf29648.zip |
BATS help test: check usage string
Now that we've agreed that usage messages should match
what the user typed, confirm it. IOW 'podman foo --help'
should not issue a usage message for 'podman container foo'.
Fix one broken instance, 'unpause'.
Signed-off-by: Ed Santiago <santiago@redhat.com>
Diffstat (limited to 'test/system/015-help.bats')
-rw-r--r-- | test/system/015-help.bats | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/test/system/015-help.bats b/test/system/015-help.bats index 6c3d617dc..42d3bd3ec 100644 --- a/test/system/015-help.bats +++ b/test/system/015-help.bats @@ -28,13 +28,20 @@ function check_help() { local subcommands_found=0 for cmd in $(podman_commands "$@"); do - dprint "podman $@ $cmd --help" + # Human-readable podman command string, with multiple spaces collapsed + command_string="podman $* $cmd" + command_string=${command_string// / } # 'podman x' -> 'podman x' + + dprint "$command_string --help" run_podman "$@" $cmd --help # The line immediately after 'Usage:' gives us a 1-line synopsis usage=$(echo "$output" | grep -A1 '^Usage:' | tail -1) [ -n "$usage" ] || die "podman $cmd: no Usage message found" + # e.g. 'podman ps' should not show 'podman container ps' in usage + is "$usage" " $command_string .*" "Usage string matches command" + # If usage ends in '[command]', recurse into subcommands if expr "$usage" : '.*\[command\]$' >/dev/null; then subcommands_found=$(expr $subcommands_found + 1) @@ -46,10 +53,10 @@ function check_help() { # Confirm that by running with 'invalid-arg' and expecting failure. if expr "$usage" : '.*\[flags\]$' >/dev/null; then if [ "$cmd" != "help" ]; then - dprint "podman $@ $cmd invalid-arg" + dprint "$command_string invalid-arg" run_podman 125 "$@" $cmd invalid-arg is "$output" "Error: .* takes no arguments" \ - "'podman $@ $cmd' with extra (invalid) arguments" + "'$command_string' with extra (invalid) arguments" fi fi @@ -69,10 +76,10 @@ function check_help() { # The </dev/null protects us from 'podman login' which will # try to read username/password from stdin. - dprint "podman $@ $cmd (without required args)" + dprint "$command_string (without required args)" run_podman 125 "$@" $cmd </dev/null is "$output" "Error:.* \(require\|specif\|must\|provide\|need\|choose\|accepts\)" \ - "'podman $@ $cmd' without required arg" + "'$command_string' without required arg" fi count=$(expr $count + 1) |