mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-02-15 04:32:24 +00:00
tests/variables.sh: fix problems with tracing ('bin/shtests -x')
src/cmd/ksh93/tests/variables.sh: - Unset -x in a command substitution that redirects stderr to stdout; this caused a spurious failure with tracing active. - Execute the nameref tests in a subshell. They modified LINENO, so that all the line numbers after this test were traced and/or reported as 'foo'. . This exposed a bug in namerefs: this is yet another thing that is broken in non-forked/virtual subshells! That is for another commit. For now, fork the subshell and leave a TODO. (cherry picked from commit 8b7f8f9b14523a66bdf337612daef2501c2bb5ba)
This commit is contained in:
parent
80126062cc
commit
a9351320ed
1 changed files with 38 additions and 28 deletions
|
@ -474,7 +474,7 @@ chmod +x $tmp/script
|
||||||
(( .sh.subshell == 1 )) || err_exit ".sh.subshell not working in a subshell"
|
(( .sh.subshell == 1 )) || err_exit ".sh.subshell not working in a subshell"
|
||||||
)
|
)
|
||||||
TIMEFORMAT='this is a test'
|
TIMEFORMAT='this is a test'
|
||||||
[[ $({ { time :;} 2>&1;}) == "$TIMEFORMAT" ]] || err_exit 'TIMEFORMAT not working'
|
[[ $(set +x; { { time :;} 2>&1;}) == "$TIMEFORMAT" ]] || err_exit 'TIMEFORMAT not working'
|
||||||
: ${.sh.version}
|
: ${.sh.version}
|
||||||
[[ $(alias integer) == *.sh.* ]] && err_exit '.sh. prefixed to alias name'
|
[[ $(alias integer) == *.sh.* ]] && err_exit '.sh. prefixed to alias name'
|
||||||
: ${.sh.version}
|
: ${.sh.version}
|
||||||
|
@ -541,6 +541,8 @@ esac
|
||||||
}
|
}
|
||||||
} 2> /dev/null || err_exit "cannot add get discipline to .sh.foobar"
|
} 2> /dev/null || err_exit "cannot add get discipline to .sh.foobar"
|
||||||
[[ ${.sh.foobar} == world ]] || err_exit 'get discipline for .sh.foobar not working'
|
[[ ${.sh.foobar} == world ]] || err_exit 'get discipline for .sh.foobar not working'
|
||||||
|
|
||||||
|
[[ -o xtrace ]] && opt_x=-x || opt_x=+x
|
||||||
x='a|b'
|
x='a|b'
|
||||||
IFS='|'
|
IFS='|'
|
||||||
set -- $x
|
set -- $x
|
||||||
|
@ -548,10 +550,11 @@ set -- $x
|
||||||
exec 3>&2 2> /dev/null
|
exec 3>&2 2> /dev/null
|
||||||
set -x
|
set -x
|
||||||
( IFS= ) 2> /dev/null
|
( IFS= ) 2> /dev/null
|
||||||
set +x
|
set "$opt_x"
|
||||||
exec 2>&3-
|
exec 2>&3-
|
||||||
set -- $x
|
set -- $x
|
||||||
[[ $2 == b ]] || err_exit '$2 should be b after subshell'
|
[[ $2 == b ]] || err_exit '$2 should be b after subshell'
|
||||||
|
|
||||||
: & pid=$!
|
: & pid=$!
|
||||||
( : & )
|
( : & )
|
||||||
[[ $pid == $! ]] || err_exit '$! value not preserved across subshells'
|
[[ $pid == $! ]] || err_exit '$! value not preserved across subshells'
|
||||||
|
@ -616,33 +619,40 @@ set -- {1..32768}
|
||||||
(( $# == 32768 )) || err_exit "\$# failed -- expected 32768, got $#"
|
(( $# == 32768 )) || err_exit "\$# failed -- expected 32768, got $#"
|
||||||
set --
|
set --
|
||||||
|
|
||||||
unset r v x
|
(
|
||||||
path=$PATH
|
# TODO: namerefs are broken in non-forked/virtual subshells.
|
||||||
x=foo
|
# For now, fork it using ulimit; remove the ulimit to expose the test failures.
|
||||||
for v in EDITOR VISUAL OPTIND CDPATH FPATH PATH ENV LINENO RANDOM SECONDS _
|
ulimit -t unlimited
|
||||||
do nameref r=$v
|
|
||||||
unset $v
|
|
||||||
if ( $SHELL -c "unset $v; : \$$v" ) 2>/dev/null
|
|
||||||
then [[ $r ]] && err_exit "unset $v failed -- expected '', got '$r'"
|
|
||||||
r=$x
|
|
||||||
[[ $r == $x ]] || err_exit "$v=$x failed -- expected '$x', got '$r'"
|
|
||||||
else err_exit "unset $v; : \$$v failed"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
x=x
|
unset r v x
|
||||||
for v in LC_ALL LC_CTYPE LC_MESSAGES LC_COLLATE LC_NUMERIC
|
x=foo
|
||||||
do nameref r=$v
|
for v in EDITOR VISUAL OPTIND CDPATH FPATH PATH ENV LINENO RANDOM SECONDS _
|
||||||
unset $v
|
do nameref r=$v
|
||||||
[[ $r ]] && err_exit "unset $v failed -- expected '', got '$r'"
|
unset $v
|
||||||
d=$($SHELL -c "$v=$x" 2>&1)
|
if ( $SHELL -c "unset $v; : \$$v" ) 2>/dev/null
|
||||||
[[ $d ]] || err_exit "$v=$x failed -- expected locale diagnostic"
|
then [[ $r ]] && err_exit "unset $v failed -- expected '', got '$r'"
|
||||||
{ g=$( r=$x; print -- $r ); } 2>/dev/null
|
r=$x
|
||||||
[[ $g == '' ]] || err_exit "$v=$x failed -- expected '', got '$g'"
|
[[ $r == $x ]] || err_exit "$v=$x failed -- expected '$x', got '$r'"
|
||||||
{ g=$( r=C; r=$x; print -- $r ); } 2>/dev/null
|
else err_exit "unset $v; : \$$v failed"
|
||||||
[[ $g == 'C' ]] || err_exit "$v=C; $v=$x failed -- expected 'C', got '$g'"
|
fi
|
||||||
done
|
done
|
||||||
PATH=$path
|
|
||||||
|
x=x
|
||||||
|
for v in LC_ALL LC_CTYPE LC_MESSAGES LC_COLLATE LC_NUMERIC
|
||||||
|
do nameref r=$v
|
||||||
|
unset $v
|
||||||
|
[[ $r ]] && err_exit "unset $v failed -- expected '', got '$r'"
|
||||||
|
d=$($SHELL -c "$v=$x" 2>&1)
|
||||||
|
[[ $d ]] || err_exit "$v=$x failed -- expected locale diagnostic"
|
||||||
|
{ g=$( r=$x; print -- $r ); } 2>/dev/null
|
||||||
|
[[ $g == '' ]] || err_exit "$v=$x failed -- expected '', got '$g'"
|
||||||
|
{ g=$( r=C; r=$x; print -- $r ); } 2>/dev/null
|
||||||
|
[[ $g == 'C' ]] || err_exit "$v=C; $v=$x failed -- expected 'C', got '$g'"
|
||||||
|
done
|
||||||
|
|
||||||
|
exit $Errors
|
||||||
|
)
|
||||||
|
Errors=$? # in case of failures, ensure error count survives subshell
|
||||||
|
|
||||||
cd $tmp
|
cd $tmp
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue