From d1792371a76a1c03bbe2ebd9bc99271de9952e46 Mon Sep 17 00:00:00 2001 From: Ulrich Dangel Date: Sat, 12 Sep 2009 03:12:39 +0200 Subject: [PATCH] refactored unit tests added run_tests script to run all tests invoke run_tests from debian/rules instead of test_parameters.sh --- debian/rules | 2 +- tests/common_tests | 15 +++++++++++ tests/run_tests.sh | 29 ++++++++++++++++++++++ .../{test_parameters.sh => test_bootparameters.sh} | 13 +--------- 4 files changed, 46 insertions(+), 13 deletions(-) create mode 100644 tests/common_tests create mode 100755 tests/run_tests.sh rename tests/{test_parameters.sh => test_bootparameters.sh} (90%) 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 -- 2.1.4