commit: ee7d8eb47d2ed1e4d7a671c0892d7ef2c827bd37
parent 8094982e862e5da8850aef0d4e3299819d233a88
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Thu, 1 Aug 2024 03:13:27 +0200
selfcheck.sh: Change main loop into a normal loop for err=1
Otherwise as a pipeline, err=1 doesn't ends up setting the global $err
(At least with oksh)
Diffstat:
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/selfcheck.sh b/selfcheck.sh
@@ -8,9 +8,16 @@ WD="$(realpath "$(dirname "$0")")"
tmpdir=
err=0
+run_test() {
+ env MALLOC_CHECK_=3 POSIX_ME_HARDER=1 POSIXLY_CORRECT=1 LC_ALL=C.UTF-8 "$1" 2>&1
+ return $?
+}
+
cd "$WD"
-printf '%s\n' test-cmd/*.sh | while read runner
+rm "${WD}/selfcheck.out"
+
+for runner in test-cmd/*.sh
do
[ "$runner" = "test-cmd/tap.sh" ] && continue
echo "${PS4}${runner}"
@@ -22,8 +29,11 @@ do
cd "$tmpdir"
fi
- if ! env MALLOC_CHECK_=3 POSIX_ME_HARDER=1 POSIXLY_CORRECT=1 LC_ALL=C.UTF-8 "${WD}/${runner}" 2>&1
+ run_test "${WD}/${runner}" | tee -a "$WD/selfcheck.out" | grep -v '^ok'
+ ret="$?"
+ if [ "$ret" != 0 ]
then
+ printf '## %s exited with code %s\n' "$runner" "$ret"
err=1
fi
@@ -33,9 +43,10 @@ do
if ! rm -d "$tmpdir"
then
printf '## Error: %s left files:\n%s\n' "$runner" "$(ls -R "$tmpdir")"
+ err=1
fi
fi
-done | tee selfcheck.out | grep -v '^ok'
+done
-[ $err = 0 ] && rm selfcheck.out
+[ $err = 0 ] && rm "${WD}/selfcheck.out"
exit $err