From 94131e92b827ab2b46a4cb7ded52cdc143f807a8 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 12 Jan 2010 15:58:36 -0500 Subject: [PATCH] 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. --- test/test.sh | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/test/test.sh b/test/test.sh index b59c667f..be35f684 100755 --- a/test/test.sh +++ b/test/test.sh @@ -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 ;