]> git.saurik.com Git - apt.git/blame_incremental - test/integration/run-tests
add --sha512 option + documentation for apt-ftparchive
[apt.git] / test / integration / run-tests
... / ...
CommitLineData
1#!/bin/sh
2set -e
3
4FAIL=0
5PASS=0
6ALL=0
7
8FAILED_TESTS=""
9DIR=$(readlink -f $(dirname $0))
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}"
23
24if [ "$MSGCOLOR" != 'NO' ]; then
25 if [ ! -t 1 ]; then # but check that we output to a terminal
26 export MSGCOLOR='NO'
27 fi
28fi
29if [ "$MSGCOLOR" != 'NO' ]; then
30 CTEST='\033[1;32m'
31 CHIGH='\033[1;35m'
32 CRESET='\033[0m'
33else
34 CTEST=''
35 CHIGH=''
36 CRESET=''
37fi
38
39TOTAL="$(run-parts --list $DIR | grep '/test-' | wc -l)"
40for testcase in $(run-parts --list $DIR | grep '/test-'); do
41 if [ "$MSGLEVEL" -le 2 ]; then
42 printf "($(($ALL+1))/${TOTAL}) ${CTEST}Testcase ${CHIGH}$(basename ${testcase})${CRESET}: "
43 else
44 printf "${CTEST}Run Testcase ($(($ALL+1))/${TOTAL}) ${CHIGH}$(basename ${testcase})${CRESET}\n"
45 fi
46 if ! ${testcase}; then
47 FAIL=$((FAIL+1))
48 FAILED_TESTS="$FAILED_TESTS $(basename $testcase)"
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
54 else
55 PASS=$((PASS+1))
56 fi
57 ALL=$((ALL+1))
58 if [ "$MSGLEVEL" -le 2 ]; then
59 echo
60 fi
61done
62
63echo >&2 "Statistics: $ALL tests were run: $PASS successfully and $FAIL failed"
64if [ -n "$FAILED_TESTS" ]; then
65 echo >&2 "Failed tests: $FAILED_TESTS"
66else
67 echo >&2 'All tests seem to have been run successfully. What could possibly go wrong?'
68fi
69# ensure we don't overflow
70exit $((FAIL <= 255 ? FAIL : 255))