From: Ulrich Dangel Date: Sat, 12 Sep 2009 01:12:39 +0000 (+0200) Subject: refactored unit tests X-Git-Tag: v0.8.31~3^2~6 X-Git-Url: https://git.grml.org/?p=grml-autoconfig.git;a=commitdiff_plain;h=d1792371a76a1c03bbe2ebd9bc99271de9952e46;ds=inline refactored unit tests added run_tests script to run all tests invoke run_tests from debian/rules instead of test_parameters.sh --- diff --git a/debian/rules b/debian/rules index 2026dce..1cb8462 100755 --- a/debian/rules +++ b/debian/rules @@ -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 index 0000000..576b7fc --- /dev/null +++ b/tests/common_tests @@ -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 index 0000000..46c4645 --- /dev/null +++ b/tests/run_tests.sh @@ -0,0 +1,29 @@ +#!/bin/zsh +# Filename: run_tests +# Purpose: run unit tests for grml-autoconfig +# Authors: grml-team (grml.org), (c) Ulrich Dangel +# 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 diff --git a/tests/test_parameters.sh b/tests/test_bootparameters.sh similarity index 90% rename from tests/test_parameters.sh rename to tests/test_bootparameters.sh index 5d08f8a..7e61c86 100755 --- a/tests/test_parameters.sh +++ b/tests/test_bootparameters.sh @@ -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