shelltest.od: we accidentally treated some fails as mere warnings.
We were setting a global variable FAIL on failure, but if we failed inside a subshell (which a very small number of tests might do), this setting would be lost. The script output (a series of failed/warning lines) was still valid, but not the return code, so the shell might be selected even if one of these tests failed. To avoid the problem, put the fail/warning state in the filesystem instead, which is shared across subshells.
This commit is contained in:
parent
9aa8061e83
commit
6cf06f707a
5 changed files with 12 additions and 9 deletions
|
|
@ -13,7 +13,7 @@ WARN=
|
||||||
# use some non-portable feature.
|
# use some non-portable feature.
|
||||||
for sh in dash /usr/xpg4/bin/sh ash posh mksh ksh ksh88 ksh93 pdksh \
|
for sh in dash /usr/xpg4/bin/sh ash posh mksh ksh ksh88 ksh93 pdksh \
|
||||||
zsh bash busybox /bin/sh; do
|
zsh bash busybox /bin/sh; do
|
||||||
printf "%-30s" "Testing $sh..."
|
printf " %-22s" "$sh..."
|
||||||
FOUND=`which $sh 2>/dev/null` || { echo "missing"; continue; }
|
FOUND=`which $sh 2>/dev/null` || { echo "missing"; continue; }
|
||||||
|
|
||||||
# It's important for the file to actually be named 'sh'. Some
|
# It's important for the file to actually be named 'sh'. Some
|
||||||
|
|
|
||||||
2
t/.gitignore
vendored
2
t/.gitignore
vendored
|
|
@ -1,4 +1,6 @@
|
||||||
/broken
|
/broken
|
||||||
/shellfile
|
/shellfile
|
||||||
|
/shelltest.warned
|
||||||
|
/shelltest.failed
|
||||||
/stress.log
|
/stress.log
|
||||||
/flush-cache
|
/flush-cache
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1 @@
|
||||||
redo nonshelltest shelltest vartest
|
redo nonshelltest shelltest vartest
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,5 +2,6 @@
|
||||||
sed 's/\.do$//' |
|
sed 's/\.do$//' |
|
||||||
xargs redo
|
xargs redo
|
||||||
|
|
||||||
rm -f broken shellfile *~ .*~ stress.log flush-cache
|
rm -f broken shellfile shelltest.warned shelltest.failed \
|
||||||
|
*~ .*~ stress.log flush-cache
|
||||||
rm -rf 'space home dir'
|
rm -rf 'space home dir'
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
# Most of these tests were inspired by:
|
# Most of these tests were inspired by:
|
||||||
# http://www.gnu.org/software/hello/manual/autoconf/Shell-Substitutions.html
|
# http://www.gnu.org/software/hello/manual/autoconf/Shell-Substitutions.html
|
||||||
#
|
#
|
||||||
# Note that this file isn't really a test for POSIX compliance. It's a test
|
# Note that this file isn't exactly a test for POSIX compliance. It's a test
|
||||||
# for usefulness-compliance, that is, interpreting POSIX in a particular way
|
# for usefulness-compliance, that is, interpreting POSIX in a particular way
|
||||||
# for consistency, so that users of redo can depend on all the following
|
# for consistency, so that users of redo can depend on all the following
|
||||||
# functionality.
|
# functionality.
|
||||||
|
|
@ -15,18 +15,18 @@
|
||||||
exec >&2
|
exec >&2
|
||||||
set +e
|
set +e
|
||||||
|
|
||||||
FAIL=
|
rm -f shelltest.failed shelltest.warned
|
||||||
|
|
||||||
fail()
|
fail()
|
||||||
{
|
{
|
||||||
echo " failed: $1"
|
echo " failed: $1"
|
||||||
FAIL=41
|
: >shelltest.failed
|
||||||
}
|
}
|
||||||
|
|
||||||
warn()
|
warn()
|
||||||
{
|
{
|
||||||
echo " warning: $1"
|
echo " warning: $1"
|
||||||
[ -n "$FAIL" ] || FAIL=42
|
: >shelltest.warned
|
||||||
}
|
}
|
||||||
|
|
||||||
quiet_stderr()
|
quiet_stderr()
|
||||||
|
|
@ -417,5 +417,6 @@ set x y z
|
||||||
x=$(printf "a%-5sc" "b")
|
x=$(printf "a%-5sc" "b")
|
||||||
[ "$x" = "ab c" ] || warn 119
|
[ "$x" = "ab c" ] || warn 119
|
||||||
|
|
||||||
[ -n "$FAIL" ] || exit 40
|
[ -e shelltest.failed ] && exit 41
|
||||||
exit $FAIL
|
[ -e shelltest.warned ] && exit 42
|
||||||
|
exit 40
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue