From 4fa34122cbe347d21b3a162ff2fa75dd2e73c3a8 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 20 Oct 2014 10:23:41 +0200 Subject: testcases: do not allow warnings in testsuccess Adds a new testwarning which tests for zero exit and the presents of a warning in the output, failing if either is not the case or if an error is found, too. This allows us to change testsuccess to accept only totally successful executions (= without warnings) which should help finding regressions. Git-Dch: Ignore --- test/integration/framework | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'test/integration/framework') diff --git a/test/integration/framework b/test/integration/framework index 617daa283..9ce300d55 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -1205,12 +1205,43 @@ testsuccess() { msgtest 'Test for successful execution of' "$*" fi local OUTPUT="${TMPWORKINGDIRECTORY}/rootdir/tmp/testsuccess.output" + if "$@" >${OUTPUT} 2>&1; then + if expr match "$1" '^apt.*' >/dev/null; then + if grep -q -E '^[WE]: ' "$OUTPUT"; then + echo >&2 + cat >&2 $OUTPUT + msgfail 'successful run, but output contains warnings/errors' + else + msgpass + fi + else + msgpass + fi + else + local EXITCODE=$? + echo >&2 + cat >&2 $OUTPUT + msgfail "exitcode $EXITCODE" + fi + aptautotest 'testsuccess' "$@" +} +testwarning() { + if [ "$1" = '--nomsg' ]; then + shift + else + msgtest 'Test for successful execution with warnings of' "$*" + fi + local OUTPUT="${TMPWORKINGDIRECTORY}/rootdir/tmp/testsuccess.output" if "$@" >${OUTPUT} 2>&1; then if expr match "$1" '^apt.*' >/dev/null; then if grep -q -E '^E: ' "$OUTPUT"; then echo >&2 cat >&2 $OUTPUT msgfail 'successful run, but output contains errors' + elif ! grep -q -E '^W: ' "$OUTPUT"; then + echo >&2 + cat >&2 $OUTPUT + msgfail 'successful run, but output contains no warnings' else msgpass fi @@ -1223,9 +1254,8 @@ testsuccess() { cat >&2 $OUTPUT msgfail "exitcode $EXITCODE" fi - aptautotest 'testsuccess' "$@" + aptautotest 'testwarning' "$@" } - testfailure() { if [ "$1" = '--nomsg' ]; then shift -- cgit v1.2.3