]>
git.saurik.com Git - apt.git/blob - test/integration/run-tests
6 if [ "$1" = "-q" ]; then
8 elif [ "$1" = "-v" ]; then
10 elif [ "$1" = '--color=no' ]; then
12 elif [ "$1" = '--color=yes' ]; then
14 elif [ "$1" = '--color' ]; then
15 export MSGCOLOR
="$(echo "$2" | tr 'a-z' 'A-Z')"
17 elif [ "$1" = '--level' ]; then
20 elif [ "$1" = '-j' ]; then
23 elif [ -x "$1" ]; then
26 echo >&2 "WARNING: Unknown parameter »$1« will be ignored"
30 export MSGLEVEL
="${MSGLEVEL:-3}"
32 if [ "${MSGCOLOR:-YES}" = 'YES' ]; then
33 if [ ! -t 1 ]; then # but check that we output to a terminal
37 if [ "$MSGCOLOR" != 'NO' ]; then
47 if [ -n "$TESTTORUN" ]; then
48 # collecting the output of one test to have it together
51 if [ "$MSGLEVEL" -le 2 ]; then
52 printf "${CTEST}Testcase ${CHIGH}${TESTTORUN##*/}${CRESET}: "
54 printf "${CTEST}Run Testcase ${CHIGH}${TESTTORUN##*/}${CRESET}\n"
56 if ! "$TESTTORUN"; then
58 if [ "$MSGLEVEL" -le 2 ]; then
59 printf >&2 "\n${CHIGH}Running ${TESTTORUN##*/} -> FAILED${CRESET}"
61 echo >&2 "${CHIGH}Running ${TESTTORUN##*/} -> FAILED${CRESET}"
64 if [ "$MSGLEVEL" -le 2 ]; then
68 # without we end up getting stepped output 'randomly'
72 if [ "$FAIL" = 'yes' ]; then
83 DIR
="$(readlink -f "$(dirname "$0")")"
84 TESTLIST="$(run-parts --list "$DIR" --regex '^test-.*$')"
85 if [ -n "$APT_TEST_JOBS" ]; then
86 if [ "$MSGCOLOR" != 'NO' ]; then
87 export MSGCOLOR='ALWAYS'
89 exec parallel -j "$APT_TEST_JOBS" "$0" -- $(echo "$TESTLIST")
91 TOTAL="$(echo "$TESTLIST" | wc -l)"
92 for testcase in $TESTLIST; do
93 if [ "$MSGLEVEL" -le 2 ]; then
94 printf "($(($ALL+1))/${TOTAL}) ${CTEST}Testcase
${CHIGH}${testcase##*/}${CRESET}: "
96 printf "${CTEST}Run Testcase
($(($ALL+1))/${TOTAL}) ${CHIGH}${testcase##*/}${CRESET}\n"
98 if ! ${testcase}; then
100 FAILED_TESTS="$FAILED_TESTS ${testcase##*/}"
101 if [ "$MSGLEVEL" -le 2 ]; then
102 printf >&2 "\n${CHIGH}Running
${testcase##*/} -> FAILED
${CRESET}"
104 echo >&2 "${CHIGH}Running
${testcase##*/} -> FAILED
${CRESET}"
110 if [ "$MSGLEVEL" -le 2 ]; then
115 echo >&2 "Statistics
: $ALL tests were run
: $PASS successfully and
$FAIL failed
"
116 if [ -n "$FAILED_TESTS" ]; then
117 echo >&2 "Failed tests
: $FAILED_TESTS"
119 echo >&2 'All tests seem to have been run successfully. What could possibly go wrong?'
121 # ensure we don't overflow
122 exit $((FAIL <= 255 ? FAIL : 255))