summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@zsh.org>2016-12-05 16:52:22 +0000
committerPeter Stephenson <pws@zsh.org>2016-12-05 16:52:22 +0000
commit98e297931ab7e67504a9670135f9264fe1e5b283 (patch)
tree5f95448ed3682acfcfbf1cd2c0977db3d7b93a0c
parent9649ef588882419046f66a7a7db18f3cff8106f9 (diff)
downloadzsh-98e297931ab7e67504a9670135f9264fe1e5b283.tar.gz
zsh-98e297931ab7e67504a9670135f9264fe1e5b283.tar.xz
zsh-98e297931ab7e67504a9670135f9264fe1e5b283.zip
40102: Use subdirectory for test I/O files
-rw-r--r--ChangeLog3
-rw-r--r--Test/C02cond.ztst4
-rwxr-xr-xTest/ztst.zsh18
3 files changed, 16 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 3e06cfa83..65304650a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2016-12-05  Peter Stephenson  <p.stephenson@samsung.com>
 
+	* 40102: Test/ztst.zsh, Test/C02cond.ztst: create test IO
+	files in newly created temporary directory.
+
 	* 40100: Test/C03traps.ztst: Check ERR_EXIT and ERR_RETURN on
 	anonymous functions: should exit on function return even if
 	suppressed internally.
diff --git a/Test/C02cond.ztst b/Test/C02cond.ztst
index 40e4dfb0b..27a22593d 100644
--- a/Test/C02cond.ztst
+++ b/Test/C02cond.ztst
@@ -11,9 +11,9 @@
   typeset -gi isnfs
   [[ "$(find . -prune -fstype nfs 2>/dev/null)" == "." ]] && isnfs=1
   if (( isnfs )) &&
-    (cd -q ${TMPPREFIX:h} >/dev/null 2>&1 &&
+    (cd -q ${ZTST_tmp} >/dev/null 2>&1 &&
      [[ "$(find . -prune -fstype nfs 2>/dev/null)" != "." ]]); then
-    filetmpprefix=${TMPPREFIX}-$$-
+    filetmpprefix=${ZTST_tmp}/condtest-$$-
     isnfs=0
   else
     filetmpprefix=
diff --git a/Test/ztst.zsh b/Test/ztst.zsh
index 8ae06b832..f172ae143 100755
--- a/Test/ztst.zsh
+++ b/Test/ztst.zsh
@@ -104,19 +104,23 @@ fpath=( $ZTST_srcdir/../Functions/*~*/CVS(/)
         $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=${TMPPREFIX}.ztst.in.$$
+ZTST_in=${ZTST_tmp}/ztst.in
 # hold the expected output
-ZTST_out=${TMPPREFIX}.ztst.out.$$
-ZTST_err=${TMPPREFIX}.ztst.err.$$
+ZTST_out=${ZTST_tmp}/ztst.out
+ZTST_err=${ZTST_tmp}/ztst.err
 # hold the actual output from the test
-ZTST_tout=${TMPPREFIX}.ztst.tout.$$
-ZTST_terr=${TMPPREFIX}.ztst.terr.$$
+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) \
-    ${TMPPREFIX}.ztst*$$(N)
+  rm -rf $ZTST_testdir/dummy.tmp $ZTST_testdir/*.tmp(N) ${ZTST_tmp}
 }
 
 # This cleanup always gets performed, even if we abort.  Later,