mirror of
git://git.code.sf.net/p/zsh/code
synced 2024-11-15 21:43:09 +01:00
1993a3cd2a
This is both in xtrace output and shell code rebuilt from internal structures.
149 lines
4.3 KiB
Plaintext
149 lines
4.3 KiB
Plaintext
# Test that xtrace output is correctly generated
|
|
|
|
%prep
|
|
mkdir xtrace.tmp && cd xtrace.tmp
|
|
|
|
function xtf {
|
|
local regression_test_dummy_variable
|
|
print "$*"
|
|
}
|
|
function xtfx {
|
|
local regression_test_dummy_variable
|
|
print "Tracing: (){ builtin 2>file }" 2>>xtrace.err
|
|
{ print "Tracing: (){ { builtin } 2>file }" } 2>>xtrace.err
|
|
}
|
|
echo 'print "$*"' > xt.in
|
|
|
|
%test
|
|
|
|
PS4='+%N:%i> '
|
|
set -x
|
|
print 'Tracing: builtin'
|
|
print 'Tracing: builtin 2>file' 2>xtrace.err
|
|
cat <<<'Tracing: external'
|
|
cat <<<'Tracing: external 2>file' 2>>xtrace.err
|
|
( print 'Tracing: ( builtin )' )
|
|
( print 'Tracing: ( builtin ) 2>file' ) 2>>xtrace.err
|
|
( cat <<<'Tracing: ( external )' )
|
|
( cat <<<'Tracing: ( external ) 2>file' ) 2>>xtrace.err
|
|
{ print 'Tracing: { builtin }' }
|
|
{ print 'Tracing: { builtin } 2>file' } 2>>xtrace.err
|
|
{ cat <<<'Tracing: { external }' }
|
|
{ cat <<<'Tracing: { external } 2>file' } 2>>xtrace.err
|
|
repeat 1 do print 'Tracing: do builtin done'; done
|
|
repeat 1 do print 'Tracing: do builtin done 2>file'; done 2>>xtrace.err
|
|
repeat 1 do cat <<<'Tracing: do external done'; done
|
|
repeat 1 do cat <<<'Tracing: do external done 2>file'; done 2>>xtrace.err
|
|
xtf 'Tracing: function'
|
|
xtf 'Tracing: function 2>file' 2>>xtrace.err
|
|
xtfx
|
|
. ./xt.in 'Tracing: source'
|
|
. ./xt.in 'Tracing: source 2>file' 2>>xtrace.err
|
|
set +x
|
|
cat xtrace.err
|
|
0:xtrace with and without redirection
|
|
>Tracing: builtin
|
|
>Tracing: builtin 2>file
|
|
>Tracing: external
|
|
>Tracing: external 2>file
|
|
>Tracing: ( builtin )
|
|
>Tracing: ( builtin ) 2>file
|
|
>Tracing: ( external )
|
|
>Tracing: ( external ) 2>file
|
|
>Tracing: { builtin }
|
|
>Tracing: { builtin } 2>file
|
|
>Tracing: { external }
|
|
>Tracing: { external } 2>file
|
|
>Tracing: do builtin done
|
|
>Tracing: do builtin done 2>file
|
|
>Tracing: do external done
|
|
>Tracing: do external done 2>file
|
|
>Tracing: function
|
|
>Tracing: function 2>file
|
|
>Tracing: (){ builtin 2>file }
|
|
>Tracing: (){ { builtin } 2>file }
|
|
>Tracing: source
|
|
>Tracing: source 2>file
|
|
>+(eval):8> print 'Tracing: ( builtin ) 2>file'
|
|
>+(eval):10> cat
|
|
>+(eval):12> print 'Tracing: { builtin } 2>file'
|
|
>+(eval):14> cat
|
|
>+(eval):16> print 'Tracing: do builtin done 2>file'
|
|
>+(eval):18> cat
|
|
>+xtf:1> local regression_test_dummy_variable
|
|
>+xtf:2> print 'Tracing: function 2>file'
|
|
>+xtfx:3> print 'Tracing: (){ { builtin } 2>file }'
|
|
?+(eval):3> print 'Tracing: builtin'
|
|
?+(eval):4> print 'Tracing: builtin 2>file'
|
|
?+(eval):5> cat
|
|
?+(eval):6> cat
|
|
?+(eval):7> print 'Tracing: ( builtin )'
|
|
?+(eval):9> cat
|
|
?+(eval):11> print 'Tracing: { builtin }'
|
|
?+(eval):13> cat
|
|
?+(eval):15> print 'Tracing: do builtin done'
|
|
?+(eval):17> cat
|
|
?+(eval):19> xtf 'Tracing: function'
|
|
?+xtf:1> local regression_test_dummy_variable
|
|
?+xtf:2> print 'Tracing: function'
|
|
?+(eval):20> xtf 'Tracing: function 2>file'
|
|
?+(eval):21> xtfx
|
|
?+xtfx:1> local regression_test_dummy_variable
|
|
?+xtfx:2> print 'Tracing: (){ builtin 2>file }'
|
|
?+(eval):22> . ./xt.in 'Tracing: source'
|
|
?+./xt.in:1> print 'Tracing: source'
|
|
?+(eval):23> . ./xt.in 'Tracing: source 2>file'
|
|
?+./xt.in:1> print 'Tracing: source 2>file'
|
|
?+(eval):24> set +x
|
|
|
|
typeset -ft xtf
|
|
xtf 'Tracing: function'
|
|
0:tracing function
|
|
>Tracing: function
|
|
?+xtf:1> local regression_test_dummy_variable
|
|
?+xtf:2> print 'Tracing: function'
|
|
|
|
echo 'PS4="+%x:%I> "
|
|
fn() {
|
|
print This is fn.
|
|
}
|
|
:
|
|
fn
|
|
' >fnfile
|
|
$ZTST_testdir/../Src/zsh -fx ./fnfile 2>errfile
|
|
grep '\./fnfile' errfile 1>&2
|
|
0:Trace output with sourcefile and line number.
|
|
>This is fn.
|
|
?+./fnfile:1> PS4='+%x:%I> '
|
|
?+./fnfile:5> :
|
|
?+./fnfile:6> fn
|
|
?+./fnfile:3> print This is fn.
|
|
|
|
set -x
|
|
[[ 'f o' == 'f x'* || 'b r' != 'z o' && 'squashy sound' < 'squishy sound' ]]
|
|
[[ 'f o' = 'f x'* || 'b r' != 'z o' && 'squashy sound' < 'squishy sound' ]]
|
|
[[ -e nonexistentfile || ( -z '' && -t 3 ) ]]
|
|
set +x
|
|
0:Trace for conditions
|
|
?+(eval):2> [[ 'f o' == f\ x* || 'b r' != z\ o && 'squashy sound' < 'squishy sound' ]]
|
|
?+(eval):3> [[ 'f o' = f\ x* || 'b r' != z\ o && 'squashy sound' < 'squishy sound' ]]
|
|
?+(eval):4> [[ -e nonexistentfile || -z '' && -t 3 ]]
|
|
?+(eval):5> set +x
|
|
|
|
# Part 1: Recurses into nested anonymous functions
|
|
fn() {
|
|
() { () { true } }
|
|
}
|
|
functions -T fn
|
|
fn
|
|
# Part 2: Doesn't recurse into named functions
|
|
gn() { true }
|
|
fn() { gn }
|
|
functions -T fn
|
|
fn
|
|
0:tracing recurses into anonymous functions
|
|
?+fn:1> '(anon)'
|
|
?+(anon):0> '(anon)'
|
|
?+(anon):0> true
|
|
?+fn:0> gn
|