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:
parent
4e285607f0
commit
c6020cf1cd
2 changed files with 18 additions and 5 deletions
|
|
@ -14,18 +14,30 @@
|
|||
#
|
||||
exec >&2
|
||||
set +e
|
||||
|
||||
FAIL=
|
||||
|
||||
fail()
|
||||
{
|
||||
echo " failed: $1"
|
||||
FAIL=41
|
||||
}
|
||||
|
||||
warn()
|
||||
{
|
||||
echo " warning: $1"
|
||||
[ -n "$FAIL" ] || FAIL=42
|
||||
}
|
||||
|
||||
quiet_stderr()
|
||||
{
|
||||
if [ -n "$SHELLTEST_QUIET" ]; then
|
||||
"$@" 2>/dev/null
|
||||
else
|
||||
"$@"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
name=foo.o.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`
|
||||
chicken2="`echo " $spacey" | sed s/a/./g`"
|
||||
chicken2="`quiet_stderr echo " $spacey" | sed s/a/./g`"
|
||||
chicken3=$(echo " $spacey" | sed s/a/./g)
|
||||
chicken4="$(echo " $spacey" | sed s/a/./g)"
|
||||
[ "$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
|
||||
# shells. But to make ash/dash not abort the test script *entirely* when it
|
||||
# fails, we use the $() + eval nonsense.
|
||||
f3=$(eval ': ${f3:=
|
||||
f3=$(quiet_stderr eval ': ${f3:=
|
||||
a
|
||||
b
|
||||
}' && echo "$f3")
|
||||
|
|
@ -176,10 +188,10 @@ c"
|
|||
# it check our syntax.
|
||||
#
|
||||
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 *"
|
||||
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
|
||||
|
||||
|
||||
|
|
@ -334,7 +346,7 @@ rm -f || fail 110
|
|||
HOME="$PWD/space home dir"
|
||||
rm -rf "$HOME"
|
||||
mkdir "$HOME"
|
||||
cd ~ || exit 1
|
||||
quiet_stderr cd ~ || exit 1
|
||||
cd ..
|
||||
rmdir 'space home dir'
|
||||
) || warn 111
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue