summaryrefslogtreecommitdiff
path: root/Test/ztst.zsh
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2006-07-12 12:02:51 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2006-07-12 12:02:51 +0000
commit3d3318d8f6bbda7484689b0a29540858295260c9 (patch)
treee739223c4712e434b4996de25d2c6c7b893b37a0 /Test/ztst.zsh
parent91a241292bf88228336726938625bb381fd7f54b (diff)
downloadzsh-3d3318d8f6bbda7484689b0a29540858295260c9.tar.gz
zsh-3d3318d8f6bbda7484689b0a29540858295260c9.zip
22550: put "exec" tests
in subshells and allow substitution on test output to occur after the test.
Diffstat (limited to 'Test/ztst.zsh')
-rwxr-xr-xTest/ztst.zsh47
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"