diff options
Diffstat (limited to 'Test/ztst.zsh')
-rwxr-xr-x | Test/ztst.zsh | 47 |
1 files changed, 29 insertions, 18 deletions
diff --git a/Test/ztst.zsh b/Test/ztst.zsh index c0fbc179f..348ec4a7f 100755 --- a/Test/ztst.zsh +++ b/Test/ztst.zsh @@ -227,24 +227,25 @@ ${ZTST_curline[2,-1]}" ZTST_verbose 2 "ZTST_getredir: read redir for '$char': $ZTST_redir" -case $char in - ('<') fn=$ZTST_in - ;; - ('>') fn=$ZTST_out - ;; - ('?') fn=$ZTST_err - ;; - (*) ZTST_testfailed "bad redir operator: $char" - return 1 - ;; -esac -if [[ $ZTST_flags = *q* ]]; then - print -r -- "${(e)ZTST_redir}" >>$fn -else - print -r -- "$ZTST_redir" >>$fn -fi + case $char in + ('<') fn=$ZTST_in + ;; + ('>') fn=$ZTST_out + ;; + ('?') fn=$ZTST_err + ;; + (*) ZTST_testfailed "bad redir operator: $char" + return 1 + ;; + esac + if [[ $ZTST_flags = *q* && $char = '<' ]]; then + # delay substituting output until variables are set + print -r -- "${(e)ZTST_redir}" >>$fn + else + print -r -- "$ZTST_redir" >>$fn + fi -return 0 + return 0 } # Execute an indented chunk. Redirections will already have @@ -287,7 +288,7 @@ ZTST_diff() { } ZTST_test() { - local last match mbegin mend found + local last match mbegin mend found substlines while true; do rm -f $ZTST_in $ZTST_out $ZTST_err @@ -375,6 +376,11 @@ ZTST_test: and standard error: $(<$ZTST_terr)" # Now check output and error. + if [[ $ZTST_flags = *q* && -s $ZTST_out ]]; then + substlines="$(<$ZTST_out)" + rm -rf $ZTST_out + print -r -- "${(e)substlines}" >$ZTST_out + fi if [[ $ZTST_flags != *d* ]] && ! ZTST_diff -c $ZTST_out $ZTST_tout; then ZTST_testfailed "output differs from expected as shown above for: $ZTST_code${$(<$ZTST_terr):+ @@ -382,6 +388,11 @@ Error output: $(<$ZTST_terr)}" return 1 fi + if [[ $ZTST_flags = *q* && -s $ZTST_err ]]; then + substlines="$(<$ZTST_err)" + rm -rf $ZTST_err + print -r -- "${(e)substlines}" >$ZTST_err + fi if [[ $ZTST_flags != *D* ]] && ! ZTST_diff -c $ZTST_err $ZTST_terr; then ZTST_testfailed "error output differs from expected as shown above for: $ZTST_code" |