diff options
-rw-r--r-- | Test/B01cd.ztst | 10 | ||||
-rw-r--r-- | Test/C02cond.ztst | 3 | ||||
-rw-r--r-- | Test/E02xtrace.ztst | 34 | ||||
-rw-r--r-- | Test/README | 3 | ||||
-rwxr-xr-x | Test/ztst.zsh | 38 |
5 files changed, 57 insertions, 31 deletions
diff --git a/Test/B01cd.ztst b/Test/B01cd.ztst index f6c9fc88f..1995971cf 100644 --- a/Test/B01cd.ztst +++ b/Test/B01cd.ztst @@ -77,12 +77,22 @@ # If either or both of the '>' and '?' sets of lines is absent, it is # assumed the corresponding output should be empty and it is an error if it # is not. If '<' is empty, stdin is an empty (but opened) file. +# +# It is also possible to add lines in the redirection section beginning +# with `F:'. The remaining text on all such lines will be concatenated +# (with newlines in between) and displayed in the event of an error. +# This text is useful for explaining certain frequent errors, for example +# ones which may arise from the environment rather than from the shell +# itself. (The example below isn't particularly useful as errors with +# `cd' are unusual.) cd cdtst.tmp/sub/fake && pwd && print $PWD 0q:Preserving symbolic links in the current directory string >$mydir/cdtst.tmp/sub/fake >$mydir/cdtst.tmp/sub/fake +F:This test shouldn't really fail. The fact that it has indicates +F:something is broken. But you already knew that. cd ../../.. && pwd && diff --git a/Test/C02cond.ztst b/Test/C02cond.ztst index 6c6aea4f6..2c3c939ab 100644 --- a/Test/C02cond.ztst +++ b/Test/C02cond.ztst @@ -135,6 +135,9 @@ [[ -N newnewnew && ! -N unmodified ]] fi 0:-N cond +F:This test can fail on NFS-mounted filesystems as the access and +F:modification times are not updated separately. This does not indicate +F:a problem in the shell. [[ newnewnew -nt zerolength && ! (unmodified -nt zerolength) ]] 0:-nt cond diff --git a/Test/E02xtrace.ztst b/Test/E02xtrace.ztst index 412516cea..9b38227ff 100644 --- a/Test/E02xtrace.ztst +++ b/Test/E02xtrace.ztst @@ -55,32 +55,32 @@ >Tracing: function 2>file >Tracing: source >Tracing: source 2>file ->+(eval):7> print Tracing: ( builtin ) 2>file +>+(eval):7> print 'Tracing: ( builtin ) 2>file' >+(eval):9> cat ->+(eval):11> print Tracing: { builtin } 2>file +>+(eval):11> print 'Tracing: { builtin } 2>file' >+(eval):13> cat ->+(eval):15> print Tracing: do builtin done 2>file +>+(eval):15> print 'Tracing: do builtin done 2>file' >+(eval):17> cat -?+(eval):2> print Tracing: builtin -?+(eval):3> print Tracing: builtin 2>file +?+(eval):2> print 'Tracing: builtin' +?+(eval):3> print 'Tracing: builtin 2>file' ?+(eval):4> cat ?+(eval):5> cat -?+(eval):6> print Tracing: ( builtin ) +?+(eval):6> print 'Tracing: ( builtin )' ?+(eval):8> cat -?+(eval):10> print Tracing: { builtin } +?+(eval):10> print 'Tracing: { builtin }' ?+(eval):12> cat -?+(eval):14> print Tracing: do builtin done +?+(eval):14> print 'Tracing: do builtin done' ?+(eval):16> cat -?+(eval):18> xtf Tracing: function +?+(eval):18> xtf 'Tracing: function' ?+xtf:1> local regression_test_dummy_variable -?+xtf:2> print Tracing: function -?+(eval):19> xtf Tracing: function 2>file +?+xtf:2> print 'Tracing: function' +?+(eval):19> xtf 'Tracing: function 2>file' ?+xtf:1> local regression_test_dummy_variable -?+xtf:2> print Tracing: function 2>file -?+(eval):20> . ./xt.in Tracing: source -?+./xt.in:1> print Tracing: source -?+(eval):21> . ./xt.in Tracing: source 2>file -?+./xt.in:1> print Tracing: source 2>file +?+xtf:2> print 'Tracing: function 2>file' +?+(eval):20> . ./xt.in 'Tracing: source' +?+./xt.in:1> print 'Tracing: source' +?+(eval):21> . ./xt.in 'Tracing: source 2>file' +?+./xt.in:1> print 'Tracing: source 2>file' ?+(eval):22> set +x typeset -ft xtf @@ -88,4 +88,4 @@ 0: >Tracing: function ?+xtf:1> local regression_test_dummy_variable -?+xtf:2> print Tracing: function +?+xtf:2> print 'Tracing: function' diff --git a/Test/README b/Test/README index de3324fd9..d012277ce 100644 --- a/Test/README +++ b/Test/README @@ -25,3 +25,6 @@ or make TESTNUM=C check to perform just the test beginning C02, or all tests beginning C, respectively. + +Instructions on how to write tests are given in B01cd.ztst, which acts as a +model. diff --git a/Test/ztst.zsh b/Test/ztst.zsh index bd0c57f85..51ca12a30 100755 --- a/Test/ztst.zsh +++ b/Test/ztst.zsh @@ -101,6 +101,10 @@ ZTST_testfailed() { print -r "Was testing: $ZTST_message" fi print -r "$ZTST_testname: test failed." + if [[ -n $ZTST_failmsg ]]; then + print -r "The following may (or may not) help identifying the cause: +$ZTST_failmsg" + fi ZTST_testfailed=1 return 1 } @@ -195,13 +199,13 @@ ${ZTST_curline[2,-1]}" $ZTST_redir" case $char in - '<') fn=$ZTST_in + ('<') fn=$ZTST_in ;; - '>') fn=$ZTST_out + ('>') fn=$ZTST_out ;; - '?') fn=$ZTST_err + ('?') fn=$ZTST_err ;; - *) ZTST_testfailed "bad redir operator: $char" + (*) ZTST_testfailed "bad redir operator: $char" return 1 ;; esac @@ -260,6 +264,7 @@ ZTST_test() { rm -f $ZTST_in $ZTST_out $ZTST_err touch $ZTST_in $ZTST_out $ZTST_err ZTST_message='' + ZTST_failmsg='' found=0 ZTST_verbose 2 "ZTST_test: looking for new test" @@ -268,14 +273,14 @@ ZTST_test() { ZTST_verbose 2 "ZTST_test: examining line: $ZTST_curline" case $ZTST_curline in - %*) if [[ $found = 0 ]]; then + (%*) if [[ $found = 0 ]]; then break 2 else last=1 break fi ;; - [[:space:]]#) + ([[:space:]]#) if [[ $found = 0 ]]; then ZTST_getline || break 2 continue @@ -283,7 +288,7 @@ $ZTST_curline" break fi ;; - [[:space:]]##[^[:space:]]*) ZTST_getchunk + ([[:space:]]##[^[:space:]]*) ZTST_getchunk if [[ $ZTST_curline == (#b)([-0-9]##)([[:alpha:]]#)(:*)# ]]; then ZTST_xstatus=$match[1] ZTST_flags=$match[2] @@ -296,16 +301,21 @@ $ZTST_curline" ZTST_getline found=1 ;; - '<'*) ZTST_getredir || return 1 + ('<'*) ZTST_getredir || return 1 found=1 ;; - '>'*) ZTST_getredir || return 1 + ('>'*) ZTST_getredir || return 1 found=1 ;; - '?'*) ZTST_getredir || return 1 + ('?'*) ZTST_getredir || return 1 found=1 ;; - *) ZTST_testfailed "bad line in test block: + ('F:'*) ZTST_failmsg="${ZTST_failmsg:+${ZTST_failmsg} +} ${ZTST_curline[3,-1]}" + ZTST_getline + found=1 + ;; + (*) ZTST_testfailed "bad line in test block: $ZTST_curline" return 1 ;; @@ -373,7 +383,7 @@ ZTST_skipok= ZTST_unimplemented= while [[ -z "$ZTST_unimplemented" ]] && ZTST_getsect $ZTST_skipok; do case $ZTST_cursect in - prep) if (( ${ZTST_sects[prep]} + ${ZTST_sects[test]} + \ + (prep) if (( ${ZTST_sects[prep]} + ${ZTST_sects[test]} + \ ${ZTST_sects[clean]} )); then ZTST_testfailed "\`prep' section must come first" exit 1 @@ -381,7 +391,7 @@ while [[ -z "$ZTST_unimplemented" ]] && ZTST_getsect $ZTST_skipok; do ZTST_prepclean ZTST_sects[prep]=1 ;; - test) + (test) if (( ${ZTST_sects[test]} + ${ZTST_sects[clean]} )); then ZTST_testfailed "bad placement of \`test' section" exit 1 @@ -392,7 +402,7 @@ while [[ -z "$ZTST_unimplemented" ]] && ZTST_getsect $ZTST_skipok; do (( $? )) && ZTST_skipok=1 ZTST_sects[test]=1 ;; - clean) + (clean) if (( ${ZTST_sects[test]} == 0 || ${ZTST_sects[clean]} )); then ZTST_testfailed "bad use of \`clean' section" else |