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

tests: collect more details about failed checkdiffs

Git-Dch: Ignore
David Kalnischkies лет назад: 11
Родитель
Сommit
22ac12b2c4
2 измененных файлов с 30 добавлено и 51 удалено
  1. 24 42
      test/integration/framework
  2. 6 9
      test/integration/test-apt-ftparchive-cachedb

+ 24 - 42
test/integration/framework

@@ -66,6 +66,9 @@ msgtest() { msgprintf "${CINFO}%s" "${CCMD}%s${CINFO}" "…${CNORMAL} " "$@"; }
 msgpass() { printf "${CPASS}PASS${CNORMAL}\n"; }
 msgpass() { printf "${CPASS}PASS${CNORMAL}\n"; }
 msgskip() {
 msgskip() {
 	if [ -n "$MSGTEST_MSG" ]; then
 	if [ -n "$MSGTEST_MSG" ]; then
+		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"
 		echo -n "$MSGTEST_MSG"
 		unset MSGTEST_MSG
 		unset MSGTEST_MSG
 	fi
 	fi
@@ -1241,6 +1244,19 @@ checkdiff() {
 	fi
 	fi
 }
 }
 
 
+testoutputequal() {
+	local OUTPUT="${TMPWORKINGDIRECTORY}/rootdir/tmp/testoutputequal.output"
+	local COMPAREFILE="$1"
+	shift
+	if "$@" 2>&1 | checkdiff $COMPAREFILE - >"$OUTPUT" 2>&1; then
+		msgpass
+	else
+		echo "=== content of file we compared with (${COMPAREFILE}) ===" >>"${OUTPUT}"
+		cat "$COMPAREFILE" >>"${OUTPUT}"
+		msgfailoutput '' "$OUTPUT" "$@"
+	fi
+}
+
 testfileequal() {
 testfileequal() {
 	msggroup "$0"
 	msggroup "$0"
 	local MSG='Test for correctness of file'
 	local MSG='Test for correctness of file'
@@ -1255,17 +1271,9 @@ testfileequal() {
 	fi
 	fi
 	local OUTPUT="${TMPWORKINGDIRECTORY}/rootdir/tmp/testfileequal.output"
 	local OUTPUT="${TMPWORKINGDIRECTORY}/rootdir/tmp/testfileequal.output"
 	if [ -z "$*" ]; then
 	if [ -z "$*" ]; then
-		if echo -n "" | checkdiff - $FILE >"$OUTPUT" 2>&1; then
-			msgpass
-		else
-			msgfailoutput '' "$OUTPUT"
-		fi
+		testoutputequal "$FILE" echo -n ''
 	else
 	else
-		if echo "$*" | checkdiff - $FILE >"$OUTPUT" 2>&1; then
-			msgpass
-		else
-			msgfailoutput '' "$OUTPUT"
-		fi
+		testoutputequal "$FILE" echo "$*"
 	fi
 	fi
 	msggroup
 	msggroup
 }
 }
@@ -1277,7 +1285,7 @@ testempty() {
 	if "$@" >$COMPAREFILE 2>&1 && test ! -s $COMPAREFILE; then
 	if "$@" >$COMPAREFILE 2>&1 && test ! -s $COMPAREFILE; then
 		msgpass
 		msgpass
 	else
 	else
-		msgfailoutput '' "$COMPAREFILE"
+		msgfailoutput '' "$COMPAREFILE" "$@"
 	fi
 	fi
 	aptautotest 'testempty' "$@"
 	aptautotest 'testempty' "$@"
 	msggroup
 	msggroup
@@ -1298,12 +1306,7 @@ testequal() {
 	if [ -n "$MSG" ]; then
 	if [ -n "$MSG" ]; then
 		msgtest "$MSG" "$*"
 		msgtest "$MSG" "$*"
 	fi
 	fi
-	local OUTPUT="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequal.output"
-	if "$@" 2>&1 | checkdiff $COMPAREFILE - >"$OUTPUT" 2>&1; then
-		msgpass
-	else
-		msgfailoutput '' "$OUTPUT"
-	fi
+	testoutputequal "$COMPAREFILE" "$@"
 	aptautotest 'testequal' "$@"
 	aptautotest 'testequal' "$@"
 	msggroup
 	msggroup
 }
 }
@@ -1352,11 +1355,7 @@ N: No packages found"
 	local ARCH="$(getarchitecture 'native')"
 	local ARCH="$(getarchitecture 'native')"
 	echo "$VIRTUAL" | sed -e "s/:$ARCH//" -e 's/:all//' >"$COMPAREFILE"
 	echo "$VIRTUAL" | sed -e "s/:$ARCH//" -e 's/:all//' >"$COMPAREFILE"
 	local OUTPUT="${TMPWORKINGDIRECTORY}/rootdir/tmp/testshowvirtual.output"
 	local OUTPUT="${TMPWORKINGDIRECTORY}/rootdir/tmp/testshowvirtual.output"
-	if aptcache show -q=0 "$PACKAGE" 2>&1 | checkdiff "$COMPAREFILE" - >"$OUTPUT" 2>&1; then
-		msgpass
-	else
-		msgfailoutput '' "$OUTPUT"
-	fi
+	testoutputequal "$COMPAREFILE" aptcache show -q=0 "$PACKAGE"
 	msggroup
 	msggroup
 }
 }
 
 
@@ -1414,12 +1413,7 @@ testmarkedauto() {
 		msgtest 'Test for correctly marked as auto-installed' 'no package'
 		msgtest 'Test for correctly marked as auto-installed' 'no package'
 		echo -n > $COMPAREFILE
 		echo -n > $COMPAREFILE
 	fi
 	fi
-	local OUTPUT="${TMPWORKINGDIRECTORY}/rootdir/tmp/testmarkedauto.output"
-	if aptmark showauto 2>&1 | checkdiff $COMPAREFILE - >"$OUTPUT" 2>&1; then
-		msgpass
-	else
-		msgfailoutput '' "$OUTPUT"
-	fi
+	testoutputequal "$COMPAREFILE" aptmark showauto
 	msggroup
 	msggroup
 }
 }
 testmarkedmanual() {
 testmarkedmanual() {
@@ -1432,12 +1426,7 @@ testmarkedmanual() {
 		msgtest 'Test for correctly marked as manually installed' 'no package'
 		msgtest 'Test for correctly marked as manually installed' 'no package'
 		echo -n > $COMPAREFILE
 		echo -n > $COMPAREFILE
 	fi
 	fi
-	local OUTPUT="${TMPWORKINGDIRECTORY}/rootdir/tmp/testmarkedmanual.output"
-	if aptmark showmanual 2>&1 | checkdiff $COMPAREFILE - >"$OUTPUT" 2>&1; then
-		msgpass
-	else
-		msgfailoutput '' "$OUTPUT"
-	fi
+	testoutputequal "$COMPAREFILE" aptmark showmanual
 	msggroup
 	msggroup
 }
 }
 
 
@@ -1618,14 +1607,7 @@ testfailuremsg() {
 	msgtest 'Check that the output of the previous failed command has expected' 'failures and warnings'
 	msgtest 'Check that the output of the previous failed command has expected' 'failures and warnings'
 	local COMPAREFILE="${TMPWORKINGDIRECTORY}/rootdir/tmp/testfailuremsg.comparefile"
 	local COMPAREFILE="${TMPWORKINGDIRECTORY}/rootdir/tmp/testfailuremsg.comparefile"
 	grep '^\(W\|E\):' "${TMPWORKINGDIRECTORY}/rootdir/tmp/testfailure.output" > "$COMPAREFILE" 2>&1 || true
 	grep '^\(W\|E\):' "${TMPWORKINGDIRECTORY}/rootdir/tmp/testfailure.output" > "$COMPAREFILE" 2>&1 || true
-	local OUTPUT="${TMPWORKINGDIRECTORY}/rootdir/tmp/testfailuremsg.output"
-	if echo "$CMP" | checkdiff - "${COMPAREFILE}" >"$OUTPUT" 2>&1; then
-		msgpass
-	else
-		echo '### Complete output ###' >"$OUTPUT"
-		cat "${TMPWORKINGDIRECTORY}/rootdir/tmp/testfailure.output" >"$OUTPUT"
-		msgfailoutput '' "$OUTPUT"
-	fi
+	testoutputequal "$COMPAREFILE" echo "$CMP"
 	msggroup
 	msggroup
 }
 }
 
 

+ 6 - 9
test/integration/test-apt-ftparchive-cachedb

@@ -73,18 +73,16 @@ testsuccess aptftparchive generate ftparchive.conf -q=0 -o APT::FTPArchive::Show
 cp rootdir/tmp/testsuccess.output stats-out.txt
 cp rootdir/tmp/testsuccess.output stats-out.txt
 ensure_correct_packages_file
 ensure_correct_packages_file
 ensure_correct_contents_file
 ensure_correct_contents_file
-testsuccess grep Misses stats-out.txt
-testfileequal 'rootdir/tmp/testsuccess.output' ' Misses in Cache: 2
- dists/test/Contents-i386: New 402 B  Misses in Cache: 0'
+testsuccessequal ' Misses in Cache: 2
+ dists/test/Contents-i386: New 402 B  Misses in Cache: 0' grep Misses stats-out.txt
 
 
 # generate again
 # generate again
 testsuccess aptftparchive generate ftparchive.conf -q=0 -o APT::FTPArchive::ShowCacheMisses=1
 testsuccess aptftparchive generate ftparchive.conf -q=0 -o APT::FTPArchive::ShowCacheMisses=1
 cp rootdir/tmp/testsuccess.output stats-out.txt
 cp rootdir/tmp/testsuccess.output stats-out.txt
 ensure_correct_packages_file
 ensure_correct_packages_file
 ensure_correct_contents_file
 ensure_correct_contents_file
-testsuccess grep Misses stats-out.txt
-testfileequal 'rootdir/tmp/testsuccess.output' ' Misses in Cache: 0
- dists/test/Contents-i386:  Misses in Cache: 0'
+testsuccessequal ' Misses in Cache: 0
+ dists/test/Contents-i386:  Misses in Cache: 0' grep Misses stats-out.txt
 
 
 # and again (with removing the Packages file)
 # and again (with removing the Packages file)
 rm -f ./aptarchive/dists/test/main/binary-i386/*
 rm -f ./aptarchive/dists/test/main/binary-i386/*
@@ -93,9 +91,8 @@ testsuccess aptftparchive generate ftparchive.conf -q=0 -o APT::FTPArchive::Show
 cp rootdir/tmp/testsuccess.output stats-out.txt
 cp rootdir/tmp/testsuccess.output stats-out.txt
 ensure_correct_packages_file
 ensure_correct_packages_file
 ensure_correct_contents_file
 ensure_correct_contents_file
-testsuccess grep Misses stats-out.txt
-testfileequal 'rootdir/tmp/testsuccess.output' ' Misses in Cache: 0
- dists/test/Contents-i386: New 402 B  Misses in Cache: 0'
+testsuccessequal ' Misses in Cache: 0
+ dists/test/Contents-i386: New 402 B  Misses in Cache: 0' grep Misses stats-out.txt
 
 
 # and clean
 # and clean
 rm -rf aptarchive/pool/main/*
 rm -rf aptarchive/pool/main/*