tests: fix --help test

Check for "Usage" only in the root command, builtins may not output
it.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
Giuseppe Scrivano 2014-10-21 16:20:58 +02:00 committed by Colin Walters
parent 26bdfae5bc
commit 22a82341b1
1 changed files with 8 additions and 4 deletions

View File

@ -26,11 +26,15 @@ echo "1..1"
echo "Testing:" 1>&2 echo "Testing:" 1>&2
test_recursive() { test_recursive() {
local cmd=$1 local cmd=$1
local root=$2
echo "$cmd" 1>&2 echo "$cmd" 1>&2
$cmd --help 1>out 2>err $cmd --help 1>out 2>err
# --help message goes to standard output # --help message goes to standard output
assert_file_has_content out "[Uu]sage" if [ "$root" == "1" ] ; then
assert_file_has_content out "$cmd" assert_file_has_content out "[Uu]sage"
assert_file_has_content out "$cmd"
fi
assert_file_empty err assert_file_empty err
builtins=`sed -n '/^Builtin commands/,/^[^ ]/p' <out | tail -n +2` builtins=`sed -n '/^Builtin commands/,/^[^ ]/p' <out | tail -n +2`
if [ "$builtins" != "" ] ; then if [ "$builtins" != "" ] ; then
@ -49,11 +53,11 @@ test_recursive() {
assert_file_empty out assert_file_empty out
for subcmd in $builtins ; do for subcmd in $builtins ; do
test_recursive "$cmd $subcmd" test_recursive "$cmd $subcmd" 0
done done
fi fi
} }
test_recursive ostree test_recursive ostree 1
echo "ok help option is properly supported" echo "ok help option is properly supported"