From 25da95b17a1a1f53b338d6c29dbe34a4b9c7669d Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Tue, 5 Jul 2022 00:10:21 -0500 Subject: [PATCH] Use do_pass and do_fail consistently. --- scripts/runtest.sh | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/scripts/runtest.sh b/scripts/runtest.sh index 121becf2..1ca5c579 100644 --- a/scripts/runtest.sh +++ b/scripts/runtest.sh @@ -114,6 +114,19 @@ do_pass() ! verbose_has nopass && printf "%s\n" "$SHOWPASS: $NAME" } +# Announce failure and handle fallout for txpect +do_fail() +{ + FAILCOUNT=$(($FAILCOUNT+1)) + printf "%s\n" "$SHOWFAIL: $NAME" + if [ ! -z "$CASE" ] + then + echo "Expected '$CASE'" + echo "Got '$A'" + fi + ! verbose_has all && exit 1 +} + # The testing function testing() @@ -138,15 +151,12 @@ testing() RETVAL=$? # Catch segfaults - [ $RETVAL -gt 128 ] && [ $RETVAL -lt 255 ] && + [ $RETVAL -gt 128 ] && echo "exited with signal (or returned $RETVAL)" >> actual DIFF="$(diff -au${NOSPACE:+w} expected actual)" if [ -n "$DIFF" ] - then - FAILCOUNT=$(($FAILCOUNT+1)) - printf "%s\n" "$SHOWFAIL: $NAME" - else - ! verbose_has nopass && printf "%s\n" "$SHOWPASS: $NAME" + then do_fail + else do_pass fi if ! verbose_has quiet && { [ -n "$DIFF" ] || verbose_has spam; } then @@ -172,19 +182,6 @@ testcmd() testing "$X" "\"$C\" $2" "$3" "$4" "$5" } -# Announce failure and handle fallout for txpect -do_fail() -{ - FAILCOUNT=$(($FAILCOUNT+1)) - printf "%s\n" "$SHOWFAIL: $NAME" - if [ ! -z "$CASE" ] - then - echo "Expected '$CASE'" - echo "Got '$A'" - fi - ! verbose_has all && exit 1 -} - # txpect NAME COMMAND [I/O/E/Xstring]... # Run COMMAND and interact with it: send I strings to input, read O or E # strings from stdout or stderr (empty string is "read line of input here"), -- 2.39.2