From 3f91d7a9f6f74714f27537fee694bad6966beea5 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sat, 24 Sep 2005 00:52:58 +0000 Subject: [PATCH] cleanup option parsing --- testsuite/testing.sh | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/testsuite/testing.sh b/testsuite/testing.sh index 420cfa1ef..b7c85c227 100755 --- a/testsuite/testing.sh +++ b/testsuite/testing.sh @@ -19,11 +19,25 @@ # The environment variable "FAILCOUNT" contains a cumulative total of the # -# The command line parsing is ugly and should be improved. +verbose=0 +debug=0 +force=0 +for x in "$@" ; do + case "$x" in + -v|--verbose) verbose=1; shift;; + -d|--debug) debug=1; shift;; + -f|--force) force=1; shift;; + --) break;; + -*) echo "Unknown option '$x'"; exit 1;; + *) break;; + esac +done -if [ "$1" == "-v" ] -then - verbose=1 +if [ -n "$VERBOSE" ] ; then + verbose=1 +fi +if [ -n "$DEBUG" ] ; then + debug=1 fi export FAILCOUNT=0 @@ -48,16 +62,19 @@ testing() exit fi - if [ ${force_tests:-0} -ne 1 -a -n "$_BB_CONFIG_DEP" ] + if [ "$debug" = "1" ] ; then + set -x + fi + + if [ -n "$_BB_CONFIG_DEP" ] && [ "${force}" = "0" ] then if ! config_is_set "$_BB_CONFIG_DEP" then - echo "UNTESTED: $1" + echo "SKIPPED: $1" return 0 fi fi - f=$FAILCOUNT echo -ne "$3" > expected echo -ne "$4" > input echo -n -e "$5" | eval "$COMMAND $2" > actual @@ -66,9 +83,9 @@ testing() cmp expected actual > /dev/null if [ $? -ne 0 ] then - FAILCOUNT=$[$FAILCOUNT+1] + ((FAILCOUNT++)) echo "FAIL: $1" - if [ $verbose ] + if [ "$verbose" = "1" ] then diff -u expected actual fi @@ -77,5 +94,9 @@ testing() fi rm -f input expected actual + if [ "$debug" = "1" ] ; then + set +x + fi + return $RETVAL }