Fix test.sh on shells without echo -n

Some systems have a version of /bin/sh whose builtin echo doesn't
support the -n option used in test/test.sh.  /bin/echo, however,
usually does.  This patch makes us use /bin/echo for echo -n whenever
it is present.

Also, our use of echo -n really only made sense when suppressing all
test output.  Since test output isn't suppressed when logging to a
file, this pach makes us stop using echo -n when logging to a file.
This commit is contained in:
Nick Mathewson 2010-01-12 15:58:36 -05:00
parent b9f43b231f
commit 94131e92b8

View File

@ -5,6 +5,14 @@ then
TEST_OUTPUT_FILE=/dev/null
fi
# /bin/echo is a little more likely to support -n than sh's builtin echo.
if test -x /bin/echo
then
ECHO=/bin/echo
else
ECHO=echo
fi
touch "$TEST_OUTPUT_FILE" || exit 1
TEST_DIR=.
@ -29,6 +37,12 @@ announce () {
echo $@ >>"$TEST_OUTPUT_FILE"
}
announce_n () {
$ECHO -n $@
echo $@ >>"$TEST_OUTPUT_FILE"
}
run_tests () {
if $TEST_DIR/test-init 2>>"$TEST_OUTPUT_FILE" ;
then
@ -38,28 +52,28 @@ run_tests () {
return
fi
announce -n " test-eof: "
announce_n " test-eof: "
if $TEST_DIR/test-eof >>"$TEST_OUTPUT_FILE" ;
then
announce OKAY ;
else
announce FAILED ;
fi
announce -n " test-weof: "
announce_n " test-weof: "
if $TEST_DIR/test-weof >>"$TEST_OUTPUT_FILE" ;
then
announce OKAY ;
else
announce FAILED ;
fi
announce -n " test-time: "
announce_n " test-time: "
if $TEST_DIR/test-time >>"$TEST_OUTPUT_FILE" ;
then
announce OKAY ;
else
announce FAILED ;
fi
announce -n " regress: "
announce_n " regress: "
if $TEST_DIR/regress >>"$TEST_OUTPUT_FILE" ;
then
announce OKAY ;