From f06e5dc1665c288071ade1d403f7e7eb4275ae64 Mon Sep 17 00:00:00 2001 From: Björn Persson Date: Thu, 19 Dec 2013 09:29:59 +0100 Subject: better failure reporting --- testsuite/run_tests | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/testsuite/run_tests b/testsuite/run_tests index 38d6562..35fcc23 100755 --- a/testsuite/run_tests +++ b/testsuite/run_tests @@ -37,6 +37,27 @@ export srcdir # testcase's source directory relative to testrundir export builddir # testcase's build directory relative to testrundir export relative_builddir # testcase's build directory relative to srcdir + +pass () { + # Report the current testcase as passed. + echo "${test_name}: PASSED" + passed=$((passed + 1)) +} + + +fail () { + # Report the current testcase as failed. + # Parameters: + # 1: a message about what went wrong + # 2: the name of a file with details about the error + echo "${test_name}: FAILED" + echo "$1" + cat "$2" + echo + failed=$((failed + 1)) +} + + # Clean out any old test results. rm -Rf "${outer_builddir}"/testruns @@ -82,24 +103,17 @@ for source_directory in "${outer_srcdir}"/testsuite/sources/* ; do fi done if [ -s "${testrundir}"/changed_sources ] ; then - verdict=FAILED + fail "Changed soure files:" "${testrundir}"/changed_sources else - verdict=PASSED + pass fi else - verdict=FAILED + fail "Difference from the list of expected files:" files.diff fi else - # The test returned an error code. - verdict=FAILED + fail "Error code: $?" output fi - if [ ${verdict} = PASSED ] ; then - passed=$((passed + 1)) - else - failed=$((failed + 1)) - fi - echo "${test_name}: ${verdict}" done done done -- cgit v1.2.3