Просмотр исходного кода

tests: refactor printing of the quiet failure header

Git-Dch: Ignore
David Kalnischkies лет назад: 11
Родитель
Сommit
1501a2c9d8
1 измененных файлов с 29 добавлено и 44 удалено
  1. 29 44
      test/integration/framework

+ 29 - 44
test/integration/framework

@@ -64,31 +64,26 @@ msgninfo() { msgprintf "${CINFO}I: %s" '%s' "${CNORMAL}" "$@"; }
 msgndebug() { msgprintf "${CDEBUG}D: %s" '%s' "${CNORMAL}" "$@"; }
 msgndebug() { msgprintf "${CDEBUG}D: %s" '%s' "${CNORMAL}" "$@"; }
 msgtest() { msgprintf "${CINFO}%s" "${CCMD}%s${CINFO}" "…${CNORMAL} " "$@"; }
 msgtest() { msgprintf "${CINFO}%s" "${CCMD}%s${CINFO}" "…${CNORMAL} " "$@"; }
 msgpass() { printf "${CPASS}PASS${CNORMAL}\n"; }
 msgpass() { printf "${CPASS}PASS${CNORMAL}\n"; }
-msgskip() {
+msgreportheader() {
 	if [ -n "$MSGTEST_MSG" ]; then
 	if [ -n "$MSGTEST_MSG" ]; then
+		test "$1" != 'msgfailoutput' || echo
 		if [ -n "$MSGTEST_MSGMSG" ]; then
 		if [ -n "$MSGTEST_MSGMSG" ]; then
 			echo "$MSGTEST_MSGMSG"
 			echo "$MSGTEST_MSGMSG"
 		fi
 		fi
 		if [ -n "$MSGTEST_GRP" ] && [ "$MSGTEST_GRP" != 'NEXT' ] && [ "$MSGTEST_GRP" != "$MSGTEST_MSG" ]; then
 		if [ -n "$MSGTEST_GRP" ] && [ "$MSGTEST_GRP" != 'NEXT' ] && [ "$MSGTEST_GRP" != "$MSGTEST_MSG" ]; then
-			echo "Part of the test group: $MSGTEST_GRP"
+			echo "${CFAIL}Part of the test group: $MSGTEST_GRP"
 		fi
 		fi
 		echo -n "$MSGTEST_MSG"
 		echo -n "$MSGTEST_MSG"
 		unset MSGTEST_MSG
 		unset MSGTEST_MSG
 	fi
 	fi
+}
+msgskip() {
+	msgreportheader 'msgskip'
 	if [ $# -gt 0 ]; then printf "${CWARNING}SKIP: $*${CNORMAL}\n" >&2;
 	if [ $# -gt 0 ]; then printf "${CWARNING}SKIP: $*${CNORMAL}\n" >&2;
 	else printf "${CWARNING}SKIP${CNORMAL}\n" >&2; fi
 	else printf "${CWARNING}SKIP${CNORMAL}\n" >&2; fi
 }
 }
 msgfail() {
 msgfail() {
-	if [ -n "$MSGTEST_MSG" ]; then
-		if [ -n "$MSGTEST_MSGMSG" ]; then
-			echo "$MSGTEST_MSGMSG"
-		fi
-		if [ -n "$MSGTEST_GRP" ] && [ "$MSGTEST_GRP" != 'NEXT' ] && [ "$MSGTEST_GRP" != "$MSGTEST_MSG" ]; then
-			echo "Part of the test group: $MSGTEST_GRP"
-		fi
-		echo -n "$MSGTEST_MSG"
-		unset MSGTEST_MSG
-	fi
+	msgreportheader 'msgfail'
 	if [ $# -gt 0 ] && [ -n "$1" ]; then printf "${CFAIL}FAIL: $*${CNORMAL}\n" >&2;
 	if [ $# -gt 0 ] && [ -n "$1" ]; then printf "${CFAIL}FAIL: $*${CNORMAL}\n" >&2;
 	else printf "${CFAIL}FAIL${CNORMAL}\n" >&2; fi
 	else printf "${CFAIL}FAIL${CNORMAL}\n" >&2; fi
 	if [ -n "$APT_DEBUG_TESTS" ]; then
 	if [ -n "$APT_DEBUG_TESTS" ]; then
@@ -1266,7 +1261,7 @@ testoutputequal() {
 }
 }
 
 
 testfileequal() {
 testfileequal() {
-	msggroup "$0"
+	msggroup 'testfileequal'
 	local MSG='Test for correctness of file'
 	local MSG='Test for correctness of file'
 	if [ "$1" = '--nomsg' ]; then
 	if [ "$1" = '--nomsg' ]; then
 		MSG=''
 		MSG=''
@@ -1287,7 +1282,7 @@ testfileequal() {
 }
 }
 
 
 testempty() {
 testempty() {
-	msggroup "$0"
+	msggroup 'testempty'
 	msgtest "Test for no output of" "$*"
 	msgtest "Test for no output of" "$*"
 	local COMPAREFILE="${TMPWORKINGDIRECTORY}/rootdir/tmp/testempty.comparefile"
 	local COMPAREFILE="${TMPWORKINGDIRECTORY}/rootdir/tmp/testempty.comparefile"
 	if "$@" >$COMPAREFILE 2>&1 && test ! -s $COMPAREFILE; then
 	if "$@" >$COMPAREFILE 2>&1 && test ! -s $COMPAREFILE; then
@@ -1300,7 +1295,7 @@ testempty() {
 }
 }
 
 
 testequal() {
 testequal() {
-	msggroup "$0"
+	msggroup 'testequal'
 	local MSG='Test of equality of'
 	local MSG='Test of equality of'
 	if [ "$1" = '--nomsg' ]; then
 	if [ "$1" = '--nomsg' ]; then
 		MSG=''
 		MSG=''
@@ -1320,7 +1315,7 @@ testequal() {
 }
 }
 
 
 testequalor2() {
 testequalor2() {
-	msggroup "$0"
+	msggroup 'testequalor2'
 	local COMPAREFILE1="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequalor2.comparefile1"
 	local COMPAREFILE1="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequalor2.comparefile1"
 	local COMPAREFILE2="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequalor2.comparefile2"
 	local COMPAREFILE2="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequalor2.comparefile2"
 	local COMPAREAGAINST="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequalor2.compareagainst"
 	local COMPAREAGAINST="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequalor2.compareagainst"
@@ -1346,7 +1341,7 @@ testequalor2() {
 }
 }
 
 
 testshowvirtual() {
 testshowvirtual() {
-	msggroup "$0"
+	msggroup 'testshowvirtual'
 	local VIRTUAL="N: Can't select versions from package '$1' as it is purely virtual"
 	local VIRTUAL="N: Can't select versions from package '$1' as it is purely virtual"
 	local PACKAGE="$1"
 	local PACKAGE="$1"
 	shift
 	shift
@@ -1368,7 +1363,7 @@ N: No packages found"
 }
 }
 
 
 testnopackage() {
 testnopackage() {
-	msggroup "$0"
+	msggroup 'testnopackage'
 	msgtest "Test for non-existent packages" "apt-cache show $*"
 	msgtest "Test for non-existent packages" "apt-cache show $*"
 	local SHOWPKG="$(aptcache show "$@" 2>&1 | grep '^Package: ')"
 	local SHOWPKG="$(aptcache show "$@" 2>&1 | grep '^Package: ')"
 	if [ -n "$SHOWPKG" ]; then
 	if [ -n "$SHOWPKG" ]; then
@@ -1382,7 +1377,7 @@ testnopackage() {
 }
 }
 
 
 testdpkgstatus() {
 testdpkgstatus() {
-	msggroup "$0"
+	msggroup 'testdpkgstatus'
 	local STATE="$1"
 	local STATE="$1"
 	local NR="$2"
 	local NR="$2"
 	shift 2
 	shift 2
@@ -1400,19 +1395,19 @@ testdpkgstatus() {
 }
 }
 
 
 testdpkginstalled() {
 testdpkginstalled() {
-	msggroup "$0"
+	msggroup 'testdpkginstalled'
 	testdpkgstatus 'ii' "$#" "$@"
 	testdpkgstatus 'ii' "$#" "$@"
 	msggroup
 	msggroup
 }
 }
 
 
 testdpkgnotinstalled() {
 testdpkgnotinstalled() {
-	msggroup "$0"
+	msggroup 'testdpkgnotinstalled'
 	testdpkgstatus 'ii' '0' "$@"
 	testdpkgstatus 'ii' '0' "$@"
 	msggroup
 	msggroup
 }
 }
 
 
 testmarkedauto() {
 testmarkedauto() {
-	msggroup "$0"
+	msggroup 'testmarkedauto'
 	local COMPAREFILE="${TMPWORKINGDIRECTORY}/rootdir/tmp/testmarkedauto.comparefile"
 	local COMPAREFILE="${TMPWORKINGDIRECTORY}/rootdir/tmp/testmarkedauto.comparefile"
 	if [ -n "$1" ]; then
 	if [ -n "$1" ]; then
 		msgtest 'Test for correctly marked as auto-installed' "$*"
 		msgtest 'Test for correctly marked as auto-installed' "$*"
@@ -1425,7 +1420,7 @@ testmarkedauto() {
 	msggroup
 	msggroup
 }
 }
 testmarkedmanual() {
 testmarkedmanual() {
-	msggroup "$0"
+	msggroup 'testmarkedmanual'
 	local COMPAREFILE="${TMPWORKINGDIRECTORY}/rootdir/tmp/testmarkedmanual.comparefile"
 	local COMPAREFILE="${TMPWORKINGDIRECTORY}/rootdir/tmp/testmarkedmanual.comparefile"
 	if [ -n "$1" ]; then
 	if [ -n "$1" ]; then
 		msgtest 'Test for correctly marked as manually installed' "$*"
 		msgtest 'Test for correctly marked as manually installed' "$*"
@@ -1439,17 +1434,7 @@ testmarkedmanual() {
 }
 }
 
 
 msgfailoutput() {
 msgfailoutput() {
-	if [ -n "$MSGTEST_MSG" ]; then
-		echo
-		if [ -n "$MSGTEST_MSGMSG" ]; then
-			echo "$MSGTEST_MSGMSG"
-		fi
-		if [ -n "$MSGTEST_GRP" ] && [ "$MSGTEST_GRP" != 'NEXT' ] && [ "$MSGTEST_GRP" != "$MSGTEST_MSG" ]; then
-			echo "${CFAIL}Part of the test group: $MSGTEST_GRP"
-		fi
-		echo -n "$MSGTEST_MSG"
-		unset MSGTEST_MSG
-	fi
+	msgreportheader 'msgfailoutput'
 	local MSG="$1"
 	local MSG="$1"
 	local OUTPUT="$2"
 	local OUTPUT="$2"
 	shift 2
 	shift 2
@@ -1481,7 +1466,7 @@ msgfailoutput() {
 }
 }
 
 
 testsuccess() {
 testsuccess() {
-	msggroup "$0"
+	msggroup 'testsuccess'
 	if [ "$1" = '--nomsg' ]; then
 	if [ "$1" = '--nomsg' ]; then
 		shift
 		shift
 	else
 	else
@@ -1517,7 +1502,7 @@ testsuccess() {
 	msggroup
 	msggroup
 }
 }
 testwarning() {
 testwarning() {
-	msggroup "$0"
+	msggroup 'testwarning'
 	if [ "$1" = '--nomsg' ]; then
 	if [ "$1" = '--nomsg' ]; then
 		shift
 		shift
 	else
 	else
@@ -1546,7 +1531,7 @@ testwarning() {
 	msggroup
 	msggroup
 }
 }
 testfailure() {
 testfailure() {
-	msggroup "$0"
+	msggroup 'testfailure'
 	if [ "$1" = '--nomsg' ]; then
 	if [ "$1" = '--nomsg' ]; then
 		shift
 		shift
 	else
 	else
@@ -1586,7 +1571,7 @@ testfailure() {
 }
 }
 
 
 testsuccessequal() {
 testsuccessequal() {
-	msggroup "$0"
+	msggroup 'testsuccessequal'
 	local CMP="$1"
 	local CMP="$1"
 	shift
 	shift
 	testsuccess "$@"
 	testsuccess "$@"
@@ -1594,7 +1579,7 @@ testsuccessequal() {
 	msggroup
 	msggroup
 }
 }
 testwarningequal() {
 testwarningequal() {
-	msggroup "$0"
+	msggroup 'testwarningequal'
 	local CMP="$1"
 	local CMP="$1"
 	shift
 	shift
 	testwarning "$@"
 	testwarning "$@"
@@ -1602,7 +1587,7 @@ testwarningequal() {
 	msggroup
 	msggroup
 }
 }
 testfailureequal() {
 testfailureequal() {
-	msggroup "$0"
+	msggroup 'testfailureequal'
 	local CMP="$1"
 	local CMP="$1"
 	shift
 	shift
 	testfailure "$@"
 	testfailure "$@"
@@ -1611,7 +1596,7 @@ testfailureequal() {
 }
 }
 
 
 testfailuremsg() {
 testfailuremsg() {
-	msggroup "$0"
+	msggroup 'testfailuremsg'
 	local CMP="$1"
 	local CMP="$1"
 	shift
 	shift
 	testfailure "$@"
 	testfailure "$@"
@@ -1623,7 +1608,7 @@ testfailuremsg() {
 }
 }
 
 
 testfilestats() {
 testfilestats() {
-	msggroup "$0"
+	msggroup 'testfilestats'
 	msgtest "Test that file $1 has $2 $3" "$4"
 	msgtest "Test that file $1 has $2 $3" "$4"
 	if [ "$4" "$3" "$(stat --format "$2" "$1")" ]; then
 	if [ "$4" "$3" "$(stat --format "$2" "$1")" ]; then
 		msgpass
 		msgpass
@@ -1639,13 +1624,13 @@ testfilestats() {
 	msggroup
 	msggroup
 }
 }
 testaccessrights() {
 testaccessrights() {
-	msggroup "$0"
+	msggroup 'testaccessrights'
 	testfilestats "$1" '%a' '=' "$2"
 	testfilestats "$1" '%a' '=' "$2"
 	msggroup
 	msggroup
 }
 }
 
 
 testwebserverlaststatuscode() {
 testwebserverlaststatuscode() {
-	msggroup "$0"
+	msggroup 'testwebserverlaststatuscode'
 	local DOWNLOG='rootdir/tmp/webserverstatus-testfile.log'
 	local DOWNLOG='rootdir/tmp/webserverstatus-testfile.log'
 	local STATUS='downloaded/webserverstatus-statusfile.log'
 	local STATUS='downloaded/webserverstatus-statusfile.log'
 	rm -f "$DOWNLOG" "$STATUS"
 	rm -f "$DOWNLOG" "$STATUS"