Skip to content

Commit

Permalink
Merge pull request #4848 from ipfs/check-failure-with-bad-flag
Browse files Browse the repository at this point in the history
sharness/t0010: check that all the commands fail when passed a bad flag
whyrusleeping authored Mar 23, 2018
2 parents 2c0bb93 + 30039a7 commit 550c6eb
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions test/sharness/t0010-basic-commands.sh
Original file line number Diff line number Diff line change
@@ -66,7 +66,7 @@ test_expect_success "All commands accept --help" '
while read -r cmd
do
$cmd --help </dev/null >/dev/null ||
{ echo $cmd doesnt accept --help; echo 1 > fail; }
{ echo "$cmd doesnt accept --help"; echo 1 > fail; }
done <commands.txt
if [ $(cat fail) = 1 ]; then
@@ -80,7 +80,7 @@ test_expect_failure "All ipfs root commands are mentioned in base helptext" '
while read cmd
do
grep " $cmd" help.txt > /dev/null ||
{ echo missing $cmd from helptext; echo 1 > fail; }
{ echo "missing $cmd from helptext"; echo 1 > fail; }
done
if [ $(cat fail) = 1 ]; then
@@ -94,7 +94,20 @@ test_expect_failure "All ipfs commands docs are 80 columns or less" '
do
LENGTH="$($cmd --help | awk "{ print length }" | sort -nr | head -1)"
[ $LENGTH -gt 80 ] &&
{ echo "$cmd" help text is longer than 79 chars "($LENGTH)"; echo 1 > fail; }
{ echo "$cmd help text is longer than 79 chars ($LENGTH)"; echo 1 > fail; }
done <commands.txt
if [ $(cat fail) = 1 ]; then
return 1
fi
'

test_expect_success "All ipfs commands fail when passed a bad flag" '
echo 0 > fail
while read -r cmd
do
test_must_fail $cmd --badflag >/dev/null ||
{ echo "$cmd exit with code 0 when passed --badflag"; echo 1 > fail; }
done <commands.txt
if [ $(cat fail) = 1 ]; then

0 comments on commit 550c6eb

Please sign in to comment.