Fix spelling and encoding errors in manpages and an error message
[mmh] / test / runtest
index 0b18653..9f35ade 100755 (executable)
@@ -2,56 +2,70 @@
 
 set -e
 
-if [ ! -e test-temp-dir ]; then
-   echo "test-temp-dir not found: running setup-test"
-   ./setup-test
+export MH_TEST_COMMON="$PWD/common.sh"
+
+if [ ! -f test-temp-dir ]; then
+       echo "test-temp-dir not found: running setup-test"
+       ./setup-test
 fi
 
 export MH_TEST_DIR=`cat test-temp-dir`
 
-if [ ! -e "$MH_TEST_DIR/bld/Makefile" ]; then
-   echo "temporary directory missing or broken: running setup-test"
-   ./setup-test
-   export MH_TEST_DIR=`cat test-temp-dir`
+if [ ! -f "$MH_TEST_DIR/build/Makefile" ]; then
+       echo "temporary directory missing or broken: running setup-test"
+       ./setup-test
+       export MH_TEST_DIR=`cat test-temp-dir`
 fi
 
-export MH=$MH_TEST_DIR/Mail/.mh_profile
-export PATH=$MH_TEST_DIR/bin:$PATH
-
-export MH_TEST_COMMON=$PWD/common.sh
+unset MMHP MMHC
+export PATH="$MH_TEST_DIR/bin:$PATH"
+export MMH="$MH_TEST_DIR/.mmh"
+MAILDIR="$MH_TEST_DIR/Mail"
 
 # clean old test data
-rm -rf $MH_TEST_DIR/Mail
-# setup test data
-mkdir $MH_TEST_DIR/Mail
-echo "Path: $MH_TEST_DIR/Mail" > $MH
-folder -create +inbox > /dev/null
+rm -rf "$MAILDIR" "$MMH"
+
+# setup mmh
+mkdir "$MAILDIR" "$MMH"
+cat >"$MMH/profile" <<-!
+       Path: $MAILDIR
+       Inbox: +inbox
+!
+folder -create `mhparam inbox` >/dev/null
+folder -create `mhparam trashfolder` >/dev/null
+folder -create `mhparam draftfolder` >/dev/null
+
 # create 10 basic messages
 for i in `seq 1 10`;
 do
-    cat > $MH_TEST_DIR/Mail/inbox/$i <<EOF
-From: Test$i <test$i@example.com>
-To: Some User <user@example.com>
-Date: Fri, 29 Sep 2006 00:00:00
-Subject: Testing message $i
-
-This is message number $i
-EOF
+       cat >"$MAILDIR/inbox/$i" <<-!
+               From: Test$i <test$i@example.com>
+               To: Some User <user@example.com>
+               Date: Fri, 29 Sep 2006 00:00:00
+               Subject: Testing message $i
+
+               This is message number $i
+       !
 done
+folder +inbox >/dev/null
 
 # now run the test
 set +e
-/bin/sh $1
+export SHELL="${SHELL:-/bin/sh}"
+/bin/sh "$1"
 return_value=$?
 set -e
 
 if [ $return_value -eq 0 ] ; then
-    echo Test $1 PASS
+       printf "Test %-60s\tPASS\n" "$1"
+       exit 0
 elif [ $return_value -eq 120 ]; then
-    # indicates test was skipped (eg needed program not found)
-    # test itself should have printed a message about this,
-    # so print nothing here.
-    :
+       # indicates test was skipped (eg needed program not found)
+       # test itself should have printed a message about this,
+       # so print nothing here.
+       printf "Test %-60s\tSKIP\n" "$1"
+       exit 2
 else
-    echo Test $1 FAIL
+       printf "Test %-60s\tFAIL\n" "$1"
+       exit 1
 fi