about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPaul Ackersviller <packersv@users.sourceforge.net>2007-10-25 01:57:14 +0000
committerPaul Ackersviller <packersv@users.sourceforge.net>2007-10-25 01:57:14 +0000
commitc9d6e5e4cf6b4aaaea40dfc133238ea9f9d6bf11 (patch)
tree5ead72b4e460044f731e88a691a64f17c7bc09f8
parentafce61a417efecc9f5936601a8ae61e26918eeb9 (diff)
downloadzsh-c9d6e5e4cf6b4aaaea40dfc133238ea9f9d6bf11.tar.gz
zsh-c9d6e5e4cf6b4aaaea40dfc133238ea9f9d6bf11.tar.xz
zsh-c9d6e5e4cf6b4aaaea40dfc133238ea9f9d6bf11.zip
Merge this part of 22550: put "exec" tests in subshells.
-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"