From 8c7af93bde1798da7d59182201b3599158bf926d Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Tue, 16 Mar 2021 02:29:15 -0500 Subject: Add more shell tests, and teach txpect to do regex matches (RO and RE). --- scripts/runtest.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/scripts/runtest.sh b/scripts/runtest.sh index 6aad9ff1..158ed7fa 100644 --- a/scripts/runtest.sh +++ b/scripts/runtest.sh @@ -61,7 +61,7 @@ optional() # Not set? if [ -z "$1" ] || [ -z "$OPTIONFLAGS" ] || [ ${#option} -ne 0 ] then - SKIP="" + unset SKIP return fi SKIP=1 @@ -183,6 +183,8 @@ do_fail() # X means close stdin/stdout/stderr and match return code (blank means nonzero) txpect() { + local NAME CASE VERBOSITY LEN A B + # Run command with redirection through fifos NAME="$CMDNAME $1" CASE= @@ -206,16 +208,18 @@ txpect() LEN=$((${#1}-1)) CASE="$1" A= + B= case ${1::1} in # send input to child I) printf %s "${1:1}" >&$IN || { do_fail;break;} ;; + R) LEN=0; B=1; ;& # check output from child [OE]) [ $LEN == 0 ] && LARG="" || LARG="-rN $LEN" O=$OUT - [ ${1::1} == 'E' ] && O=$ERR + [ "${1:$B:1}" == 'E' ] && O=$ERR A= read -t2 $LARG A <&$O VERBOSITY="$VERBOSITY"$'\n'"$A" @@ -223,8 +227,9 @@ txpect() then [ -z "$A" ] && { do_fail;break;} else - if [ "$A" != "${1:1}" ] - then + if [ ${1::1} == 'R' ] && [[ "$A" =~ "${1:2}" ]]; then true + elif [ ${1::1} != 'R' ] && [ "$A" == "${1:1}" ]; then true + else # Append the rest of the output if there is any. read -t.1 B <&$O A="$A$B" -- cgit v1.2.3