Parcourir la source

tests: fail testsuccess if notices are shown, too

Notices are just hints, but if they are printed in tests, they should be
expected and if not the test should fail. No current test has this
problem, so that is just potential future proving.

Git-Dch: Ignore
David Kalnischkies il y a 10 ans
Parent
commit
671a55ba45
1 fichiers modifiés avec 50 ajouts et 16 suppressions
  1. 50 16
      test/integration/framework

+ 50 - 16
test/integration/framework

@@ -1522,19 +1522,22 @@ msgfailoutput() {
 	msgfail "$MSG"
 	msgfail "$MSG"
 }
 }
 
 
-testsuccess() {
-	msggroup 'testsuccess'
+testsuccesswithglobalerror() {
+	local TYPE="$1"
+	local ERRORS="$2"
+	shift 2
+	msggroup "$TYPE"
 	if [ "$1" = '--nomsg' ]; then
 	if [ "$1" = '--nomsg' ]; then
 		shift
 		shift
 	else
 	else
 		msgtest 'Test for successful execution of' "$*"
 		msgtest 'Test for successful execution of' "$*"
 	fi
 	fi
-	local OUTPUT="${TMPWORKINGDIRECTORY}/rootdir/tmp/testsuccess.output"
+	local OUTPUT="${TMPWORKINGDIRECTORY}/rootdir/tmp/${TYPE}.output"
 	if "$@" >"${OUTPUT}" 2>&1; then
 	if "$@" >"${OUTPUT}" 2>&1; then
 		if expr match "$1" '^apt.*' >/dev/null; then
 		if expr match "$1" '^apt.*' >/dev/null; then
 			if grep -q -E ' runtime error: ' "$OUTPUT"; then
 			if grep -q -E ' runtime error: ' "$OUTPUT"; then
 				msgfailoutput 'compiler detected undefined behavior' "$OUTPUT" "$@"
 				msgfailoutput 'compiler detected undefined behavior' "$OUTPUT" "$@"
-			elif grep -E '^[WE]: ' "$OUTPUT" > "${TMPWORKINGDIRECTORY}/rootdir/tmp/checkforwarnings.output" 2>&1; then
+			elif grep -E "^[${ERRORS}]: " "$OUTPUT" > "${TMPWORKINGDIRECTORY}/rootdir/tmp/checkforwarnings.output" 2>&1; then
 				if [ "$IGNORE_PTY_NOT_MOUNTED" = '1' ]; then
 				if [ "$IGNORE_PTY_NOT_MOUNTED" = '1' ]; then
 					if echo 'E: Can not write log (Is /dev/pts mounted?) - posix_openpt (2: No such file or directory)' \
 					if echo 'E: Can not write log (Is /dev/pts mounted?) - posix_openpt (2: No such file or directory)' \
 						| cmp - "${TMPWORKINGDIRECTORY}/rootdir/tmp/checkforwarnings.output" >/dev/null 2>&1; then
 						| cmp - "${TMPWORKINGDIRECTORY}/rootdir/tmp/checkforwarnings.output" >/dev/null 2>&1; then
@@ -1545,6 +1548,12 @@ testsuccess() {
 				else
 				else
 					msgfailoutput 'successful run, but output contains warnings/errors' "$OUTPUT" "$@"
 					msgfailoutput 'successful run, but output contains warnings/errors' "$OUTPUT" "$@"
 				fi
 				fi
+			elif [ "$TYPE" = 'testsuccesswithnotice' ]; then
+				if grep -q -E "^N: " "$OUTPUT"; then
+					msgpass
+				else
+					msgfailoutput 'successful run, but output had no notices' "$OUTPUT" "$@"
+				fi
 			else
 			else
 				msgpass
 				msgpass
 			fi
 			fi
@@ -1555,9 +1564,15 @@ testsuccess() {
 		local EXITCODE=$?
 		local EXITCODE=$?
 		msgfailoutput "exitcode $EXITCODE" "$OUTPUT" "$@"
 		msgfailoutput "exitcode $EXITCODE" "$OUTPUT" "$@"
 	fi
 	fi
-	aptautotest 'testsuccess' "$@"
+	aptautotest "$TYPE" "$@"
 	msggroup
 	msggroup
 }
 }
+testsuccesswithnotice() {
+	testsuccesswithglobalerror 'testsuccesswithnotice' 'WE' "$@"
+}
+testsuccess() {
+	testsuccesswithglobalerror 'testsuccess' 'NWE' "$@"
+}
 testwarning() {
 testwarning() {
 	msggroup 'testwarning'
 	msggroup 'testwarning'
 	if [ "$1" = '--nomsg' ]; then
 	if [ "$1" = '--nomsg' ]; then
@@ -1629,22 +1644,41 @@ testfailure() {
 
 
 testreturnstateequal() {
 testreturnstateequal() {
 	local STATE="$1"
 	local STATE="$1"
-	msggroup "${STATE}equal"
-	if [ "$2" != '--nomsg' ]; then
-		local CMP="$2"
-		shift 2
-		"$STATE" "$@"
-		testfileequal "${TMPWORKINGDIRECTORY}/rootdir/tmp/${STATE}.output" "$CMP"
-	else
-		local CMP="$3"
+	if [ "$STATE" = 'testsuccesswithglobalerror' ]; then
+		local STATE="$2"
+		local TYPE="$3"
 		shift 3
 		shift 3
-		"$STATE" --nomsg "$@"
-		testfileequal "${TMPWORKINGDIRECTORY}/rootdir/tmp/${STATE}.output" "$CMP"
+		msggroup "${STATE}equal"
+		if [ "$1" != '--nomsg' ]; then
+			local CMP="$1"
+			shift
+			testsuccesswithglobalerror "$STATE" "$TYPE" "$@"
+			testfileequal "${TMPWORKINGDIRECTORY}/rootdir/tmp/${STATE}.output" "$CMP"
+		else
+			local CMP="$2"
+			shift 2
+			testsuccesswithglobalerror "$STATE" "$TYPE" "$@"
+			testfileequal "${TMPWORKINGDIRECTORY}/rootdir/tmp/${STATE}.output" "$CMP"
+		fi
+	else
+		msggroup "${STATE}equal"
+		if [ "$2" != '--nomsg' ]; then
+			local CMP="$2"
+			shift 2
+			"$STATE" "$@"
+			testfileequal "${TMPWORKINGDIRECTORY}/rootdir/tmp/${STATE}.output" "$CMP"
+		else
+			local CMP="$3"
+			shift 3
+			"$STATE" --nomsg "$@"
+			testfileequal "${TMPWORKINGDIRECTORY}/rootdir/tmp/${STATE}.output" "$CMP"
+		fi
 	fi
 	fi
 	msggroup
 	msggroup
 }
 }
 testsuccessequal() {
 testsuccessequal() {
-	testreturnstateequal 'testsuccess' "$@"
+	# we compare output, so we know perfectly well about N:
+	testreturnstateequal 'testsuccesswithglobalerror' 'testsuccess' 'WE' "$@"
 }
 }
 testwarningequal() {
 testwarningequal() {
 	testreturnstateequal 'testwarning' "$@"
 	testreturnstateequal 'testwarning' "$@"