From 6a3ddad78729af4386c4adc68ff69581e494349c Mon Sep 17 00:00:00 2001 From: Ingo Karkat Date: Fri, 27 Apr 2012 21:58:07 +0200 Subject: [PATCH] FIX: test-lib: Print differences when test_expect_output fails. When the command-under-test fails with a non-zero exit code, neither the different exit code nor any output differences are printed. Also, there's a lot of duplication between test_expect_output and test_expect_code_and_output. So, let's fix both by delegating the first to the latter. --- tests/test-lib.sh | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/tests/test-lib.sh b/tests/test-lib.sh index cf197be..79d58f8 100644 --- a/tests/test-lib.sh +++ b/tests/test-lib.sh @@ -264,25 +264,7 @@ test_expect_success () { test_expect_output () { test "$#" = 2 || error "bug in the test script: not 2 parameters to test-expect-output" - if ! test_skip "$@" - then - say >&3 "expecting success and output: $2" - test_run_ "$2" - if [ "$?" = 0 -a "$eval_ret" = 0 ] - then - cmp_output=$(test_cmp expect output) - if [ "$?" = 0 ] - then - test_ok_ "$1" - else - test_failure_ "$@" " -$cmp_output" - fi - else - test_failure_ "$@" - fi - fi - echo >&3 "" + test_expect_code_and_output 0 "$@" } test_expect_code_and_output () { @@ -290,7 +272,11 @@ test_expect_code_and_output () { error "bug in the test script: not 3 parameters to test-expect-code-and-output" if ! test_skip "$@" then - say >&3 "expecting exit code $1 and output: $3" + if [ "$1" = 0 ]; then + say >&3 "expecting success and output: $3" + else + say >&3 "expecting exit code $1 and output: $3" + fi test_run_ "$3" if [ "$?" = 0 -a "$eval_ret" = "$1" ] then