]> git.saurik.com Git - apt.git/blame - test/integration/run-tests
get color/msglevel handling for tests in line
[apt.git] / test / integration / run-tests
CommitLineData
8d876415
DK
1#!/bin/sh
2set -e
3
adee3bae 4FAIL=0
0954c58e
DK
5PASS=0
6ALL=0
7
2b4e2e83 8FAILED_TESTS=""
9962ae93 9DIR=$(readlink -f $(dirname $0))
1290422a
DK
10while [ -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
21done
22export MSGLEVEL="${MSGLEVEL:-3}"
682a3bf7 23
1290422a
DK
24if [ "$MSGCOLOR" != 'NO' ]; then
25 if ! expr match "$(readlink -f /proc/$$/fd/1)" '/dev/pts/[0-9]\+' > /dev/null; then
26 export MSGCOLOR='NO'
27 fi
28fi
29if [ "$MSGCOLOR" != 'NO' ]; then
682a3bf7
DK
30 CTEST='\033[1;32m'
31 CHIGH='\033[1;35m'
32 CRESET='\033[0m'
1290422a
DK
33else
34 CTEST=''
35 CHIGH=''
36 CRESET=''
fe268128
DK
37fi
38
8d876415 39for testcase in $(run-parts --list $DIR | grep '/test-'); do
682a3bf7
DK
40 if [ "$MSGLEVEL" -le 2 ]; then
41 echo -n "${CTEST}Testcase ${CHIGH}$(basename ${testcase})${CRESET}: "
39cc8228 42 else
682a3bf7 43 echo "${CTEST}Run Testcase ${CHIGH}$(basename ${testcase})${CRESET}"
39cc8228 44 fi
adee3bae 45 if ! ${testcase}; then
0954c58e
DK
46 FAIL=$((FAIL+1))
47 FAILED_TESTS="$FAILED_TESTS $(basename $testcase)"
48 echo >&2 "$(basename $testcase) ... FAIL"
49 else
50 PASS=$((PASS+1))
51 fi
52 ALL=$((ALL+1))
682a3bf7 53 if [ "$MSGLEVEL" -le 2 ]; then
39cc8228
DK
54 echo
55 fi
8d876415 56done
adee3bae 57
0954c58e
DK
58echo >&2 "Statistics: $ALL tests were run: $PASS successfully and $FAIL failed"
59if [ -n "$FAILED_TESTS" ]; then
60 echo >&2 "Failed tests: $FAILED_TESTS"
61else
62 echo >&2 'All tests seem to have been run successfully. What could possibly go wrong?'
2b4e2e83 63fi
f91bd741
MV
64# ensure we don't overflow
65exit $((FAIL <= 255 ? FAIL : 255))