]> git.saurik.com Git - apt.git/blob - test/integration/run-tests
support DEB_BUILD_PROFILES and -P for build profiles
[apt.git] / test / integration / run-tests
1 #!/bin/sh
2 set -e
3
4 FAIL=0
5 PASS=0
6 ALL=0
7
8 FAILED_TESTS=""
9 DIR=$(readlink -f $(dirname $0))
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}"
23
24 if [ "$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
28 fi
29 if [ "$MSGCOLOR" != 'NO' ]; then
30 CTEST='\033[1;32m'
31 CHIGH='\033[1;35m'
32 CRESET='\033[0m'
33 else
34 CTEST=''
35 CHIGH=''
36 CRESET=''
37 fi
38
39 for testcase in $(run-parts --list $DIR | grep '/test-'); do
40 if [ "$MSGLEVEL" -le 2 ]; then
41 echo -n "${CTEST}Testcase ${CHIGH}$(basename ${testcase})${CRESET}: "
42 else
43 echo "${CTEST}Run Testcase ${CHIGH}$(basename ${testcase})${CRESET}"
44 fi
45 if ! ${testcase}; then
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))
53 if [ "$MSGLEVEL" -le 2 ]; then
54 echo
55 fi
56 done
57
58 echo >&2 "Statistics: $ALL tests were run: $PASS successfully and $FAIL failed"
59 if [ -n "$FAILED_TESTS" ]; then
60 echo >&2 "Failed tests: $FAILED_TESTS"
61 else
62 echo >&2 'All tests seem to have been run successfully. What could possibly go wrong?'
63 fi
64 # ensure we don't overflow
65 exit $((FAIL <= 255 ? FAIL : 255))