From c9b06645de2e0ceff23272de930418fb66b870e0 Mon Sep 17 00:00:00 2001 From: Michele Locati Date: Tue, 13 Mar 2018 17:15:03 +0100 Subject: Start adding tests --- test/all-tests.sh | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 test/all-tests.sh (limited to 'test/all-tests.sh') diff --git a/test/all-tests.sh b/test/all-tests.sh new file mode 100644 index 0000000..be10e10 --- /dev/null +++ b/test/all-tests.sh @@ -0,0 +1,69 @@ +#!/bin/sh + +IS_TEST_CASE=0 +if ! . "$(cd -- "$(dirname -- "$0")" && pwd -P)/bootstrap.sh" +then + echo 'Unable to find bootstrap script'>&2 + exit 1 +fi + +wantedFilter='' +if test $# -eq 1 +then + wantedFilter="${1}" +else + wantedFilter='' +fi + +someTestExecuted=0 +for testFile in "${DIR_TESTCASES}"/* +do + fullTestName="$(basename "${testFile}")" + testName=${fullTestName%.success} + if test "${fullTestName}" != "${testName}" + then + should='succeed' + else + testName=${fullTestName%.fail} + if test "${fullTestName}" != "${testName}" + then + should='fail' + else + printf 'Unrecognized test case: %s\n', "${fullTestName}" + exit 1 + fi + fi + if test -z "${wantedFilter}" -o "${testName}" = "${wantedFilter}" + then + printf '%s should %s... ' "${testName}" "${should}" + case "${should}" in + 'succeed') + if testOutput="$(${testFile} 2>&1)" + then + printf 'ok.\n' + else + printf 'FAILED!\n' + printf '%s\n' "${testOutput}" >&2 + exit 1 + fi + ;; + 'fail') + if testOutput="$(${testFile} 2>&1)" + then + printf 'FAILED!\n' + printf '%s\n' "${testOutput}" >&2 + exit 1 + else + printf 'ok.\n' + fi + ;; + esac + someTestExecuted=1 + fi +done + +if test ${someTestExecuted} -eq 0 +then + echo 'No test found!'>&2 + exit 1 +fi -- cgit v1.2.3