| 1 |
From: Håvard F. Aasen <[email protected]> |
| 2 |
Date: Tue, 27 Sep 2022 20:14:08 +0200 |
| 3 |
Subject: [PATCH] tests: Fix reporting of test failures |
| 4 |
|
| 5 |
After commit a4afb898f7758160acda71d774c7d98d528da273 the testsuite |
| 6 |
no longer reported test failures. This is because we rely on the exit |
| 7 |
status code of the script, and currently, this is always 0. |
| 8 |
|
| 9 |
If any test fails, we will exit with status code 2. The entire testsuite |
| 10 |
will continue to run, even after a test has failed. |
| 11 |
|
| 12 |
Forwarded: https://github.com/rpm-software-management/popt/pull/83 |
| 13 |
Applied-Upstream: https://github.com/rpm-software-management/popt/commit/ce80a8045c70db57084008a3fd98a7f0ba79544e |
| 14 |
--- |
| 15 |
tests/testit.sh | 10 +++++++++- |
| 16 |
1 file changed, 9 insertions(+), 1 deletion(-) |
| 17 |
|
| 18 |
diff --git a/tests/testit.sh b/tests/testit.sh |
| 19 |
index 04713f5..26724d6 100755 |
| 20 |
--- a/tests/testit.sh |
| 21 |
+++ b/tests/testit.sh |
| 22 |
@@ -8,6 +8,7 @@ run() { |
| 23 |
result=`HOME=$builddir $builddir/$prog $*` |
| 24 |
if [ "$answer" != "$result" ]; then |
| 25 |
echo "FAIL: $name: \"$result\" != \"$answer\" " |
| 26 |
+ retval=2 |
| 27 |
else |
| 28 |
echo "PASS: $name" |
| 29 |
fi |
| 30 |
@@ -30,6 +31,7 @@ run_diff() { |
| 31 |
if [ "$diff_ret" != "0" ]; then |
| 32 |
echo "FAIL $name: failed output is in $out, diff is:" |
| 33 |
cat $diff_file |
| 34 |
+ retval=2 |
| 35 |
else |
| 36 |
echo "PASS $name" |
| 37 |
fi |
| 38 |
@@ -37,6 +39,7 @@ run_diff() { |
| 39 |
} |
| 40 |
|
| 41 |
builddir=`pwd` |
| 42 |
+retval=0 |
| 43 |
cd ${builddir} |
| 44 |
echo "Running tests in ${builddir}" |
| 45 |
|
| 46 |
@@ -181,4 +184,9 @@ run_diff test3 "test3 - 2" test3-data/02.input test3-data/02.answer |
| 47 |
run_diff test3 "test3 - 3" test3-data/03.input test3-data/03.answer |
| 48 |
|
| 49 |
echo "" |
| 50 |
-echo "Passed." |
| 51 |
+if [ $retval != 0 ]; then |
| 52 |
+ echo "Failed." |
| 53 |
+ exit $retval |
| 54 |
+else |
| 55 |
+ echo "Passed." |
| 56 |
+fi |