summaryrefslogtreecommitdiff
path: root/Test
diff options
context:
space:
mode:
Diffstat (limited to 'Test')
-rw-r--r--Test/B02typeset.ztst10
-rw-r--r--Test/C02cond.ztst4
-rw-r--r--Test/C03traps.ztst98
-rw-r--r--Test/D04parameter.ztst13
-rwxr-xr-xTest/ztst.zsh18
5 files changed, 131 insertions, 12 deletions
diff --git a/Test/B02typeset.ztst b/Test/B02typeset.ztst
index 6d85a63fe..9c56c7e5e 100644
--- a/Test/B02typeset.ztst
+++ b/Test/B02typeset.ztst
@@ -711,3 +711,13 @@
typeset isreadonly=still
1:typeset returns status 1 if setting readonly variable
?(eval):2: read-only variable: isreadonly
+
+ if (( UID )); then
+ UID=$((UID+1)) date; echo "Status is printed, $?"
+ else
+ ZTST_skip="cannot test setuid error when tests run as superuser"
+ fi
+0:when cannot change UID, the command isn't run
+# 'date' did not run.
+>Status is printed, 1
+?(eval):2: failed to change user ID: operation not permitted
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/C03traps.ztst b/Test/C03traps.ztst
index c3bedb06c..7bc0b486d 100644
--- a/Test/C03traps.ztst
+++ b/Test/C03traps.ztst
@@ -626,6 +626,104 @@ F:Must be tested with a top-level script rather than source or function
>before-out
>before-in
+ (setopt err_exit
+ for x in y; do
+ false && true
+ done
+ print OK
+ )
+0:ERR_EXIT not triggered by status 1 at end of for
+>OK
+
+ (setopt err_exit
+ integer x=0
+ while (( ! x++ )); do
+ false && true
+ done
+ print OK
+ )
+0:ERR_EXIT not triggered by status 1 at end of while
+>OK
+
+ (setopt err_exit
+ repeat 1; do
+ false && true
+ done
+ print OK
+ )
+0:ERR_EXIT not triggered by status 1 at end of repeat
+>OK
+
+ (setopt err_exit
+ if true; then
+ false && true
+ fi
+ print OK
+ )
+0:ERR_EXIT not triggered by status 1 at end of if
+>OK
+
+ (setopt err_exit
+ {
+ false && true
+ }
+ print OK
+ )
+0:ERR_EXIT not triggered by status 1 at end of { }
+>OK
+
+ (setopt err_exit
+ for x in y; do
+ false
+ done
+ print OK
+ )
+1:ERR_EXIT triggered by status 1 within for
+
+ (setopt err_exit
+ integer x=0
+ while (( ! x++ )); do
+ false
+ done
+ print OK
+ )
+1:ERR_EXIT triggered by status 1 within while
+
+ (setopt err_exit
+ repeat 1; do
+ false
+ done
+ print OK
+ )
+1:ERR_EXIT triggered by status 1 within repeat
+
+ (setopt err_exit
+ if true; then
+ false
+ fi
+ print OK
+ )
+1:ERR_EXIT triggered by status 1 within if
+
+ (setopt err_exit
+ {
+ false
+ }
+ print OK
+ )
+1:ERR_EXIT triggered by status 1 within { }
+
+ (setopt err_exit
+ () {
+ false && true
+ print Still functioning
+ false && true
+ }
+ print OK
+ )
+1:ERR_EXIT triggered by status 1 at end of anon func
+>Still functioning
+
if zmodload zsh/system 2>/dev/null; then
(
trap 'echo TERM; exit 2' TERM
diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst
index 4cbd2fa0f..9128c3c38 100644
--- a/Test/D04parameter.ztst
+++ b/Test/D04parameter.ztst
@@ -97,16 +97,17 @@
PROMPT="" $ZTST_testdir/../Src/zsh -fis <<<'
unsetopt PROMPT_SP
- PS2="" PS3="" PS4="" RPS1="" RPS2=""
+ PS1="" PS2="" PS3="" PS4="" RPS1="" RPS2=""
+ exec 2>&1
foo() {
print ${1:?no arguments given}
print not reached
}
foo
print reached
- '
+ ' 2>/dev/null
0:interactive shell returns to top level on ${...?...} error
-?foo:1: 1: no arguments given
+*>*foo:1: 1: no arguments given
>reached
print ${set1:+word1} ${set1+word2} ${null1:+word3} ${null1+word4}
@@ -852,6 +853,7 @@
foo='b* e*'
print ${(e)~foo}
print ${(e)~=foo}
+ setopt nomatch
0:Rule 10: Re-Evaluation
>b* e*
>boringfile evenmoreboringfile
@@ -2049,3 +2051,8 @@
0:Out-of-range multiple array subscripts with quoting, with and without (@)
>1
>0
+
+ a='~-/'; echo $~a
+0:Regression: "-" became Dash in workers/37689, breaking ~- expansion
+*>*
+F:We do not care what $OLDPWD is, as long as it doesn't cause an error
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,