t/shelltest.od: quiet some error messages that get printed during testing.

If the error message only triggered a shelltest warning instead of a
failure, then they're harmless, so we might as well silence them when
running 'redo test' (which runs t/shelltest.do, which enables
SHELLTEST_QUIET).  We still want to print them when actually testing out
shelltest.od, though, to help with debugging the script.
This commit is contained in:
Avery Pennarun 2011-05-08 01:23:32 -04:00
commit c6020cf1cd
2 changed files with 18 additions and 5 deletions

View file

@ -1,4 +1,5 @@
set +e set +e
export SHELLTEST_QUIET=1
( . ./shelltest.od ) ( . ./shelltest.od )
RV=$? RV=$?
case $RV in case $RV in

View file

@ -14,18 +14,30 @@
# #
exec >&2 exec >&2
set +e set +e
FAIL= FAIL=
fail() fail()
{ {
echo " failed: $1" echo " failed: $1"
FAIL=41 FAIL=41
} }
warn() warn()
{ {
echo " warning: $1" echo " warning: $1"
[ -n "$FAIL" ] || FAIL=42 [ -n "$FAIL" ] || FAIL=42
} }
quiet_stderr()
{
if [ -n "$SHELLTEST_QUIET" ]; then
"$@" 2>/dev/null
else
"$@"
fi
}
name=foo.o.o name=foo.o.o
ext=.o ext=.o
@ -69,7 +81,7 @@ t1=$(n 1 2 3 4 5 6 7 8 9 xx yy)
chicken1=`echo " $spacey" | sed s/a/./g` chicken1=`echo " $spacey" | sed s/a/./g`
chicken2="`echo " $spacey" | sed s/a/./g`" chicken2="`quiet_stderr echo " $spacey" | sed s/a/./g`"
chicken3=$(echo " $spacey" | sed s/a/./g) chicken3=$(echo " $spacey" | sed s/a/./g)
chicken4="$(echo " $spacey" | sed s/a/./g)" chicken4="$(echo " $spacey" | sed s/a/./g)"
[ "$chicken1" = " this h.s * .nd sp.ces" ] || fail 11 [ "$chicken1" = " this h.s * .nd sp.ces" ] || fail 11
@ -92,7 +104,7 @@ out=$(echo ${f1:-foo} ${f2:-foo} ${g1:=foo} ${g2:=foo})
# quoting, which is apparently required by POSIX but not supported in some # quoting, which is apparently required by POSIX but not supported in some
# shells. But to make ash/dash not abort the test script *entirely* when it # shells. But to make ash/dash not abort the test script *entirely* when it
# fails, we use the $() + eval nonsense. # fails, we use the $() + eval nonsense.
f3=$(eval ': ${f3:= f3=$(quiet_stderr eval ': ${f3:=
a a
b b
}' && echo "$f3") }' && echo "$f3")
@ -176,10 +188,10 @@ c"
# it check our syntax. # it check our syntax.
# #
bob="a b *" bob="a b *"
bob=$(eval 'export bob=$bob:hello'; echo "$bob") bob=$(quiet_stderr eval 'export bob=$bob:hello'; echo "$bob")
#[ "$bob" = "a b *:hello" ] || warn 46 #[ "$bob" = "a b *:hello" ] || warn 46
bob="a b *" bob="a b *"
nob=$(eval 'f() { local nob=$bob:hello; echo "$nob"; }'; f) nob=$(eval 'f() { local nob=$bob:hello; echo "$nob"; }'; quiet_stderr f)
#[ "$nob" = "a b *:hello" ] || warn 47 #[ "$nob" = "a b *:hello" ] || warn 47
@ -334,7 +346,7 @@ rm -f || fail 110
HOME="$PWD/space home dir" HOME="$PWD/space home dir"
rm -rf "$HOME" rm -rf "$HOME"
mkdir "$HOME" mkdir "$HOME"
cd ~ || exit 1 quiet_stderr cd ~ || exit 1
cd .. cd ..
rmdir 'space home dir' rmdir 'space home dir'
) || warn 111 ) || warn 111