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.
This commit is contained in:
@@ -264,25 +264,7 @@ test_expect_success () {
|
|||||||
test_expect_output () {
|
test_expect_output () {
|
||||||
test "$#" = 2 ||
|
test "$#" = 2 ||
|
||||||
error "bug in the test script: not 2 parameters to test-expect-output"
|
error "bug in the test script: not 2 parameters to test-expect-output"
|
||||||
if ! test_skip "$@"
|
test_expect_code_and_output 0 "$@"
|
||||||
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 () {
|
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"
|
error "bug in the test script: not 3 parameters to test-expect-code-and-output"
|
||||||
if ! test_skip "$@"
|
if ! test_skip "$@"
|
||||||
then
|
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"
|
test_run_ "$3"
|
||||||
if [ "$?" = 0 -a "$eval_ret" = "$1" ]
|
if [ "$?" = 0 -a "$eval_ret" = "$1" ]
|
||||||
then
|
then
|
||||||
|
|||||||
Reference in New Issue
Block a user