tests: Allow run_cluster_tests.sh to take options
authorMartin Schwenke <martin@meltin.net>
Thu, 10 May 2012 06:17:44 +0000 (16:17 +1000)
committerMartin Schwenke <martin@meltin.net>
Fri, 11 May 2012 00:33:27 +0000 (10:33 +1000)
However, options must be followed by "--".

This also fixes:

* a bug where specifying tests caused local daemons to be used; and
* an incorrect comment.

Signed-off-by: Martin Schwenke <martin@meltin.net>
tests/run_cluster_tests.sh

index fa45534b0c371b4b49db3b141ac261b0ad8d4e01..9cafd50b136e3290d80c0518ece1186168aadc82 100755 (executable)
@@ -2,16 +2,29 @@
 
 test_dir=$(dirname "$0")
 
+# Allow options to be passed to this script.  However, if any options
+# are passed there must be a "--" between the options and the tests.
+# This makes it easy to handle options that take arguments.
+opts=""
+case "$1" in
+    -*)
+       while [ -n "$1" ] ; do
+           case "$1" in
+               --) shift ; break ;;
+               *) opts="$opts $1" ; shift ;;
+           esac
+       done
+esac
+
 if [ -n "$1" ] ; then
-    "${test_dir}/scripts/run_tests" -l -s "$@" || exit 1
+    "${test_dir}/scripts/run_tests" -s $opts "$@" || exit 1
 else
     cd "$test_dir"
 
-    # By default, run all unit tests and the tests against local
-    # daemons
+    # By default, don't bother with unit tests
     dirs="simple complex"
 
-    ./scripts/run_tests -s $dirs || exit 1
+    ./scripts/run_tests -s $opts $dirs || exit 1
 fi
 
 echo "All OK"