]>
Commit | Line | Data |
---|---|---|
8d876415 DK |
1 | #!/bin/sh |
2 | set -e | |
3 | ||
adee3bae | 4 | FAIL=0 |
0954c58e DK |
5 | PASS=0 |
6 | ALL=0 | |
7 | ||
2b4e2e83 | 8 | FAILED_TESTS="" |
9962ae93 | 9 | DIR=$(readlink -f $(dirname $0)) |
1290422a DK |
10 | while [ -n "$1" ]; do |
11 | if [ "$1" = "-q" ]; then | |
12 | export MSGLEVEL=2 | |
13 | elif [ "$1" = "-v" ]; then | |
14 | export MSGLEVEL=4 | |
15 | elif [ "$1" = '--color=no' ]; then | |
16 | export MSGCOLOR='NO' | |
17 | else | |
18 | echo >&2 "WARNING: Unknown parameter »$1« will be ignored" | |
19 | fi | |
20 | shift | |
21 | done | |
22 | export MSGLEVEL="${MSGLEVEL:-3}" | |
682a3bf7 | 23 | |
1290422a | 24 | if [ "$MSGCOLOR" != 'NO' ]; then |
27cb4f6c | 25 | if [ ! -t 1 ]; then # but check that we output to a terminal |
1290422a DK |
26 | export MSGCOLOR='NO' |
27 | fi | |
28 | fi | |
29 | if [ "$MSGCOLOR" != 'NO' ]; then | |
682a3bf7 DK |
30 | CTEST='\033[1;32m' |
31 | CHIGH='\033[1;35m' | |
32 | CRESET='\033[0m' | |
1290422a DK |
33 | else |
34 | CTEST='' | |
35 | CHIGH='' | |
36 | CRESET='' | |
fe268128 DK |
37 | fi |
38 | ||
b41713ef | 39 | TOTAL="$(run-parts --list $DIR | grep '/test-' | wc -l)" |
8d876415 | 40 | for testcase in $(run-parts --list $DIR | grep '/test-'); do |
682a3bf7 | 41 | if [ "$MSGLEVEL" -le 2 ]; then |
3c528b91 | 42 | printf "($(($ALL+1))/${TOTAL}) ${CTEST}Testcase ${CHIGH}$(basename ${testcase})${CRESET}: " |
39cc8228 | 43 | else |
3c528b91 | 44 | printf "${CTEST}Run Testcase ($(($ALL+1))/${TOTAL}) ${CHIGH}$(basename ${testcase})${CRESET}\n" |
39cc8228 | 45 | fi |
adee3bae | 46 | if ! ${testcase}; then |
0954c58e DK |
47 | FAIL=$((FAIL+1)) |
48 | FAILED_TESTS="$FAILED_TESTS $(basename $testcase)" | |
e52aad52 DK |
49 | if [ "$MSGLEVEL" -le 2 ]; then |
50 | printf >&2 "\n${CHIGH}Running $(basename $testcase) -> FAILED${CRESET}" | |
51 | else | |
52 | echo >&2 "${CHIGH}Running $(basename $testcase) -> FAILED${CRESET}" | |
53 | fi | |
0954c58e DK |
54 | else |
55 | PASS=$((PASS+1)) | |
56 | fi | |
57 | ALL=$((ALL+1)) | |
682a3bf7 | 58 | if [ "$MSGLEVEL" -le 2 ]; then |
39cc8228 DK |
59 | echo |
60 | fi | |
8d876415 | 61 | done |
adee3bae | 62 | |
0954c58e DK |
63 | echo >&2 "Statistics: $ALL tests were run: $PASS successfully and $FAIL failed" |
64 | if [ -n "$FAILED_TESTS" ]; then | |
65 | echo >&2 "Failed tests: $FAILED_TESTS" | |
66 | else | |
67 | echo >&2 'All tests seem to have been run successfully. What could possibly go wrong?' | |
2b4e2e83 | 68 | fi |
f91bd741 MV |
69 | # ensure we don't overflow |
70 | exit $((FAIL <= 255 ? FAIL : 255)) |