mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-01-01 05:16:05 +01:00
17502: Test changes for xtrace in 17492.
`F:' code indicates text to display in event of error.
This commit is contained in:
parent
5faa97cb41
commit
049dce8f63
5 changed files with 57 additions and 31 deletions
|
@ -77,12 +77,22 @@
|
||||||
# If either or both of the '>' and '?' sets of lines is absent, it is
|
# 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
|
# 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.
|
# 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 &&
|
cd cdtst.tmp/sub/fake &&
|
||||||
pwd &&
|
pwd &&
|
||||||
print $PWD
|
print $PWD
|
||||||
0q:Preserving symbolic links in the current directory string
|
0q:Preserving symbolic links in the current directory string
|
||||||
>$mydir/cdtst.tmp/sub/fake
|
>$mydir/cdtst.tmp/sub/fake
|
||||||
>$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 ../../.. &&
|
cd ../../.. &&
|
||||||
pwd &&
|
pwd &&
|
||||||
|
|
|
@ -135,6 +135,9 @@
|
||||||
[[ -N newnewnew && ! -N unmodified ]]
|
[[ -N newnewnew && ! -N unmodified ]]
|
||||||
fi
|
fi
|
||||||
0:-N cond
|
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) ]]
|
[[ newnewnew -nt zerolength && ! (unmodified -nt zerolength) ]]
|
||||||
0:-nt cond
|
0:-nt cond
|
||||||
|
|
|
@ -55,32 +55,32 @@
|
||||||
>Tracing: function 2>file
|
>Tracing: function 2>file
|
||||||
>Tracing: source
|
>Tracing: source
|
||||||
>Tracing: source 2>file
|
>Tracing: source 2>file
|
||||||
>+(eval):7> print Tracing: ( builtin ) 2>file
|
>+(eval):7> print 'Tracing: ( builtin ) 2>file'
|
||||||
>+(eval):9> cat
|
>+(eval):9> cat
|
||||||
>+(eval):11> print Tracing: { builtin } 2>file
|
>+(eval):11> print 'Tracing: { builtin } 2>file'
|
||||||
>+(eval):13> cat
|
>+(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):17> cat
|
||||||
?+(eval):2> print Tracing: builtin
|
?+(eval):2> print 'Tracing: builtin'
|
||||||
?+(eval):3> print Tracing: builtin 2>file
|
?+(eval):3> print 'Tracing: builtin 2>file'
|
||||||
?+(eval):4> cat
|
?+(eval):4> cat
|
||||||
?+(eval):5> cat
|
?+(eval):5> cat
|
||||||
?+(eval):6> print Tracing: ( builtin )
|
?+(eval):6> print 'Tracing: ( builtin )'
|
||||||
?+(eval):8> cat
|
?+(eval):8> cat
|
||||||
?+(eval):10> print Tracing: { builtin }
|
?+(eval):10> print 'Tracing: { builtin }'
|
||||||
?+(eval):12> cat
|
?+(eval):12> cat
|
||||||
?+(eval):14> print Tracing: do builtin done
|
?+(eval):14> print 'Tracing: do builtin done'
|
||||||
?+(eval):16> cat
|
?+(eval):16> cat
|
||||||
?+(eval):18> xtf Tracing: function
|
?+(eval):18> xtf 'Tracing: function'
|
||||||
?+xtf:1> local regression_test_dummy_variable
|
?+xtf:1> local regression_test_dummy_variable
|
||||||
?+xtf:2> print Tracing: function
|
?+xtf:2> print 'Tracing: function'
|
||||||
?+(eval):19> xtf Tracing: function 2>file
|
?+(eval):19> xtf 'Tracing: function 2>file'
|
||||||
?+xtf:1> local regression_test_dummy_variable
|
?+xtf:1> local regression_test_dummy_variable
|
||||||
?+xtf:2> print Tracing: function 2>file
|
?+xtf:2> print 'Tracing: function 2>file'
|
||||||
?+(eval):20> . ./xt.in Tracing: source
|
?+(eval):20> . ./xt.in 'Tracing: source'
|
||||||
?+./xt.in:1> print Tracing: source
|
?+./xt.in:1> print 'Tracing: source'
|
||||||
?+(eval):21> . ./xt.in Tracing: source 2>file
|
?+(eval):21> . ./xt.in 'Tracing: source 2>file'
|
||||||
?+./xt.in:1> print Tracing: source 2>file
|
?+./xt.in:1> print 'Tracing: source 2>file'
|
||||||
?+(eval):22> set +x
|
?+(eval):22> set +x
|
||||||
|
|
||||||
typeset -ft xtf
|
typeset -ft xtf
|
||||||
|
@ -88,4 +88,4 @@
|
||||||
0:
|
0:
|
||||||
>Tracing: function
|
>Tracing: function
|
||||||
?+xtf:1> local regression_test_dummy_variable
|
?+xtf:1> local regression_test_dummy_variable
|
||||||
?+xtf:2> print Tracing: function
|
?+xtf:2> print 'Tracing: function'
|
||||||
|
|
|
@ -25,3 +25,6 @@ or
|
||||||
make TESTNUM=C check
|
make TESTNUM=C check
|
||||||
to perform just the test beginning C02, or all tests beginning C,
|
to perform just the test beginning C02, or all tests beginning C,
|
||||||
respectively.
|
respectively.
|
||||||
|
|
||||||
|
Instructions on how to write tests are given in B01cd.ztst, which acts as a
|
||||||
|
model.
|
||||||
|
|
|
@ -101,6 +101,10 @@ ZTST_testfailed() {
|
||||||
print -r "Was testing: $ZTST_message"
|
print -r "Was testing: $ZTST_message"
|
||||||
fi
|
fi
|
||||||
print -r "$ZTST_testname: test failed."
|
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
|
ZTST_testfailed=1
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
@ -195,13 +199,13 @@ ${ZTST_curline[2,-1]}"
|
||||||
$ZTST_redir"
|
$ZTST_redir"
|
||||||
|
|
||||||
case $char in
|
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
|
return 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
@ -260,6 +264,7 @@ ZTST_test() {
|
||||||
rm -f $ZTST_in $ZTST_out $ZTST_err
|
rm -f $ZTST_in $ZTST_out $ZTST_err
|
||||||
touch $ZTST_in $ZTST_out $ZTST_err
|
touch $ZTST_in $ZTST_out $ZTST_err
|
||||||
ZTST_message=''
|
ZTST_message=''
|
||||||
|
ZTST_failmsg=''
|
||||||
found=0
|
found=0
|
||||||
|
|
||||||
ZTST_verbose 2 "ZTST_test: looking for new test"
|
ZTST_verbose 2 "ZTST_test: looking for new test"
|
||||||
|
@ -268,14 +273,14 @@ ZTST_test() {
|
||||||
ZTST_verbose 2 "ZTST_test: examining line:
|
ZTST_verbose 2 "ZTST_test: examining line:
|
||||||
$ZTST_curline"
|
$ZTST_curline"
|
||||||
case $ZTST_curline in
|
case $ZTST_curline in
|
||||||
%*) if [[ $found = 0 ]]; then
|
(%*) if [[ $found = 0 ]]; then
|
||||||
break 2
|
break 2
|
||||||
else
|
else
|
||||||
last=1
|
last=1
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
[[:space:]]#)
|
([[:space:]]#)
|
||||||
if [[ $found = 0 ]]; then
|
if [[ $found = 0 ]]; then
|
||||||
ZTST_getline || break 2
|
ZTST_getline || break 2
|
||||||
continue
|
continue
|
||||||
|
@ -283,7 +288,7 @@ $ZTST_curline"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
[[:space:]]##[^[:space:]]*) ZTST_getchunk
|
([[:space:]]##[^[:space:]]*) ZTST_getchunk
|
||||||
if [[ $ZTST_curline == (#b)([-0-9]##)([[:alpha:]]#)(:*)# ]]; then
|
if [[ $ZTST_curline == (#b)([-0-9]##)([[:alpha:]]#)(:*)# ]]; then
|
||||||
ZTST_xstatus=$match[1]
|
ZTST_xstatus=$match[1]
|
||||||
ZTST_flags=$match[2]
|
ZTST_flags=$match[2]
|
||||||
|
@ -296,16 +301,21 @@ $ZTST_curline"
|
||||||
ZTST_getline
|
ZTST_getline
|
||||||
found=1
|
found=1
|
||||||
;;
|
;;
|
||||||
'<'*) ZTST_getredir || return 1
|
('<'*) ZTST_getredir || return 1
|
||||||
found=1
|
found=1
|
||||||
;;
|
;;
|
||||||
'>'*) ZTST_getredir || return 1
|
('>'*) ZTST_getredir || return 1
|
||||||
found=1
|
found=1
|
||||||
;;
|
;;
|
||||||
'?'*) ZTST_getredir || return 1
|
('?'*) ZTST_getredir || return 1
|
||||||
found=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"
|
$ZTST_curline"
|
||||||
return 1
|
return 1
|
||||||
;;
|
;;
|
||||||
|
@ -373,7 +383,7 @@ ZTST_skipok=
|
||||||
ZTST_unimplemented=
|
ZTST_unimplemented=
|
||||||
while [[ -z "$ZTST_unimplemented" ]] && ZTST_getsect $ZTST_skipok; do
|
while [[ -z "$ZTST_unimplemented" ]] && ZTST_getsect $ZTST_skipok; do
|
||||||
case $ZTST_cursect in
|
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_sects[clean]} )); then
|
||||||
ZTST_testfailed "\`prep' section must come first"
|
ZTST_testfailed "\`prep' section must come first"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -381,7 +391,7 @@ while [[ -z "$ZTST_unimplemented" ]] && ZTST_getsect $ZTST_skipok; do
|
||||||
ZTST_prepclean
|
ZTST_prepclean
|
||||||
ZTST_sects[prep]=1
|
ZTST_sects[prep]=1
|
||||||
;;
|
;;
|
||||||
test)
|
(test)
|
||||||
if (( ${ZTST_sects[test]} + ${ZTST_sects[clean]} )); then
|
if (( ${ZTST_sects[test]} + ${ZTST_sects[clean]} )); then
|
||||||
ZTST_testfailed "bad placement of \`test' section"
|
ZTST_testfailed "bad placement of \`test' section"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -392,7 +402,7 @@ while [[ -z "$ZTST_unimplemented" ]] && ZTST_getsect $ZTST_skipok; do
|
||||||
(( $? )) && ZTST_skipok=1
|
(( $? )) && ZTST_skipok=1
|
||||||
ZTST_sects[test]=1
|
ZTST_sects[test]=1
|
||||||
;;
|
;;
|
||||||
clean)
|
(clean)
|
||||||
if (( ${ZTST_sects[test]} == 0 || ${ZTST_sects[clean]} )); then
|
if (( ${ZTST_sects[test]} == 0 || ${ZTST_sects[clean]} )); then
|
||||||
ZTST_testfailed "bad use of \`clean' section"
|
ZTST_testfailed "bad use of \`clean' section"
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue