refactored unit tests
authorUlrich Dangel <mru@grml.org>
Sat, 12 Sep 2009 01:12:39 +0000 (03:12 +0200)
committerUlrich Dangel <mru@grml.org>
Sat, 12 Sep 2009 11:06:15 +0000 (13:06 +0200)
added run_tests script to run all tests
invoke run_tests from debian/rules instead of test_parameters.sh

debian/rules
tests/common_tests [new file with mode: 0644]
tests/run_tests.sh [new file with mode: 0755]
tests/test_bootparameters.sh [moved from tests/test_parameters.sh with 90% similarity]

index 2026dce..1cb8462 100755 (executable)
@@ -13,7 +13,7 @@ build: build-stamp
 
 build-stamp:
        dh_testdir
-       (cd tests && ./test_parameters.sh)
+       (cd tests && ./run_tests.sh)
        (cd doc && $(MAKE))
 
        touch build-stamp
diff --git a/tests/common_tests b/tests/common_tests
new file mode 100644 (file)
index 0000000..576b7fc
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/zsh
+
+setopt shwordsplit
+
+oneTimeSetUp() {
+    OLDPATH=$PATH
+
+    . ../autoconfig.functions
+
+    export PATH=$OLDPATH
+}
+
+
+SHUNIT_PARENT=$1
+. ./shunit2
diff --git a/tests/run_tests.sh b/tests/run_tests.sh
new file mode 100755 (executable)
index 0000000..46c4645
--- /dev/null
@@ -0,0 +1,29 @@
+#!/bin/zsh
+# Filename:      run_tests
+# Purpose:       run unit tests for grml-autoconfig
+# Authors:       grml-team (grml.org), (c) Ulrich Dangel <mru@grml.org>
+# Bug-Reports:   see http://grml.org/bugs/
+# License:       This file is licensed under the GPL v2.
+################################################################################
+
+
+GLOBRETVAL=0
+
+for FILE in test_*.sh ; do
+  if [ -x ${FILE} ] ; then
+     pretty_name="${FILE##test_}"
+     pretty_name="${pretty_name/.sh/}"
+
+     echo "Running test for: ${pretty_name}"
+
+     ./${FILE}
+     RETVAL=$?
+
+     [ "$RETVAL" -ne 0 ] && GLOBRETVAL=$RETVAL
+  fi
+done
+
+exit $GLOBRETVAL
+
+## END OF FILE #################################################################
+# vim:foldmethod=marker expandtab ai ft=zsh shiftwidth=3
similarity index 90%
rename from tests/test_parameters.sh
rename to tests/test_bootparameters.sh
index 5d08f8a..7e61c86 100755 (executable)
@@ -1,6 +1,5 @@
 #!/bin/zsh
 
-setopt shwordsplit
 
 test_checkbootparam() {
     CMDLINE='foo=dingens bar foobar=blub'
@@ -51,14 +50,4 @@ test_getbootparam() {
 }
 
 
-oneTimeSetUp() {
-    OLDPATH=$PATH
-
-    . ../autoconfig.functions
-
-    export PATH=$OLDPATH
-}
-
-SHUNIT_PARENT=$0
-
-. ./shunit2
+. ./common_tests $0