Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH] Use test script specific run directories



This patch is a prerequisite for running tests in parallel. It modifies ztst.zsh to run each test script in a dedicated directory. For each script path/X01script.zest, it creates the directory path/rundirs.tmp/X01script, cds into it, and runs the script from there. The command "make check", which runs all test scripts in Test/, creates the directory Test/rundirs.tmp/, and inside it one directory for each test script. The command doesn't delete the directories, such that they can be reused by the next run. The command "make clean" deletes them.

The patch also makes it such that all temporary files created for a given script are created in its dedicated run directory.

- Use test script specific run directories

Philippe

diff --git a/Test/A01grammar.ztst b/Test/A01grammar.ztst
index eea6ede2b..c10eda3a0 100644
--- a/Test/A01grammar.ztst
+++ b/Test/A01grammar.ztst
@@ -112,7 +112,7 @@
 #
 # Tests for `Precommand Modifiers'
 #
-  - $ZTST_testdir/../Src/zsh -fc "[[ \$0 = \"-$ZTST_testdir/../Src/zsh\" ]]"
+  - $ZTST_zsh -fc "[[ \$0 = \"-$ZTST_zsh\" ]]"
 0:`-' precommand modifier
 
   echo f*
@@ -124,27 +124,27 @@
   (exec /bin/sh; echo bar)
 0:`exec' precommand modifier
 
-  (exec -l $ZTST_testdir/../Src/zsh -fc 'echo $0' | sed 's%/.*/%%' )
+  (exec -l $ZTST_zsh -fc 'echo $0' | sed 's%/.*/%%' )
 0:`exec' with -l option
 >-zsh
 
-  (exec -a /bin/SPLATTER $ZTST_testdir/../Src/zsh -fc 'echo $0')
+  (exec -a /bin/SPLATTER $ZTST_zsh -fc 'echo $0')
 0:`exec' with -a option
 >/bin/SPLATTER
 
-  (exec -a/bin/SPLOOSH $ZTST_testdir/../Src/zsh -fc 'echo $0')
+  (exec -a/bin/SPLOOSH $ZTST_zsh -fc 'echo $0')
 0:`exec' with -a option, no space
 >/bin/SPLOOSH
 
-  (exec -a foo* $ZTST_testdir/../Src/zsh -fc 'print -r -- ${(V)0}')
-  (exec -a "" $ZTST_testdir/../Src/zsh -fc 'print -r -- ${(V)0}')
+  (exec -a foo* $ZTST_zsh -fc 'print -r -- ${(V)0}')
+  (exec -a "" $ZTST_zsh -fc 'print -r -- ${(V)0}')
 0:rationalisation of arguments to exec -a
 >foo*
 >
 
   (
     opts=(-a /bin/WHOOOSH)
-    exec $opts $ZTST_testdir/../Src/zsh -fc 'echo $0'
+    exec $opts $ZTST_zsh -fc 'echo $0'
   )
 0:`exec' with -a option from expansion
 >/bin/WHOOOSH
@@ -399,7 +399,7 @@
 >This is name2
 >This is still name2
 
-  if [[ -f foo && -d . && -n $ZTST_testdir ]]; then
+  if [[ -f foo && -d . && -n $ZTST_rundir ]]; then
     true
   else
     false
@@ -619,21 +619,21 @@
 0:Handling of &&'s and ||'s with a for loop in between
 >no
 
-  $ZTST_testdir/../Src/zsh -f unmatched_quote.txt
+  $ZTST_zsh -f unmatched_quote.txt
 1:Parse error with file causes non-zero exit status
 ?unmatched_quote.txt:2: unmatched '
 
-  $ZTST_testdir/../Src/zsh -f <unmatched_quote.txt
+  $ZTST_zsh -f <unmatched_quote.txt
 1:Parse error on standard input causes non-zero exit status
 ?zsh: unmatched '
 
-  $ZTST_testdir/../Src/zsh -f -c "'"
+  $ZTST_zsh -f -c "'"
 1:Parse error on inline command causes non-zero exit status
 ?zsh:1: unmatched '
 
-  $ZTST_testdir/../Src/zsh -f NonExistentScript
+  $ZTST_zsh -f NonExistentScript
 127q:Non-existent script causes exit status 127
-?$ZTST_testdir/../Src/zsh: can't open input file: NonExistentScript
+?$ZTST_zsh: can't open input file: NonExistentScript
 
   (setopt nonomatch
   # use this to get stuff at start of line
@@ -686,16 +686,16 @@
   chmod u+x test_path_script/myscript
   path=($PWD/test_path_script $path)
   export PATH
-  $ZTST_testdir/../Src/zsh -f -o pathscript myscript
+  $ZTST_zsh -f -o pathscript myscript
 0:PATHSCRIPT option
 >Found the script.
 
-  $ZTST_testdir/../Src/zsh -f myscript
+  $ZTST_zsh -f myscript
 127q:PATHSCRIPT option not used.
-?$ZTST_testdir/../Src/zsh: can't open input file: myscript
+?$ZTST_zsh: can't open input file: myscript
 # '
 
-  $ZTST_testdir/../Src/zsh -fc 'echo $0; echo $1' myargzero myargone
+  $ZTST_zsh -fc 'echo $0; echo $1' myargzero myargone
 0:$0 is traditionally if bizarrely set to the first argument with -c
 >myargzero
 >myargone
@@ -935,7 +935,7 @@ F:Note that the behaviour of 'exit' inside try-list inside a function is unspeci
 >and true
 >or false
 
- $ZTST_testdir/../Src/zsh -fc '{ ( ) } always { echo foo }'
+ $ZTST_zsh -fc '{ ( ) } always { echo foo }'
 0:exec last command optimization inhibited for try/always
 >foo
 
@@ -948,7 +948,7 @@ F:Note that the behaviour of 'exit' inside try-list inside a function is unspeci
   echo $(
   echo bar # comment
  )' >source_comments.zsh
- $ZTST_testdir/../Src/zsh -f -o extendedglob -is -c '. ./source_comments.zsh'
+ $ZTST_zsh -f -o extendedglob -is -c '. ./source_comments.zsh'
 0:Comments should be handled in command subst in interactively sourced files
 >foo
 >bar
@@ -964,7 +964,7 @@ F:its expectations.
  (
    export VALUE=first
    print -l 'echo Value is $VALUE' 'VALUE=second sh' 'echo Value is $VALUE' |
-   $ZTST_testdir/../Src/zsh -f
+   $ZTST_zsh -f
  )
 0:Non-interactive shell command input is line buffered
 >Value is first
diff --git a/Test/A02alias.ztst b/Test/A02alias.ztst
index f866ab4d1..b641ca579 100644
--- a/Test/A02alias.ztst
+++ b/Test/A02alias.ztst
@@ -58,7 +58,7 @@
 >And this too
 >And aliases are expanded
 
-  PS1= $ZTST_testdir/../Src/zsh -fis <<<'
+  PS1= $ZTST_zsh -fis <<<'
     alias \{=echo
     { begin
     {end
@@ -70,7 +70,7 @@
 *>*2*{ begin
 *>*3*{end
 
-  PS1= $ZTST_testdir/../Src/zsh -fis <<<'
+  PS1= $ZTST_zsh -fis <<<'
     alias -g S=\"
     echo S a string S "
     fc -l -1
diff --git a/Test/A04redirect.ztst b/Test/A04redirect.ztst
index aa4b74562..a9217227c 100644
--- a/Test/A04redirect.ztst
+++ b/Test/A04redirect.ztst
@@ -462,52 +462,52 @@
 >This file contains data.
 >This file contains data.
 
-  $ZTST_testdir/../Src/zsh -fc 'exec >./nonexistent/nonexistent
+  $ZTST_zsh -fc 'exec >./nonexistent/nonexistent
   echo output'
 0:failed exec redir, no POSIX_BUILTINS
 >output
 ?zsh:1: no such file or directory: ./nonexistent/nonexistent
 
-  $ZTST_testdir/../Src/zsh -f -o POSIX_BUILTINS -c '
+  $ZTST_zsh -f -o POSIX_BUILTINS -c '
   exec >./nonexistent/nonexistent
   echo output'
 1:failed exec redir, POSIX_BUILTINS
 ?zsh:2: no such file or directory: ./nonexistent/nonexistent
 
-  $ZTST_testdir/../Src/zsh -f -o POSIX_BUILTINS -c '
+  $ZTST_zsh -f -o POSIX_BUILTINS -c '
   set >./nonexistent/nonexistent
   echo output'
 1:failed special builtin redir, POSIX_BUILTINS
 ?zsh:2: no such file or directory: ./nonexistent/nonexistent
 
-  $ZTST_testdir/../Src/zsh -f -o POSIX_BUILTINS -c '
+  $ZTST_zsh -f -o POSIX_BUILTINS -c '
   command set >./nonexistent/nonexistent
   echo output'
 0:failed special builtin redir with command prefix, POSIX_BUILTINS
 >output
 ?zsh:2: no such file or directory: ./nonexistent/nonexistent
 
-  $ZTST_testdir/../Src/zsh -f -o POSIX_BUILTINS -c '
+  $ZTST_zsh -f -o POSIX_BUILTINS -c '
   echo >./nonexistent/nonexistent
   echo output'
 0:failed unspecial builtin redir, POSIX_BUILTINS
 >output
 ?zsh:2: no such file or directory: ./nonexistent/nonexistent
 
-  $ZTST_testdir/../Src/zsh -f -o POSIX_BUILTINS -c '
+  $ZTST_zsh -f -o POSIX_BUILTINS -c '
   . ./nonexistent/nonexistent
   echo output'
 1:failed dot, POSIX_BUILTINS
 ?zsh:.:2: no such file or directory: ./nonexistent/nonexistent
 
-  $ZTST_testdir/../Src/zsh -f -c '
+  $ZTST_zsh -f -c '
   . ./nonexistent/nonexistent
   echo output'
 0:failed dot, NO_POSIX_BUILTINS
 >output
 ?zsh:.:2: no such file or directory: ./nonexistent/nonexistent
 
-  $ZTST_testdir/../Src/zsh -f -o CONTINUE_ON_ERROR <<<'
+  $ZTST_zsh -f -o CONTINUE_ON_ERROR <<<'
   readonly foo
   foo=bar set output
   echo output'
@@ -515,14 +515,14 @@
 >output
 ?zsh: read-only variable: foo
 
-  $ZTST_testdir/../Src/zsh -f <<<'
+  $ZTST_zsh -f <<<'
   readonly foo
   foo=bar set output
   echo output'
 1:failed assignment on posix special, NO_CONTINUE_ON_ERROR
 ?zsh: read-only variable: foo
 
-  $ZTST_testdir/../Src/zsh -f -o CONTINUE_ON_ERROR <<<'
+  $ZTST_zsh -f -o CONTINUE_ON_ERROR <<<'
   readonly foo
   foo=bar echo output
   echo output'
diff --git a/Test/A05execution.ztst b/Test/A05execution.ztst
index 57d6b402e..e95aedfd0 100644
--- a/Test/A05execution.ztst
+++ b/Test/A05execution.ztst
@@ -33,8 +33,8 @@
 0:./prog execution
 >This is top
 
-  path=($ZTST_testdir/command.tmp/dir1
-        $ZTST_testdir/command.tmp/dir2
+  path=($ZTST_rundir/command.tmp/dir1
+        $ZTST_rundir/command.tmp/dir2
         .)
   tstcmd
   path=($storepath)
@@ -47,18 +47,18 @@
 0:path (2)
 >This is top
 
-  PATH=${shpath}:${ZTST_testdir}/command.tmp/ tstcmd-slashless
+  PATH=${shpath}:$ZTST_rundir/command.tmp/ tstcmd-slashless
 0:path (3)
 >This is slashless
 
-  PATH=${echopath}:${ZTST_testdir}/command.tmp tstcmd-arg
+  PATH=${echopath}:$ZTST_rundir/command.tmp tstcmd-arg
 0:path (4)
 *>foo */command.tmp/tstcmd-arg
 
   # Just check this exits with non-zero status,
   # as output and status code can differ.
   (
-    path=($shpath $echopath ${ZTST_testdir}/command.tmp/)
+    path=($shpath $echopath $ZTST_rundir/command.tmp/)
     if tstcmd-interp-too-long >/dev/null 2>&1; then
       exit 0
     else
@@ -137,7 +137,7 @@
   cd .
   unfunction chpwd
 0q:chpwd
->Changed to $ZTST_testdir/command.tmp
+>Changed to $ZTST_rundir/command.tmp
 
   chpwd() { print chpwd: changed to $PWD; }
   chpwdfn1()  { print chpwdfn1: changed to $PWD; }
@@ -147,9 +147,9 @@
   unfunction chpwd
   unset chpwd_functions
 0q:chpwd_functions
->chpwd: changed to $ZTST_testdir/command.tmp
->chpwdfn1: changed to $ZTST_testdir/command.tmp
->chpwdfn2: changed to $ZTST_testdir/command.tmp
+>chpwd: changed to $ZTST_rundir/command.tmp
+>chpwdfn1: changed to $ZTST_rundir/command.tmp
+>chpwdfn2: changed to $ZTST_rundir/command.tmp
 
 # Hard to test periodic, precmd and preexec non-interactively.
 
diff --git a/Test/A07control.ztst b/Test/A07control.ztst
index 6054a363d..e394c3e5b 100644
--- a/Test/A07control.ztst
+++ b/Test/A07control.ztst
@@ -23,14 +23,14 @@
 >start 255
 >255
 
-  $ZTST_testdir/../Src/zsh -fc 'fn() {
+  $ZTST_zsh -fc 'fn() {
     break
   }
   fn'
 1:break outside loop
 ?fn:break:1: not in for, while, until, select, or repeat loop
 
-  $ZTST_testdir/../Src/zsh -fc 'fn() {
+  $ZTST_zsh -fc 'fn() {
     continue
   }
   fn'
diff --git a/Test/B01cd.ztst b/Test/B01cd.ztst
index e31341478..a1f614b40 100644
--- a/Test/B01cd.ztst
+++ b/Test/B01cd.ztst
@@ -141,11 +141,11 @@ F:something is broken.  But you already knew that.
 0:
 ?(eval):cd:3: not a directory: link_to_nonexistent
 
- (unset HOME; ARGV0=sh $ZTST_testdir/../Src/zsh -c cd)
+ (unset HOME; ARGV0=sh $ZTST_zsh -c cd)
 1:Implicit cd with unset HOME.
 ?zsh:cd:1: HOME not set
 
- $ZTST_testdir/../Src/zsh -fc 'cd -P ////dev && pwd'
+ $ZTST_zsh -fc 'cd -P ////dev && pwd'
 -f:(workers/45367) cd -P squashes multiple leading slashes
 >/dev  
 
diff --git a/Test/B02typeset.ztst b/Test/B02typeset.ztst
index 6bc53c68a..18a3eca74 100644
--- a/Test/B02typeset.ztst
+++ b/Test/B02typeset.ztst
@@ -591,7 +591,7 @@ F:BUG:The inner "typeset -p VAR" should contain the value of the outer "var"
  (export FOOENV=BAR
  env | grep '^FOOENV'
  print Exec
- exec $ZTST_testdir/../Src/zsh -fc '
+ exec $ZTST_zsh -fc '
  print Unset
  unset FOOENV
  env | grep "^FOOENV"')
@@ -1104,7 +1104,7 @@ F:BUG:The inner "typeset -p VAR" should contain the value of the outer "var"
 0:Make sure +x is honoured when tying a parameter
 >typeset -T FOO foo=( a b )
 
- $ZTST_testdir/../Src/zsh --emulate sh -f -c '
+ $ZTST_zsh --emulate sh -f -c '
  PATH=/bin; export PATH; readonly PATH
  export -p PATH		# Should be a no-op, -p ignored
  typeset -p PATH
diff --git a/Test/B06fc.ztst b/Test/B06fc.ztst
index 31ec27087..f1767d9aa 100644
--- a/Test/B06fc.ztst
+++ b/Test/B06fc.ztst
@@ -6,17 +6,17 @@
  print 'fc -l foo' >fcl
  
 %test
-  $ZTST_testdir/../Src/zsh -f ./fcl
+  $ZTST_zsh -f ./fcl
 1:Checking that fc -l foo doesn't core dump when history is empty
 ?./fcl:fc:1: event not found: foo
 
-  PS1= $ZTST_testdir/../Src/zsh +Z -fsi <<< $'fc -p /dev/null 0 0\n:'
+  PS1= $ZTST_zsh +Z -fsi <<< $'fc -p /dev/null 0 0\n:'
 0:Checking that fc -p doesn't core dump when history size is zero
 
-  PS1= $ZTST_testdir/../Src/zsh +Z -fsi <<< 'fc -p /dev/null a 0'
+  PS1= $ZTST_zsh +Z -fsi <<< 'fc -p /dev/null a 0'
 1:Checking that fc -p rejects non-integer history size
 ?fc: HISTSIZE must be an integer
 
-  PS1= $ZTST_testdir/../Src/zsh +Z -fsi <<< 'fc -p /dev/null 0 a'
+  PS1= $ZTST_zsh +Z -fsi <<< 'fc -p /dev/null 0 a'
 1:Checking that fc -p rejects non-integer history save size
 ?fc: SAVEHIST must be an integer
diff --git a/Test/B07emulate.ztst b/Test/B07emulate.ztst
index 45c39b51d..3ddab4c08 100644
--- a/Test/B07emulate.ztst
+++ b/Test/B07emulate.ztst
@@ -253,23 +253,23 @@
 F:Some reserved tokens are handled in alias expansion
 
  for mode in ksh bash zsh; do
-   $ZTST_testdir/../Src/zsh --emulate $mode -f -c 'emulate'
+   $ZTST_zsh --emulate $mode -f -c 'emulate'
  done
 0:--emulate option
 >ksh
 >sh
 >zsh
 
- $ZTST_testdir/../Src/zsh -f --emulate sh
+ $ZTST_zsh -f --emulate sh
 1:--emulate must be first
 *?*: --emulate: must precede other options
 
- $ZTST_testdir/../Src/zsh --emulate
+ $ZTST_zsh --emulate
 1:--emulate needs an argument
 *?*: --emulate: argument required
 
  for opt in shwordsplit noshwordsplit; do
-   $ZTST_testdir/../Src/zsh --emulate sh -f -o $opt -c '
+   $ZTST_zsh --emulate sh -f -o $opt -c '
      [[ -o shwordsplit ]] && echo yes || echo no
    '
  done
diff --git a/Test/C01arith.ztst b/Test/C01arith.ztst
index f932f1b0f..0e9834cb0 100644
--- a/Test/C01arith.ztst
+++ b/Test/C01arith.ztst
@@ -298,7 +298,7 @@
 0:Grouping output with underscores: floating point
 >610_351.562_5
 
-  env SHLVL=1+RANDOM $ZTST_testdir/../Src/zsh -f -c 'print $SHLVL'
+  env SHLVL=1+RANDOM $ZTST_zsh -f -c 'print $SHLVL'
 0:Imported integer functions are not evaluated
 >2
 
@@ -366,7 +366,7 @@
   # The following tests for a bug that only happens when
   # backing up over input read a line at a time, so we'll
   # read the input from stdin.
-  $ZTST_testdir/../Src/zsh -f <<<'
+  $ZTST_zsh -f <<<'
   print $((echo first command
   ); echo second command)
   print third command
@@ -375,7 +375,7 @@
 >first command second command
 >third command
 
-  $ZTST_testdir/../Src/zsh -f <<<'
+  $ZTST_zsh -f <<<'
   print $((3 +
   4))
   print next line
@@ -384,7 +384,7 @@
 >7
 >next line
 
-  $ZTST_testdir/../Src/zsh -f <<<'
+  $ZTST_zsh -f <<<'
   print $((case foo in
   bar)
   echo not this no, no
diff --git a/Test/C02cond.ztst b/Test/C02cond.ztst
index bc565e8b6..1182fd013 100644
--- a/Test/C02cond.ztst
+++ b/Test/C02cond.ztst
@@ -95,7 +95,7 @@
   [[ -o rcs && ! -o norcs && -o noerrexit && ! -o errexit ]]
 0:-o cond
 
-  if ! grep '#define HAVE_FIFOS' $ZTST_testdir/../config.h; then
+  if ! grep '#define HAVE_FIFOS' $ZTST_root/config.h; then
     print -u$ZTST_fd 'Warning: Not testing [[ -p pipe ]] (FIFOs not supported)'
     [[ ! -p zerolength ]]
   else
@@ -201,7 +201,7 @@ F:scenario if you encounter it.
   [[ 1 -lt 2 || 2 -lt 2 && 3 -gt 4 ]]
 0:|| and && in conds
 
-  if ! grep '#define PATH_DEV_FD' $ZTST_testdir/../config.h; then
+  if ! grep '#define PATH_DEV_FD' $ZTST_root/config.h; then
     print -u$ZTST_fd "Warning: not testing [[ -e /dev/fd/0 ]] (/dev/fd not supported)"
     true
   else
@@ -209,7 +209,7 @@ F:scenario if you encounter it.
   fi
 0dD:/dev/fd support in conds handled by access
 
-  if ! grep '#define PATH_DEV_FD' $ZTST_testdir/../config.h; then
+  if ! grep '#define PATH_DEV_FD' $ZTST_root/config.h; then
     print -u$ZTST_fd "Warning: not testing [[ -O /dev/fd/0 ]] (/dev/fd not supported)"
     true
   else
@@ -293,7 +293,7 @@ F:scenario if you encounter it.
 	fi
       fi
       exit 0'
-      $ZTST_testdir/../Src/zsh -f ./regex_test.sh
+      $ZTST_zsh -f ./regex_test.sh
   fi
 0:regex tests shouldn't crash
 
diff --git a/Test/C03traps.ztst b/Test/C03traps.ztst
index 9924e4f96..65cfd1461 100644
--- a/Test/C03traps.ztst
+++ b/Test/C03traps.ztst
@@ -57,10 +57,7 @@
 >Function 1 going
 >Function 2 going
 
-# $ZTST_exe is relative to the parent directory.
-# We ought to fix this in ztst.zsh...
-  (cd ..
-  $ZTST_exe -fc 'TRAPEXIT() { print Exited.; }')
+  $ZTST_zsh -fc 'TRAPEXIT() { print Exited.; }'
 0:EXIT traps on a script
 >Exited.
 
@@ -242,14 +239,14 @@
 # Autoloaded traps are horrid, but unfortunately people expect
 # them to work if we support them.
   echo "print Running exit trap" >TRAPEXIT
-  ${${ZTST_exe##[^/]*}:-$ZTST_testdir/$ZTST_exe} -fc '
+  $ZTST_zsh -fc '
     fpath=(. $fpath)
     autoload TRAPEXIT
     print "Exiting, attempt 1"
     exit
     print "What?"
   '
-  ${${ZTST_exe##[^/]*}:-$ZTST_testdir/$ZTST_exe} -fc '
+  $ZTST_zsh -fc '
     fpath=(. $fpath)
     autoload TRAPEXIT;
     fn() { print Some function }
@@ -457,14 +454,14 @@ F:Shouldn't the error in the trap prevent any further execution?
 0: EXIT trap set in command substitution
 >command substitution exited
 
-   (cd ..; $ZTST_exe -fc 'setopt posixtraps;
+   $ZTST_zsh -fc 'setopt posixtraps;
    TRAPEXIT() { print Exited; }
    fn1() { trap; }
    setopt localtraps # should be ignored by EXIT
    fn2() { TRAPEXIT() { print No, really exited; } }
    fn1
    fn2
-   fn1')
+   fn1'
 0:POSIX_TRAPS option
 >TRAPEXIT () {
 >	print Exited
@@ -474,7 +471,7 @@ F:Shouldn't the error in the trap prevent any further execution?
 >}
 >No, really exited
 
-   (cd ..; $ZTST_exe -fc 'unsetopt posixtraps;
+   $ZTST_zsh -fc 'unsetopt posixtraps;
    echo start program
    emulate sh -c '\''testfn() {
      echo start function
@@ -484,7 +481,7 @@ F:Shouldn't the error in the trap prevent any further execution?
    }'\''
    testfn
    echo program continuing
-   echo end of program')
+   echo end of program'
 0:POSIX_TRAPS effect on EXIT trap is sticky
 >start program
 >start function
@@ -494,7 +491,7 @@ F:Shouldn't the error in the trap prevent any further execution?
 >end of program
 >EXIT TRAP TRIGGERED
 
-   (cd ..; $ZTST_exe -fc '
+   $ZTST_zsh -fc '
      echo entering program
      emulate sh -c '\''trap "echo POSIX exit trap triggered" EXIT'\''
      fn() {
@@ -503,7 +500,7 @@ F:Shouldn't the error in the trap prevent any further execution?
      }
      fn
      echo exiting program
-   ')
+   '
 0:POSIX EXIT trap can have nested native mode EXIT trap
 >entering program
 >entering native zsh function
@@ -511,7 +508,7 @@ F:Shouldn't the error in the trap prevent any further execution?
 >exiting program
 >POSIX exit trap triggered
 
-   (cd ..; $ZTST_exe -fc '
+   $ZTST_zsh -fc '
      echo entering program
      emulate sh -c '\''spt() { trap "echo POSIX exit trap triggered" EXIT; }'\''
      fn() {
@@ -521,7 +518,7 @@ F:Shouldn't the error in the trap prevent any further execution?
      spt
      fn
      echo exiting program
-   ')
+   '
 0:POSIX EXIT trap not replaced if defined within function
 >entering program
 >entering native zsh function
@@ -624,7 +621,7 @@ F:Shouldn't the error in the trap prevent any further execution?
   fn
 1:ERR_RETURN in "else" branch (regression test)
 
-  $ZTST_testdir/../Src/zsh -f =(<<<"
+  $ZTST_zsh -f =(<<<"
   if false; then
     :
   else
@@ -774,7 +771,7 @@ F:Must be tested with a top-level script rather than source or function
   }
   fn
   print In .zshenv'
-  ZDOTDIR=$PWD/zdotdir $ZTST_testdir/../Src/zsh -c 'true'
+  ZDOTDIR=$PWD/zdotdir $ZTST_zsh -c 'true'
 0:ERR_RETURN within initialisation code with special flags
 >Good
 >Better
@@ -1129,7 +1126,7 @@ F:Must be tested with a top-level script rather than source or function
 >''
 >hello
 
-  $ZTST_testdir/../Src/zsh -f =(<<<"
+  $ZTST_zsh -f =(<<<"
     trap handler EXIT
     handler() {
       echoa
@@ -1150,25 +1147,25 @@ F:Must be tested with a top-level script rather than source or function
 >a
 >b
 
-  $ZTST_testdir/../Src/zsh -fc 'fn() { exit 13; }; trap fn EXIT; exit'
+  $ZTST_zsh -fc 'fn() { exit 13; }; trap fn EXIT; exit'
 13:Explicit exit in exit trap overrides status
 
-  $ZTST_testdir/../Src/zsh -fc 'fn() { exit $?+8; }; trap fn EXIT; exit 7'
+  $ZTST_zsh -fc 'fn() { exit $?+8; }; trap fn EXIT; exit 7'
 15:Progated exit status through exit trap
 
-  $ZTST_testdir/../Src/zsh -fc 'fn() { exit 13; }; trap fn EXIT'
+  $ZTST_zsh -fc 'fn() { exit 13; }; trap fn EXIT'
 13:Explicit exit in exit trap overrides implicit exit status
 
-  $ZTST_testdir/../Src/zsh -fc 'fn() { exit 0; }; trap fn EXIT; false'
+  $ZTST_zsh -fc 'fn() { exit 0; }; trap fn EXIT; false'
 0:Explicit exit status 0 in exit trap overrides implicit non-zero status
 
-  $ZTST_testdir/../Src/zsh -f <<<'fn() { exit 13; }; trap fn EXIT; false'
+  $ZTST_zsh -f <<<'fn() { exit 13; }; trap fn EXIT; false'
 13:Exit status from exit trap, script-like path
 
-  $ZTST_testdir/../Src/zsh -f <<<'fn() { exit 0; }; trap fn EXIT; false'
+  $ZTST_zsh -f <<<'fn() { exit 0; }; trap fn EXIT; false'
 0:Explicit exit status overrides implicit: script-like code path
 
- $ZTST_testdir/../Src/zsh -f <<<$'
+ $ZTST_zsh -f <<<$'
  trap \'echo $1; exit; echo $2\' USR1
  fn() {
          echo fn1
diff --git a/Test/C05debug.ztst b/Test/C05debug.ztst
index 9a8df1dad..fdd6a4361 100644
--- a/Test/C05debug.ztst
+++ b/Test/C05debug.ztst
@@ -52,7 +52,7 @@
 	# Failure
 	exit 10
 	HERE
-  $ZTST_testdir/../Src/zsh -f ./zsh-trapreturn-bug2 2>erroutput.dif
+  $ZTST_zsh -f ./zsh-trapreturn-bug2 2>erroutput.dif
   mystat=$?
   (
    setopt extendedglob
diff --git a/Test/D02glob.ztst b/Test/D02glob.ztst
index 33458e3ba..c12bc9a0c 100644
--- a/Test/D02glob.ztst
+++ b/Test/D02glob.ztst
@@ -7,7 +7,7 @@
   : >glob.tmp/{,{dir1,dir2}/}{a,b,c}
 
   globtest () {
-    $ZTST_testdir/../Src/zsh -f $ZTST_srcdir/../Misc/$1
+    $ZTST_zsh -f $ZTST_root/Misc/$1
   }
 
   regress_absolute_path_and_core_dump() {
diff --git a/Test/D03procsubst.ztst b/Test/D03procsubst.ztst
index d7f57afdc..236a8b0f5 100644
--- a/Test/D03procsubst.ztst
+++ b/Test/D03procsubst.ztst
@@ -1,8 +1,8 @@
 # Tests for process substitution: <(...), >(...) and =(...).
 
 %prep
-  if grep '#define PATH_DEV_FD' $ZTST_testdir/../config.h > /dev/null 2>&1 ||
-     grep '#define HAVE_FIFOS' $ZTST_testdir/../config.h > /dev/null 2>&1; then
+  if grep '#define PATH_DEV_FD' $ZTST_root/config.h > /dev/null 2>&1 ||
+     grep '#define HAVE_FIFOS' $ZTST_root/config.h > /dev/null 2>&1; then
     mkdir procsubst.tmp
     cd procsubst.tmp
     print 'First\tSecond\tThird\tFourth' >FILE1
@@ -154,7 +154,7 @@
 0:With /proc/self file descriptors must not be tidied up too early
 >argument
 
-  $ZTST_testdir/../Src/zsh -df -o shfileexpansion -c 'cat =(echo hi)'
+  $ZTST_zsh -df -o shfileexpansion -c 'cat =(echo hi)'
 0:EQUALS expansion followed by =(...) (sh ordering) should work
 >hi
 
@@ -170,7 +170,7 @@ F:subshells including pipe LHS do not pass through zexit()
 # Confirm tempfile exists in the function, but not after exit
   () {
     local -x TMPPREFIX=$PWD/exit
-    $ZTST_testdir/../Src/zsh -fc '
+    $ZTST_zsh -fc '
      () {
        print -rC1 -- $TMPPREFIX*
        exit
diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst
index b80564db2..7f7c0d8c3 100644
--- a/Test/D04parameter.ztst
+++ b/Test/D04parameter.ztst
@@ -147,7 +147,7 @@
 ?(eval):1: unset1: exiting1
 ?(eval):2: null1: exiting2
 
-  PS1= PS2= $ZTST_testdir/../Src/zsh -fis <<<'
+  PS1= PS2= $ZTST_zsh -fis <<<'
     exec 2>&1
     foo() {
         print ${1:?no arguments given}
@@ -1720,7 +1720,7 @@
    () { : > $1 } >( read; contextfn )
    : > >( contextfn )
    source <( <<< contextfn )
-   $ZTST_testdir/../Src/zsh -fc 'print -r - $zsh_eval_context'
+   $ZTST_zsh -fc 'print -r - $zsh_eval_context'
    () { () { print -r - $( : $(( contextfn(0) )) ) } }
 0:$ZSH_EVAL_CONTEXT and $zsh_eval_context
 >toplevel
@@ -2063,17 +2063,17 @@
 >l
 
   SHLVL=1
-  $ZTST_testdir/../Src/zsh -fc 'echo $SHLVL'
-  $ZTST_testdir/../Src/zsh -fc '(echo $SHLVL)'
+  $ZTST_zsh -fc 'echo $SHLVL'
+  $ZTST_zsh -fc '(echo $SHLVL)'
 0:SHLVL appears sensible when about to exit shell
 >2
 >2
 
   # SHLVL is incremented twice and decremented once in between.
   SHLVL=1
-  $ZTST_testdir/../Src/zsh -fc $ZTST_testdir/../Src/zsh' -fc "echo \$SHLVL"'
-  $ZTST_testdir/../Src/zsh -fc '('$ZTST_testdir/../Src/zsh' -fc "echo \$SHLVL")'
-  $ZTST_testdir/../Src/zsh -fc '( ('$ZTST_testdir/../Src/zsh' -fc "echo \$SHLVL"))'
+  $ZTST_zsh -fc $ZTST_zsh' -fc "echo \$SHLVL"'
+  $ZTST_zsh -fc '('$ZTST_zsh' -fc "echo \$SHLVL")'
+  $ZTST_zsh -fc '( ('$ZTST_zsh' -fc "echo \$SHLVL"))'
 0:SHLVL decremented upon implicit exec optimisation
 >2
 >2
@@ -2081,9 +2081,9 @@
 
   # SHLVL is incremented twice with no decrement in between.
   SHLVL=1
-  $ZTST_testdir/../Src/zsh -fc '('$ZTST_testdir/../Src/zsh' -fc "echo \$SHLVL"); exit'
-  $ZTST_testdir/../Src/zsh -fc '(exec '$ZTST_testdir/../Src/zsh' -fc "echo \$SHLVL"); exit'
-  $ZTST_testdir/../Src/zsh -fc '( ('$ZTST_testdir/../Src/zsh' -fc "echo \$SHLVL"); exit)'
+  $ZTST_zsh -fc '('$ZTST_zsh' -fc "echo \$SHLVL"); exit'
+  $ZTST_zsh -fc '(exec '$ZTST_zsh' -fc "echo \$SHLVL"); exit'
+  $ZTST_zsh -fc '( ('$ZTST_zsh' -fc "echo \$SHLVL"); exit)'
 0:SHLVL not decremented upon exec in subshells
 >3
 >3
@@ -2958,7 +2958,7 @@ F:behavior, see http://austingroupbugs.net/view.php?id=888
 1:broken length in ${name:offset:length} (workers/45843#1)
 ?(eval):1: unrecognized modifier `$'
 
- $ZTST_testdir/../Src/zsh -fc $'$\\\n('
+ $ZTST_zsh -fc $'$\\\n('
 1:regression test for workers/45843#2: escaped newline in command substitution start token
 ?zsh:2: parse error near `$('
 
@@ -3061,7 +3061,7 @@ F:behavior, see http://austingroupbugs.net/view.php?id=888
 
   (
    export ZDOTDIR=${ echo $PWD/'\0360\0237\0224\0256' }
-   $ZTST_testdir/../Src/zsh -c 'echo $ZDOTDIR'
+   $ZTST_zsh -c 'echo $ZDOTDIR'
   )
 0:regression for workers/53179 unicode ZDOTDIR
 F:output ignorable as long as not an error
@@ -3069,7 +3069,7 @@ F:output ignorable as long as not an error
 
   argv0=/not/a/real/path
   exepath=$(
-    ARGV0=$argv0 $ZTST_testdir/../Src/zsh -fc 'print -r - $ZSH_EXEPATH'
+    ARGV0=$argv0 $ZTST_zsh -fc 'print -r - $ZSH_EXEPATH'
   )
   if
     [[ $OSTYPE == (darwin|dragonfly|freebsd|netbsd)* ]] || # via library call
@@ -3089,7 +3089,7 @@ F:output ignorable as long as not an error
 *>match: /*
 
   for 1 in '' -m; do
-    COLUMNS=47 LINES=47 $ZTST_testdir/../Src/zsh $1 -fc '
+    COLUMNS=47 LINES=47 $ZTST_zsh $1 -fc '
       echo $COLUMNS $LINES
       COLUMNS=74 LINES=74
       echo $COLUMNS $LINES
@@ -3105,7 +3105,7 @@ F:output ignorable as long as not an error
 >74 74
 >74 74
 
-  $ZTST_testdir/../Src/zsh -fic '
+  $ZTST_zsh -fic '
     echo ${ZLE_RPROMPT_INDENT-unset}
     for 1 in "" 0 1 2; do (
       ZLE_RPROMPT_INDENT=$1
diff --git a/Test/D07multibyte.ztst b/Test/D07multibyte.ztst
index 28cb9d907..68569f3f6 100644
--- a/Test/D07multibyte.ztst
+++ b/Test/D07multibyte.ztst
@@ -352,12 +352,12 @@
 # TODO?: POSIX requires that printf should always compute width and
 # precision of '%s' conversion in bytes, while zsh computes them in
 # characters if multi-byte locale is in use.
-  ARGV0=sh $ZTST_testdir/../Src/zsh -c "printf '<%10s>\n' St$'\M-C\M-)'phane"
+  ARGV0=sh $ZTST_zsh -c "printf '<%10s>\n' St$'\M-C\M-)'phane"
 0f:POSIX: width in %s should be computed in bytes, not in characters
 F:This is considered a bugfix in zsh
 >< Stéphane>
 
-  ARGV0=sh $ZTST_testdir/../Src/zsh -c "printf '<%7.5s>\n' St$'\M-C\M-)'phane"
+  ARGV0=sh $ZTST_zsh -c "printf '<%7.5s>\n' St$'\M-C\M-)'phane"
 0f:POSIX: precision should also be computed in bytes, not in characers
 ><  Stép>
 
diff --git a/Test/E01options.ztst b/Test/E01options.ztst
index bcca69db7..96df3588e 100644
--- a/Test/E01options.ztst
+++ b/Test/E01options.ztst
@@ -96,7 +96,7 @@
 %test
 
 # --version is technically an option
-  v=$( $ZTST_testdir/../Src/zsh --version )
+  v=$( $ZTST_zsh --version )
   print -r - $v
   # patchlevel should appear in output if different from version
   [[ $ZSH_PATCHLEVEL == zsh-$ZSH_VERSION-0-* ]] ||
@@ -133,9 +133,9 @@
 0:ALL_EXPORT option
 >scalar-export
 >scalar
-  
+
   # Count the number of directories on the stack.  Don't care what they are.
-  dircount() { dirs -v | tail -1 | awk '{ print $1 + 1}'; }
+  dircount() { local dirs=("${(@f)$(dirs -v)}"); echo $(( ${dirs[-1]%$'\t'*} + 1 )) }
   unsetopt autopushd
   cd tmpcd
   dircount
@@ -907,7 +907,7 @@
 
 # PRINTEXITVALUE only works if shell input is coming from standard input.
 # Goodness only knows why.
-  $ZTST_testdir/../Src/zsh -f <<<'
+  $ZTST_zsh -f <<<'
       setopt printexitvalue
       func() {
 	  false
@@ -917,7 +917,7 @@
 1:PRINT_EXIT_VALUE option
 ?zsh: exit 1
 
-  $ZTST_testdir/../Src/zsh -f <<<'
+  $ZTST_zsh -f <<<'
       setopt printexitvalue
       () { false; }
   '
@@ -1492,7 +1492,7 @@ F:If this test fails at the first unsetopt, refer to P01privileged.ztst.
       '/' '/*'
     do
       before=`ls -a -- $target_dir`
-      zpty subshell $ZTST_testdir/../Src/zsh -f +Z
+      zpty subshell $ZTST_zsh -f +Z
       [[ $PWD == */options.tmp ]] || return 1 # Sanity check before calling rm(1).
       zpty -w subshell 'PS1=PROMPT'
       zpty -r -m subshell REPLY $'*PROMPT'
@@ -1527,7 +1527,7 @@ F:If this test fails at the first unsetopt, refer to P01privileged.ztst.
 F:compare E03posix.ztst
 >typeset -r var=''
 
-  $ZTST_testdir/../Src/zsh -fc "
+  $ZTST_zsh -fc "
   foo(){
       setopt err_return
       source <(echo 'if true; then return 42; fi')
@@ -1537,13 +1537,13 @@ F:compare E03posix.ztst
   "
 42:ERR_RETURN inside 'source' and 'if'
 
-  $ZTST_testdir/../Src/zsh --autonamedirs +Z -fic '
+  $ZTST_zsh --autonamedirs +Z -fic '
     b=/bin; hash -d | grep "^b="
   '
 0:AUTO_NAME_DIRS
 >b=/bin
 
-  $ZTST_testdir/../Src/zsh --autonamedirs +Z -fic '
+  $ZTST_zsh --autonamedirs +Z -fic '
     () { local b=/bin; hash -d | grep "^b=" }
     c=/bin
     () { local c=/sbin; hash -d | grep "^c=" }
diff --git a/Test/E02xtrace.ztst b/Test/E02xtrace.ztst
index 56bc20f1a..14361a9b1 100644
--- a/Test/E02xtrace.ztst
+++ b/Test/E02xtrace.ztst
@@ -110,7 +110,7 @@
  :
  fn
  ' >fnfile
- $ZTST_testdir/../Src/zsh -fx ./fnfile 2>errfile
+ $ZTST_zsh -fx ./fnfile 2>errfile
  grep '\./fnfile' errfile 1>&2
 0:Trace output with sourcefile and line number.
 >This is fn.
diff --git a/Test/E03posix.ztst b/Test/E03posix.ztst
index 6ac4d1732..f27904b3b 100644
--- a/Test/E03posix.ztst
+++ b/Test/E03posix.ztst
@@ -125,35 +125,35 @@
 F:POSIX requires a solitary "-" to be a plain argument
 >-
 
-  ARGV0=sh $ZTST_testdir/../Src/zsh -c 'foreach() { true; }'
+  ARGV0=sh $ZTST_zsh -c 'foreach() { true; }'
 -f:"foreach" is not a reserved word
 
-  ARGV0=sh $ZTST_testdir/../Src/zsh -c 'end() { true; }
+  ARGV0=sh $ZTST_zsh -c 'end() { true; }
 -f:"end" is not a reserved word
 
-  a='a:b:' ARGV0=sh $ZTST_testdir/../Src/zsh -c 'IFS=:; printf "<%s>\n" $a'
+  a='a:b:' ARGV0=sh $ZTST_zsh -c 'IFS=:; printf "<%s>\n" $a'
 0f:IFS is a separator, not a delimiter
 ><a>
 ><b>
 
-  a=$'\ra\r\rb' ARGV0=sh $ZTST_testdir/../Src/zsh -c 'IFS=:; printf "<%s>\n" $a'
+  a=$'\ra\r\rb' ARGV0=sh $ZTST_zsh -c 'IFS=:; printf "<%s>\n" $a'
 0f:All whitespace characters are "IFS whitespace"
 F:isspace('\r') is true so \r should behave like space, \t, \n
 F:This may also need to apply to multibyte whitespace
 ><a>
 ><b>
 
-  ARGV0=sh $ZTST_testdir/../Src/zsh -c 'IFS=2; printf "<%s>\n" $((11*11))'
+  ARGV0=sh $ZTST_zsh -c 'IFS=2; printf "<%s>\n" $((11*11))'
 0f:IFS applies to math results (numbers treated as strings)
 ><1>
 ><1>
 
-  ARGV0=sh $ZTST_testdir/../Src/zsh -c 'inf=42; echo $((inf))'
+  ARGV0=sh $ZTST_zsh -c 'inf=42; echo $((inf))'
 0:All identifiers are variable references in POSIX arithmetic
 F:POSIX has neither math functions nor floating point
 >42
 
-  ARGV0=sh $ZTST_testdir/../Src/zsh -c 'EUID=1; EUID=10; echo $EUID'
+  ARGV0=sh $ZTST_zsh -c 'EUID=1; EUID=10; echo $EUID'
 -f:EUID is not a special variable
 >10
 
diff --git a/Test/K01nameref.ztst b/Test/K01nameref.ztst
index a0706ec0f..976029284 100644
--- a/Test/K01nameref.ztst
+++ b/Test/K01nameref.ztst
@@ -1544,7 +1544,7 @@ F:previously this could create an infinite recursion and crash
 #
 
  # Note bypassing TYPESET_TO_UNSET here
- PS1= PS2= $ZTST_testdir/../Src/zsh -fis <<<'
+ PS1= PS2= $ZTST_zsh -fis <<<'
    typeset -n p=PS3
    () {
     typeset -p p
@@ -1560,7 +1560,7 @@ F:previously this could create an infinite recursion and crash
 >typeset p=xx
 
  # Note bypassing TYPESET_TO_UNSET here
- PS1= PS2= $ZTST_testdir/../Src/zsh -fis <<<'
+ PS1= PS2= $ZTST_zsh -fis <<<'
    () {
      typeset p=PS3
      typeset -n p
@@ -1574,8 +1574,8 @@ F:previously this could create an infinite recursion and crash
 # Testing named directories requires to run in interactive mode
 
  # Use "${(kv)nameddirs}" because "typeset -p nameddirs" prints no value
- PS1= $ZTST_testdir/../Src/zsh -fis <<<'
-   [[ -d Modules/zsh ]] && module_path=( $PWD/Modules )
+ PS1= $ZTST_zsh -fis <<<'
+   module_path=('"${(q)module_path}"')
    typeset v1=/1 v2
    typeset -n r1=v1 r2
    { echo "~v1:" ~v1 } 2>&1
diff --git a/Test/P01privileged.ztst b/Test/P01privileged.ztst
index 5d45c1a4c..9ef3f1d61 100644
--- a/Test/P01privileged.ztst
+++ b/Test/P01privileged.ztst
@@ -38,7 +38,7 @@
     return 0
   }
 
-  grep -qE '#define HAVE_SETRES?UID' $ZTST_testdir/../config.h || {
+  grep -qE '#define HAVE_SETRES?UID' $ZTST_root/config.h || {
     ZTST_unimplemented='PRIVILEGED tests require setreuid()/setresuid()'
     return 0
   }
@@ -51,7 +51,7 @@
   else
     print -ru$ZTST_fd 'Selecting unprivileged UID:EUID pair automatically'
     # See above for why we do this
-    zmodload -sF zsh/stat b:zstat && euid=${"$( zstat +uid -- $ZTST_testdir )":#0}
+    zmodload -sF zsh/stat b:zstat && euid=${"$( zstat +uid -- $ZTST_rundir )":#0}
     local tmp=$( getent passwd 2> /dev/null || < /etc/passwd )
     # Note: Some awks require -v and its argument to be separate
     ruid=$( awk -F: -v u=${euid:-0} '$3 > 0 && $3 != u { print $3; exit; }' <<< $tmp )
@@ -64,7 +64,7 @@
   else
     print -ru$ZTST_fd 'Selecting unprivileged GID:EGID pair automatically'
     # See above again -- this shouldn't have the same impact as the UID, though
-    zmodload -sF zsh/stat b:zstat && egid=${"$( zstat +gid -- $ZTST_testdir )":#0}
+    zmodload -sF zsh/stat b:zstat && egid=${"$( zstat +gid -- $ZTST_rundir )":#0}
     local tmp=$( getent group 2> /dev/null || < /etc/group )
     # Note: Some awks require -v and its argument to be separate
     rgid=$( awk -F: -v g=${egid:-0} '$3 > 0 && $3 != g { print $3; exit; }' <<< $tmp )
@@ -122,7 +122,7 @@
       opts+=( $1 )
       shift
     done
-    re_exec "$1" "$2" "$3" "$4" $ZTST_exe $opts -fc \
+    re_exec "$1" "$2" "$3" "$4" $ZTST_zsh $opts -fc \
       "MODULE_PATH=${(q)MODULE_PATH}; ${(F)@[5,-1]}"
   }
   #
@@ -191,7 +191,7 @@
 *?zsh:1: failed to change effective group ID: *
 
   local rruid
-  grep -qF '#define HAVE_INITGROUPS' $ZTST_testdir/../config.h || {
+  grep -qF '#define HAVE_INITGROUPS' $ZTST_root/config.h || {
     ZTST_skip='initgroups() not available'
     return 1
   }
diff --git a/Test/V01zmodload.ztst b/Test/V01zmodload.ztst
index ec55e0f95..8a80f760e 100644
--- a/Test/V01zmodload.ztst
+++ b/Test/V01zmodload.ztst
@@ -13,10 +13,10 @@
    [[ $link == no ]] && continue
    mods=($mods $name)
    moddeps=
-   modfile=$ZTST_srcdir/../$modfile
+   modfile=$ZTST_root/$modfile
    eval ${${${(f)"$(<$modfile)"}[(r)moddeps=*]}:-:}
    [[ -n $moddeps ]] && zmodload -d $name $=moddeps
- done < $ZTST_testdir/../config.modules
+ done < $ZTST_root/config.modules
 
  zmodunload() {
    local m n=$#
@@ -359,7 +359,7 @@
 ?(eval):6: unknown function: systell
 ?(eval):9: file descriptor out of range
 
- $ZTST_testdir/../Src/zsh -fc "
+ $ZTST_zsh -fc "
    MODULE_PATH=${(q)MODULE_PATH}
    if zmodload -e zsh/parameter; then zmodload -u zsh/parameter; fi
    unset options
@@ -370,7 +370,7 @@
 >0
 # Currently prints '1'.
 
- $ZTST_testdir/../Src/zsh -fc "
+ $ZTST_zsh -fc "
    MODULE_PATH=${(q)MODULE_PATH}
    zmodload zsh/parameter
    unset options
@@ -379,7 +379,7 @@
 0:can unset a non-readonly autoloadable parameter after loading the module
 >0
 
- $ZTST_testdir/../Src/zsh -fc "
+ $ZTST_zsh -fc "
    MODULE_PATH=${(q)MODULE_PATH}
    if zmodload -e zsh/parameter; then zmodload -u zsh/parameter; fi
    unset builtins
@@ -388,7 +388,7 @@
 *?zsh:?: read-only variable: builtins
 # Currently, the 'unset' succeeds.
 
- $ZTST_testdir/../Src/zsh -fc "
+ $ZTST_zsh -fc "
    MODULE_PATH=${(q)MODULE_PATH}
    zmodload zsh/parameter
    unset builtins
@@ -396,7 +396,7 @@
 1:can't unset a readonly autoloadable parameter after loading the module
 *?zsh:?: read-only variable: builtins
 
- $ZTST_testdir/../Src/zsh -fc "
+ $ZTST_zsh -fc "
    MODULE_PATH=${(q)MODULE_PATH}
    zmodload zsh/parameter
    zmodload -u zsh/parameter
@@ -405,7 +405,7 @@
 0:unloading a module doesn't implicitly unset autoloadable parameters
 *>(on|off) *
 
- $ZTST_testdir/../Src/zsh -fc "
+ $ZTST_zsh -fc "
   MODULE_PATH=${(q)MODULE_PATH}
   #
   zmodload zsh/zutil
diff --git a/Test/V06parameter.ztst b/Test/V06parameter.ztst
index c1f47a9dc..6927f13fd 100644
--- a/Test/V06parameter.ztst
+++ b/Test/V06parameter.ztst
@@ -11,7 +11,7 @@
   print $LINENO + $functrace + ${funcsourcetrace}
   ' >sourcedfile
   print -r -- 'print Started functrace.zsh
-  module_path=(./Modules)
+  module_path=(' ${(q)module_path} ')
   print $LINENO + $functrace + ${funcsourcetrace}
   :
   fn() {
@@ -32,7 +32,7 @@
   autofn
   autofn
   . ./sourcedfile' >functrace.zsh
-  $ZTST_testdir/../Src/zsh +Z -f ./functrace.zsh
+  $ZTST_zsh +Z -f ./functrace.zsh
 0q:Function tracing
 >Started functrace.zsh
 >3 + +
@@ -45,7 +45,7 @@
 >In sourced file
 >2 + ./functrace.zsh:22 + ./sourcedfile:0
 
-  print -r -- 'module_path=(./Modules)
+  print -r -- 'module_path=(' ${(q)module_path} ')
   debug_hook() { print $funcfiletrace[1] $functrace[1]; }
   set -o DEBUG_BEFORE_CMD
   trap "debug_hook" DEBUG
@@ -59,7 +59,7 @@
   eval "x=6
   y=7"
   z=8' >rocky3.zsh
-  $ZTST_testdir/../Src/zsh +Z -f ./rocky3.zsh
+  $ZTST_zsh +Z -f ./rocky3.zsh
 0:Eval tracing
 >./rocky3.zsh:5 ./rocky3.zsh:5
 >./rocky3.zsh:10 ./rocky3.zsh:10
diff --git a/Test/V10private.ztst b/Test/V10private.ztst
index f3ad7b6b9..39e15f133 100644
--- a/Test/V10private.ztst
+++ b/Test/V10private.ztst
@@ -7,7 +7,7 @@
  else
    # Do not use .tmp here, ztst.zsh will remove it too soon (see %cleanup)
    mkdir private.TMP
-   sed -e 's,# test_zsh_param_private,zmodload zsh/param/private,' < $ZTST_srcdir/B02typeset.ztst > private.TMP/B02
+   sed -e 's,# test_zsh_param_private,zmodload zsh/param/private,' < $ZTST_root/Test/B02typeset.ztst > private.TMP/B02
  fi
 
  setopt TYPESET_TO_UNSET
@@ -147,11 +147,11 @@ F:note "typeset" rather than "private" in output from outer
 
  inner () {
   print $+scalar_test
-  $ZTST_testdir/../Src/zsh -fc 'print X $scalar_test'
+  $ZTST_zsh -fc 'print X $scalar_test'
  }
  () {
   private -x scalar_test=whaat
-  $ZTST_testdir/../Src/zsh -fc 'print X $scalar_test'
+  $ZTST_zsh -fc 'print X $scalar_test'
   inner
   print Y $scalar_test
  }
@@ -163,12 +163,12 @@ F:note "typeset" rather than "private" in output from outer
 
  inner () {
   typeset -p array_test
-  $ZTST_testdir/../Src/zsh -fc 'print X $array_test'
+  $ZTST_zsh -fc 'print X $array_test'
  }
  () {
   local -Pax array_test=(whaat)
   print Y $array_test
-  $ZTST_testdir/../Src/zsh -fc 'print X $array_test'
+  $ZTST_zsh -fc 'print X $array_test'
   inner
  }
 0:exported private behaves like a local, part 2 (arrays do not export)
@@ -179,16 +179,16 @@ F:note "typeset" rather than "private" in output from outer
 
  inner () {
   print $+scalar_test
-  $ZTST_testdir/../Src/zsh -fc 'print X $scalar_test'
+  $ZTST_zsh -fc 'print X $scalar_test'
  }
  () {
   private scalar_test=whaat
   export scalar_test
-  $ZTST_testdir/../Src/zsh -fc 'print X $scalar_test'
+  $ZTST_zsh -fc 'print X $scalar_test'
   inner
   () {
    print $+scalar_test
-   $ZTST_testdir/../Src/zsh -fc 'print X $scalar_test'
+   $ZTST_zsh -fc 'print X $scalar_test'
   }
   print Y $scalar_test
  }
@@ -293,7 +293,7 @@ F:future revision will create a global with this assignment
 0:private parameter may hide a special parameter
 
  if (( UID )); then
-   ZTST_verbose=0 $ZTST_exe +Z -f $ZTST_srcdir/ztst.zsh private.TMP/B02
+   ZTST_verbose=0 $ZTST_zsh +Z -f $ZTST_root/Test/ztst.zsh private.TMP/B02
  else
    ZTST_skip="cannot re-run typeset tests when tests run as superuser"
  fi
diff --git a/Test/V11db_gdbm.ztst b/Test/V11db_gdbm.ztst
index 1ac9fc0c2..05999c7f5 100644
--- a/Test/V11db_gdbm.ztst
+++ b/Test/V11db_gdbm.ztst
@@ -338,16 +338,16 @@
 
  ztie -d db/gdbm -f $dbfile dbase
  zgdbmpath dbase
- [[ $REPLY = */Test/db.gdbm ]] && echo correct
+ [[ $REPLY = $ZTST_rundir/db.gdbm ]] && echo correct
  zuntie dbase
  ztie -r -d db/gdbm -f $dbfile dbase
  zgdbmpath dbase
- [[ $REPLY = */Test/db.gdbm ]] && echo correct
+ [[ $REPLY = $ZTST_rundir/db.gdbm ]] && echo correct
  zuntie -u dbase
  local -n rbase=dbase
  ztie -r -d db/gdbm -f $dbfile rbase
  zgdbmpath rbase
- [[ $REPLY = */Test/db.gdbm ]] && echo correct
+ [[ $REPLY = $ZTST_rundir/db.gdbm ]] && echo correct
  zuntie -u rbase
 0:zgdbmpath builtin
 >correct
diff --git a/Test/W01history.ztst b/Test/W01history.ztst
index 665a37f2c..5794f79ac 100644
--- a/Test/W01history.ztst
+++ b/Test/W01history.ztst
@@ -6,7 +6,7 @@
 
 %test
 
-  PS1= $ZTST_testdir/../Src/zsh -fis <<<'
+  PS1= $ZTST_zsh -fis <<<'
     print one two three four five six seven eight nine ten
     print !:$ !:10 !:9 !:1 !:0
     print one two three four five six seven eight nine ten
@@ -18,7 +18,7 @@
 >one two three four five six seven eight nine ten
 >print one two three four five six seven eight nine ten one two
 
-  PS1= $ZTST_testdir/../Src/zsh -fis <<<'
+  PS1= $ZTST_zsh -fis <<<'
     print line one of an arbitrary series
     print issue two for some mystery sequence
     print !-1:5-$
@@ -34,7 +34,7 @@
 >two
 >mystery sequence
 
-  PS1= $ZTST_testdir/../Src/zsh -fis <<<'
+  PS1= $ZTST_zsh -fis <<<'
     print All metaphor, Malachi, stilts and all
     print !1:2:s/,/\\\\?/ !1:2:s/m/shm/:s/,/\!/
     print !1:2:&
@@ -47,7 +47,7 @@
 >metophor,
 >Molochi,
 
-  PS1= $ZTST_testdir/../Src/zsh -fis <<<'
+  PS1= $ZTST_zsh -fis <<<'
     echo foo bar
     echo $(!!) again
     echo more $( !! )
@@ -60,7 +60,7 @@
 F:Check that a history bug introduced by workers/34160 is working again.
 # Discarded line of error output consumes prompts printed by "zsh -i".
 
- PS1= $ZTST_testdir/../Src/zsh -fis <<<'
+ PS1= $ZTST_zsh -fis <<<'
    echo /my/path/for/testing
    echo !1:1:h10
    echo !1:1:h3
@@ -84,7 +84,7 @@ F:Check that a history bug introduced by workers/34160 is working again.
 >testing
 >path/for
 
- PS1= $ZTST_testdir/../Src/zsh -fis <<<'
+ PS1= $ZTST_zsh -fis <<<'
    echo /my/path/for/testing
    echo !1:1:P
  '
@@ -92,7 +92,7 @@ F:Check that a history bug introduced by workers/34160 is working again.
 >/my/path/for/testing
 >/my/path/for/testing
 
- PS1= $ZTST_testdir/../Src/zsh -fgis <<<'
+ PS1= $ZTST_zsh -fgis <<<'
    SAVEHIST=7
    print -rs "one\\"
    print -rs "two\\\\"
diff --git a/Test/W02jobs.ztst b/Test/W02jobs.ztst
index bdb6ab979..101eb632d 100644
--- a/Test/W02jobs.ztst
+++ b/Test/W02jobs.ztst
@@ -7,7 +7,7 @@
     zpty_start() {
       export PS1= PS2=
       zpty -d
-      zpty zsh "${(q)ZTST_testdir}/../Src/zsh -fiV +Z"
+      zpty zsh "${(q)ZTST_zsh} -fiV +Z"
       zpty -w zsh 'alias sleep="sleep </dev/null >/dev/null 2>&1"; exec {ZTST_fd}>&-'
     }
     zpty_input() {
diff --git a/Test/W03jobparameters.ztst b/Test/W03jobparameters.ztst
index 6b2b80d54..d1564bedb 100644
--- a/Test/W03jobparameters.ztst
+++ b/Test/W03jobparameters.ztst
@@ -6,7 +6,7 @@
     zpty_start() {
       export PS1= PS2=
       zpty -d
-      zpty zsh "${(q)ZTST_testdir}/../Src/zsh -fiV +Z"
+      zpty zsh "${(q)ZTST_zsh} -fiV +Z"
     }
     zpty_input() {
       zpty -w zsh "${(F)@}" $'\n'
diff --git a/Test/X02zlevi.ztst b/Test/X02zlevi.ztst
index ccfb7b1c6..7f12c1a53 100644
--- a/Test/X02zlevi.ztst
+++ b/Test/X02zlevi.ztst
@@ -3,8 +3,8 @@
 %prep
   ZSH_TEST_LANG=$(ZTST_find_UTF8)
   if ( zmodload zsh/zpty 2>/dev/null ); then
-    . $ZTST_srcdir/comptest
-    comptestinit -v -z $ZTST_testdir/../Src/zsh
+    . $ZTST_comptest
+    comptestinit -v
   else
     ZTST_unimplemented="the zsh/zpty module is not available"
   fi
diff --git a/Test/X03zlebindkey.ztst b/Test/X03zlebindkey.ztst
index 1b63b3920..b16857124 100644
--- a/Test/X03zlebindkey.ztst
+++ b/Test/X03zlebindkey.ztst
@@ -5,8 +5,8 @@
 %prep
   ZSH_TEST_LANG=$(ZTST_find_UTF8)
   if ( zmodload zsh/zpty 2>/dev/null ); then
-    . $ZTST_srcdir/comptest
-    comptestinit -z $ZTST_testdir/../Src/zsh
+    . $ZTST_comptest
+    comptestinit
   else
     ZTST_unimplemented="the zsh/zpty module is not available"
   fi
diff --git a/Test/X04zlehighlight.ztst b/Test/X04zlehighlight.ztst
index bfb3dd135..2fc52bc18 100644
--- a/Test/X04zlehighlight.ztst
+++ b/Test/X04zlehighlight.ztst
@@ -9,7 +9,7 @@
     zpty_start() {
       export PS1= PS2=
       zpty -d
-      zpty zsh "${(q)ZTST_testdir}/../Src/zsh -fiV +Z"
+      zpty zsh "${(q)ZTST_zsh} -fiV +Z"
       zpty -w zsh "module_path=( ${(j< >)${(@q-)module_path}} \$module_path )"
       zpty -w zsh 'zle_highlight=( fg_start_code:"CDE|3" fg_end_code:"|" bg_start_code:"BCDE|4" bg_end_code:"|" )'
       zpty -w zsh '.term.extensions=( -query truecolor -bracketed-paste -integration )'
diff --git a/Test/X05zleincarg.ztst b/Test/X05zleincarg.ztst
index f712e9426..33412bfa8 100644
--- a/Test/X05zleincarg.ztst
+++ b/Test/X05zleincarg.ztst
@@ -3,8 +3,8 @@
 %prep
   ZSH_TEST_LANG=$(ZTST_find_UTF8)
   if ( zmodload zsh/zpty 2>/dev/null ); then
-    . $ZTST_srcdir/comptest
-    comptestinit -v -z $ZTST_testdir/../Src/zsh
+    . $ZTST_comptest
+    comptestinit -v
     zpty_run '
       autoload -Uz incarg
       for name in {,vim-,vim-backward-}{,sync-}{inc,dec}arg; do
diff --git a/Test/X06termquery.ztst b/Test/X06termquery.ztst
index 701cd625b..a487e5546 100644
--- a/Test/X06termquery.ztst
+++ b/Test/X06termquery.ztst
@@ -8,7 +8,7 @@
       typeset +x TERM_PROGRAM
       typeset +x -m .term.\*
       zpty -d
-      zpty zsh "${(q)ZTST_testdir}/../Src/zsh -fiV +Z"
+      zpty zsh "${(q)ZTST_zsh} -fiV +Z"
       zpty -w zsh "module_path=( ${(j< >)${(@q-)module_path}} \$module_path )"
       zpty -w zsh ".term.extensions=( -bracketed-paste -integration )"
       zpty -w zsh "setopt zle"
diff --git a/Test/Y01completion.ztst b/Test/Y01completion.ztst
index 57cac2883..b0cd1d789 100644
--- a/Test/Y01completion.ztst
+++ b/Test/Y01completion.ztst
@@ -3,10 +3,10 @@
 %prep
   ZSH_TEST_LANG=$(ZTST_find_UTF8)
   if ( zmodload zsh/zpty 2>/dev/null ); then
-    . $ZTST_srcdir/comptest
+    . $ZTST_comptest
     mkdir comp.tmp
     cd comp.tmp
-    comptestinit -z $ZTST_testdir/../Src/zsh &&
+    comptestinit &&
     {
       comptesteval 'compdef _tst tst'
       mkdir dir1 &&
@@ -194,12 +194,12 @@ F:regression test workers/51641
 F:regression test workers/42164
 
 # Depends on path assignment in comptestinit
-  comptesteval "path=( $ZTST_srcdir:A )"
+  comptesteval "path=( $ZTST_root/Test )"
   comptest $'zt\t'
 0:command
 >line: {ztst.zsh }{}
 
-  comptesteval "path=( $ZTST_srcdir:A )"
+  comptesteval "path=( $ZTST_root/Test )"
   comptest $':;zt\t'
 0:command after separator
 >line: {:;ztst.zsh }{}
@@ -364,7 +364,7 @@ F:regression test workers/31611
 >NO:{bat  -- ( [' ']='!' ['"']='#' ['$']=% ['&']=\' ['(']=')' ['*']=+ [,]=- [.]=/}
 >NO:{bay  -- '^@ ^A ^B ^C ^D ^E ^F ^G ^H \t \n ^K ^L ^M ^N ^O ^P ^Q ^R ^S ^T ^U ^}
 
-  comptesteval "path=( $ZTST_srcdir:A )"
+  comptesteval "path=( $ZTST_root/Test )"
   comptesteval 'typeset -H paths=HIDDEN'
   comptest $': $path\t'
 0:verbose doesn't show special or hidden parameter values
diff --git a/Test/Y02compmatch.ztst b/Test/Y02compmatch.ztst
index f28913867..278c0c90d 100644
--- a/Test/Y02compmatch.ztst
+++ b/Test/Y02compmatch.ztst
@@ -12,10 +12,10 @@
 
 %prep
   if ( zmodload zsh/zpty 2>/dev/null ); then
-    . $ZTST_srcdir/comptest
+    . $ZTST_comptest
     mkdir match.tmp
     cd match.tmp
-    comptestinit -z $ZTST_testdir/../Src/zsh &&
+    comptestinit &&
     {
       list1=(IndianRed IndianRed2 IndianRed3 IndianRed4)
       test_code () {
diff --git a/Test/Y03arguments.ztst b/Test/Y03arguments.ztst
index 6ff9bf0a5..5440c7c79 100644
--- a/Test/Y03arguments.ztst
+++ b/Test/Y03arguments.ztst
@@ -2,10 +2,10 @@
 
 %prep
   if ( zmodload zsh/zpty 2>/dev/null ); then
-    . $ZTST_srcdir/comptest
+    . $ZTST_comptest
     mkdir comp.tmp
     cd comp.tmp
-    comptestinit -z $ZTST_testdir/../Src/zsh &&
+    comptestinit &&
     {
       comptesteval 'compdef _tst tst'
       tst_arguments () { comptesteval "_tst () { _arguments ${${(@qq)*}} }" }
diff --git a/Test/Y04regexargs.ztst b/Test/Y04regexargs.ztst
index d204fd312..a6a79317e 100644
--- a/Test/Y04regexargs.ztst
+++ b/Test/Y04regexargs.ztst
@@ -4,10 +4,10 @@
   if [[ $OSTYPE = cygwin ]]; then
     ZTST_unimplemented="the zsh/zpty module does not work on Cygwin"
   elif ( zmodload zsh/zpty 2>/dev/null ); then
-    . $ZTST_srcdir/comptest
+    . $ZTST_comptest
     mkdir comp.tmp
     cd comp.tmp
-    comptestinit -z $ZTST_testdir/../Src/zsh &&
+    comptestinit &&
     {
       word=$'[^\0]#\0'
       comptesteval \
@@ -21,7 +21,7 @@
 
 %test
  tst_regex /one/ ':first:first:(one)'
- comptesteval "functions _tst >/tmp/hello"
+ comptesteval "functions _tst >$ZTST_rundir/hello"
  comptest $'tst \t'
 0:standalone spec
 >line: {tst one }{}
diff --git a/Test/Y05describe.ztst b/Test/Y05describe.ztst
index 72953af7c..b0db09592 100644
--- a/Test/Y05describe.ztst
+++ b/Test/Y05describe.ztst
@@ -3,10 +3,10 @@
 %prep
 
   if ( zmodload -s zsh/zpty ); then
-    source $ZTST_srcdir/comptest
+    source $ZTST_comptest
     mkdir comp.tmp
     cd comp.tmp
-    comptestinit -z $ZTST_testdir/../Src/zsh && {
+    comptestinit && {
       comptesteval 'compdef _tst tst'
       tst_describe() { comptesteval "_tst() { _describe ${${(@q+)@}} }" }
     }
diff --git a/Test/Y06values.ztst b/Test/Y06values.ztst
index 720f990a5..2b992ae58 100644
--- a/Test/Y06values.ztst
+++ b/Test/Y06values.ztst
@@ -3,10 +3,10 @@
 %prep
 
   if ( zmodload -s zsh/zpty ); then
-    source $ZTST_srcdir/comptest
+    source $ZTST_comptest
     mkdir comp.tmp
     cd comp.tmp
-    comptestinit -z $ZTST_testdir/../Src/zsh && {
+    comptestinit && {
       comptesteval 'compdef _tst tst'
       tst_values() { comptesteval "_tst() { _values ${${(@q+)@}} }" }
     }
diff --git a/Test/Y07call_program.ztst b/Test/Y07call_program.ztst
index 19eca8f9f..bd8fb85bb 100644
--- a/Test/Y07call_program.ztst
+++ b/Test/Y07call_program.ztst
@@ -3,10 +3,10 @@
 %prep
 
   if ( zmodload -s zsh/zpty ); then
-    source $ZTST_srcdir/comptest
+    source $ZTST_comptest
     mkdir comp.tmp
     cd comp.tmp
-    comptestinit -z $ZTST_testdir/../Src/zsh && {
+    comptestinit && {
       comptesteval '
         pp() { printf "<%s>" "$@"; print }
         compdef _tst tst
diff --git a/Test/comptest b/Test/comptest
index 13bbce3c8..5a11890dd 100644
--- a/Test/comptest
+++ b/Test/comptest
@@ -1,25 +1,19 @@
 comptestinit () {
   setopt extendedglob
-  [[ -d $ZTST_testdir/Modules/zsh ]] && module_path=( $ZTST_testdir/Modules )
-  fpath=( $ZTST_srcdir/../Functions/*~*/CVS(/)
-          $ZTST_srcdir/../Completion
-          $ZTST_srcdir/../Completion/*/*~*/CVS(/) )
 
   zmodload zsh/zpty || return $?
 
-  comptest_zsh=${ZSH:-zsh}
   comptest_keymap=e
 
-  while getopts vz: opt; do
+  while getopts v opt; do
     case $opt in
-      z) comptest_zsh="$OPTARG";;
       v) comptest_keymap="v";;
     esac
   done
   (( OPTIND > 1 )) && shift $(( OPTIND - 1 ))
 
   export PS1="<PROMPT>"
-  zpty zsh "$comptest_zsh -f +Z"
+  zpty zsh "$ZTST_zsh -f +Z"
 
   zpty_read log1 "*<PROMPT>*" || {
     print "first prompt hasn't appeared."
@@ -29,7 +23,7 @@ comptestinit () {
   comptesteval \
 "export LC_ALL=${ZSH_TEST_LANG:-C}" \
 "emulate -R zsh" \
-"export ZDOTDIR=$ZTST_testdir" \
+"export ZDOTDIR=$ZTST_rundir" \
 "module_path=( $module_path )" \
 "fpath=( $fpath )" \
 "bindkey -$comptest_keymap" \
diff --git a/Test/ztst.zsh b/Test/ztst.zsh
index ae5133e4d..df0a09b61 100755
--- a/Test/ztst.zsh
+++ b/Test/ztst.zsh
@@ -45,9 +45,24 @@ ZTST_find_UTF8 () {
 # Don't propagate variables that are set by default in the shell.
 typeset +x WORDCHARS
 
+# Unset relative paths inherited from the Makefile.
+unset ZTST_srcdir ZTST_exe
+
+# Set the root to correspond to this build of zsh.
+ZTST_root=$0:a:h:h
+
+# Set zsh and comptest to correspond to this build of zsh.
+ZTST_zsh=$ZTST_root/Src/zsh
+ZTST_comptest=$ZTST_root/Test/comptest
+
 # Set the module load path to correspond to this build of zsh.
 # This Modules directory should have been created by "make check".
-[[ -d Modules/zsh ]] && module_path=( $PWD/Modules )
+module_path=( $ZTST_root/Test/Modules )
+
+# Set the function autoload paths to correspond to this build of zsh.
+fpath=( $ZTST_root/Functions/*(/)
+        $ZTST_root/Completion
+        $ZTST_root/Completion/*/*(/) )
 
 # We need to be able to save and restore the options used in the test.
 # We use the $options variable of the parameter module for this.
@@ -66,81 +81,11 @@ done
 # Options set in main script
 ZTST_mainopts=(${(kv)options})
 
-# We run in the current directory, so remember it.
-ZTST_testdir=$PWD
 ZTST_testname=$1
+ZTST_testfile=$1:a
 
 integer ZTST_testfailed=0
 
-# This is POSIX nonsense.  Because of the vague feeling someone, somewhere
-# may one day need to examine the arguments of "tail" using a standard
-# option parser, every Unix user in the world is expected to switch
-# to using "tail -n NUM" instead of "tail -NUM".  Older versions of
-# tail don't support this.
-tail() {
-  emulate -L zsh
-
-  if [[ -z $TAIL_SUPPORTS_MINUS_N ]]; then
-    local test
-    test=$(echo "foo\nbar" | command tail -n 1 2>/dev/null)
-    if [[ $test = bar ]]; then
-      TAIL_SUPPORTS_MINUS_N=1
-    else
-      TAIL_SUPPORTS_MINUS_N=0
-    fi
-  fi
-
-  integer argi=${argv[(i)-<->]}
-
-  if [[ $argi -le $# && $TAIL_SUPPORTS_MINUS_N = 1 ]]; then
-    argv[$argi]=(-n ${argv[$argi][2,-1]})
-  fi
-
-  command tail "$argv[@]"
-}
-
-# The source directory is not necessarily the current directory,
-# but if $0 doesn't contain a `/' assume it is.
-if [[ $0 = */* ]]; then
-  ZTST_srcdir=${0%/*}
-else
-  ZTST_srcdir=$PWD
-fi
-[[ $ZTST_srcdir = /* ]] || ZTST_srcdir="$ZTST_testdir/$ZTST_srcdir"
-
-# Set the function autoload paths to correspond to this build of zsh.
-fpath=( $ZTST_srcdir/../Functions/*~*/CVS(/)
-        $ZTST_srcdir/../Completion
-        $ZTST_srcdir/../Completion/*/*~*/CVS(/) )
-
-: ${TMPPREFIX:=/tmp/zsh}
-ZTST_tmp=${TMPPREFIX}.ztst.$$
-if ! rm -f $ZTST_tmp || ! mkdir -p $ZTST_tmp || ! chmod go-w $ZTST_tmp; then
-  print "Can't create $ZTST_tmp for exclusive use." >&2
-  exit 1
-fi
-# Temporary files for redirection inside tests.
-ZTST_in=${ZTST_tmp}/ztst.in
-# hold the expected output
-ZTST_out=${ZTST_tmp}/ztst.out
-ZTST_err=${ZTST_tmp}/ztst.err
-# hold the actual output from the test
-ZTST_tout=${ZTST_tmp}/ztst.tout
-ZTST_terr=${ZTST_tmp}/ztst.terr
-
-ZTST_cleanup() {
-  cd $ZTST_testdir
-  rm -rf $ZTST_testdir/dummy.tmp $ZTST_testdir/*.tmp(N) ${ZTST_tmp}
-}
-
-# This cleanup always gets performed, even if we abort.  Later,
-# we should try and arrange that any test-specific cleanup
-# always gets called as well.
-##trap 'print cleaning up...
-##ZTST_cleanup' INT QUIT TERM
-# Make sure it's clean now.
-rm -rf dummy.tmp *.tmp
-
 # Report failure.  Note that all output regarding the tests goes to stdout.
 # That saves an unpleasant mixture of stdout and stderr to sort out.
 ZTST_testfailed() {
@@ -194,13 +139,48 @@ ZTST_hashmark() {
   (( SECONDS > COLUMNS+1 && (SECONDS -= COLUMNS) ))
 }
 
-if [[ ! -r $ZTST_testname ]]; then
+# Setup test specific run directory and cd into it.
+ZTST_rundir=$ZTST_testfile:h/rundirs.tmp/${${ZTST_testfile:t}%.ztst}
+[[ -d $ZTST_rundir ]] || mkdir -p $ZTST_rundir
+cd $ZTST_rundir
+
+# Create all temporary files inside the test specific run directory.
+TMPPREFIX=$ZTST_rundir/zsh
+ZTST_tmp=${TMPPREFIX}.ztst.$$
+if ! rm -f $ZTST_tmp || ! mkdir -p $ZTST_tmp || ! chmod go-w $ZTST_tmp; then
+  ZTST_testfailed "can't create $ZTST_tmp for exclusive use."
+  exit 1
+fi
+
+# Temporary files for redirection inside tests.
+ZTST_in=${ZTST_tmp}/ztst.in
+# hold the expected output
+ZTST_out=${ZTST_tmp}/ztst.out
+ZTST_err=${ZTST_tmp}/ztst.err
+# hold the actual output from the test
+ZTST_tout=${ZTST_tmp}/ztst.tout
+ZTST_terr=${ZTST_tmp}/ztst.terr
+
+ZTST_cleanup() {
+  cd $ZTST_rundir
+  rm -rf $ZTST_rundir/dummy.tmp $ZTST_rundir/*.tmp(N) ${ZTST_tmp}
+}
+
+# This cleanup always gets performed, even if we abort.  Later,
+# we should try and arrange that any test-specific cleanup
+# always gets called as well.
+##trap 'print cleaning up...
+##ZTST_cleanup' INT QUIT TERM
+# Make sure it's clean now.
+rm -rf dummy.tmp *.tmp
+
+if [[ ! -r $ZTST_testfile ]]; then
   ZTST_testfailed "can't read test file."
   exit 1
 fi
 
 exec {ZTST_fd}>&1
-exec {ZTST_input}<$ZTST_testname
+exec {ZTST_input}<$ZTST_testfile
 
 # The current line read from the test file.
 ZTST_curline=''


Messages sorted by: Reverse Date, Date, Thread, Author