summaryrefslogtreecommitdiff
path: root/test/integration/test-00-commands-have-help
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2014-11-08 18:14:46 +0100
committerDavid Kalnischkies <david@kalnischkies.de>2014-11-09 01:26:07 +0100
commitad7e0941b376d792911f240377094a2e78ca8756 (patch)
treea7e65478aa213bd7639cd45e8025989b6d413bfa /test/integration/test-00-commands-have-help
parent20801f613690b330c79b4f7a30dc3ff52b722468 (diff)
streamline display of --help in all tools
By convention, if I run a tool with --help or --version I expect it to exit successfully with the usage, while if I do call it wrong (like without any parameters) I expect the usage message shown with a non-zero exit.
Diffstat (limited to 'test/integration/test-00-commands-have-help')
-rwxr-xr-xtest/integration/test-00-commands-have-help52
1 files changed, 52 insertions, 0 deletions
diff --git a/test/integration/test-00-commands-have-help b/test/integration/test-00-commands-have-help
new file mode 100755
index 000000000..ebf8b8cfa
--- /dev/null
+++ b/test/integration/test-00-commands-have-help
@@ -0,0 +1,52 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+configarchitecture 'amd64'
+
+# this test does double duty: The obvious is checking for --help and co,
+# but it also checks if the binary can find all methods in the library.
+# The later is quite handy for manual testing of non-abibreaking changes
+export LD_BIND_NOW=1
+
+checkversionmessage() {
+ testsuccess grep '^apt .* compiled on ' ${1}-help.output
+}
+
+checkhelpmessage() {
+ checkversionmessage "$1"
+ testsuccess grep '^Usage:' ${1}-help.output
+}
+
+checkoptions() {
+ testsuccess $1 --help
+ cp -f rootdir/tmp/testsuccess.output ${1}-help.output
+ checkhelpmessage "$1"
+
+ testsuccess $1 --version
+ cp -f rootdir/tmp/testsuccess.output ${1}-help.output
+ checkversionmessage "$1"
+}
+
+for CMD in 'apt-cache' 'apt-cdrom' 'apt-config' \
+ 'apt-extracttemplates' 'apt-get' 'apt-helper' \
+ 'apt-mark' 'apt-sortpkgs' 'apt' 'apt-ftparchive'; do
+ cmd="$(echo "$CMD" | tr -d '-')"
+ msgtest 'Test for failure with no parameters calling' "$CMD"
+ if $cmd > ${cmd}-help.output 2>&1; then
+ echo
+ cat ${cmd}-help.output
+ msgfail 'zero exit'
+ else
+ msgpass
+ fi
+ checkhelpmessage "$cmd"
+ checkoptions "$cmd"
+done
+
+for CMD in 'apt-dump-solver' 'apt-internal-solver'; do
+ checkoptions "$(echo "$CMD" | tr -d '-')"
+done