]>
git.saurik.com Git - apt.git/blob - test/integration/run-tests
e90b4b7558eb13c3b45d04cc5b968fb0c6b9575e
3 TESTDIR
="$(readlink -f "$(dirname "$0")")"
6 find_project_binary_dir
12 if [ "$1" = "-q" ]; then
14 elif [ "$1" = "-v" ]; then
16 elif [ "$1" = '--color=no' ]; then
18 elif [ "$1" = '--color=yes' ]; then
20 elif [ "$1" = '--color' ]; then
21 export MSGCOLOR="$(echo "$2" | tr 'a-z' 'A-Z')"
23 elif [ "$1" = '--level' ]; then
26 elif [ "$1" = '-j' ]; then
29 elif [ -x "$1" ]; then
32 echo >&2 "WARNING
: Unknown parameter »
$1« will be ignored
"
36 export MSGLEVEL="${MSGLEVEL:-3}"
38 if [ "${MSGCOLOR:-YES}" = 'YES' ]; then
39 if [ ! -t 1 ]; then # but check that we output to a terminal
43 if [ "$MSGCOLOR" != 'NO' ]; then
53 if [ -n "$TESTTORUN" ]; then
54 # collecting the output of one test to have it together
56 CURRENTTRAP="rm -f \"$OUTPUT\"; $CURRENTTRAP"
57 trap "$CURRENTTRAP" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
59 if [ "$MSGLEVEL" -le 2 ]; then
60 printf "${CTEST}Testcase
${CHIGH}${TESTTORUN##*/}${CRESET}: "
62 printf "${CTEST}Run Testcase
${CHIGH}${TESTTORUN##*/}${CRESET}\n"
64 if ! "$TESTTORUN"; then
66 if [ "$MSGLEVEL" -le 2 ]; then
67 printf >&2 "\n${CHIGH}Running
${TESTTORUN##*/} -> FAILED
${CRESET}"
69 echo >&2 "${CHIGH}Running
${TESTTORUN##*/} -> FAILED
${CRESET}"
72 if [ "$MSGLEVEL" -le 2 ]; then
76 # without we end up getting stepped output 'randomly'
80 if [ "$FAIL" = 'yes' ]; then
91 DIR="$(readlink -f "$(dirname "$0")")"
93 TESTLIST
="$(find . -mindepth 1 -maxdepth 1 -regex '^\./test-[^/]*$' | sort)"
94 if [ -n "$APT_TEST_JOBS" ]; then
95 if [ "$MSGCOLOR" != 'NO' ]; then
96 export MSGCOLOR
='ALWAYS'
98 exec parallel
-j "$APT_TEST_JOBS" "./$(basename "$0")" -- $(echo "$TESTLIST")
100 TOTAL
="$(echo "$TESTLIST" | wc -l)"
101 for testcase
in $TESTLIST; do
102 if [ "$MSGLEVEL" -le 2 ]; then
103 printf "($(($ALL+1))/${TOTAL}) ${CTEST}Testcase ${CHIGH}${testcase##*/}${CRESET}: "
105 printf "${CTEST}Run Testcase ($(($ALL+1))/${TOTAL}) ${CHIGH}${testcase##*/}${CRESET}\n"
107 if ! ${testcase}; then
109 FAILED_TESTS
="$FAILED_TESTS ${testcase##*/}"
110 if [ "$MSGLEVEL" -le 2 ]; then
111 printf >&2 "\n${CHIGH}Running ${testcase##*/} -> FAILED${CRESET}"
113 echo >&2 "${CHIGH}Running ${testcase##*/} -> FAILED${CRESET}"
119 if [ "$MSGLEVEL" -le 2 ]; then
124 echo >&2 "Statistics: $ALL tests were run: $PASS successfully and $FAIL failed"
125 if [ -n "$FAILED_TESTS" ]; then
126 echo >&2 "Failed tests: $FAILED_TESTS"
128 echo >&2 'All tests seem to have been run successfully. What could possibly go wrong?'
130 # ensure we don't overflow
131 exit $((FAIL <= 255 ? FAIL : 255))