Some tests failed because they displayed the user's local
[mmh] / test / runtest
1 #!/bin/sh
2
3 status=1
4
5 [ $# -eq 1 ]  ||  echo "usage: $0 "'<testname>'
6
7 # Get full pathnames that we'll need.
8 cd `dirname $0`
9
10 export MH_TEST_DIR=`pwd`/testinstall
11 export MH=$MH_TEST_DIR/Mail/.mh_profile
12 export PATH=$MH_TEST_DIR/bin:$PATH
13 export MH_TEST_COMMON=$PWD/common.sh
14
15 #### Some tests use mhshow to display headers.  It relies on mhl's
16 #### default mhl.headers, which runs the date through the pretty
17 #### function.  That displays the date with the user's current
18 #### timezone.  All of the tests expect GMT, so fool them into using
19 #### that.
20 export TZ=GMT
21
22 [ -d $MH_TEST_DIR ] || ./setup-test
23
24 # clean old test data
25 trap "rm -rf $MH_TEST_DIR/Mail; exit \$status" 0
26 # setup test data
27 rm -rf $MH_TEST_DIR/Mail
28 mkdir $MH_TEST_DIR/Mail
29 echo "Path: $MH_TEST_DIR/Mail" > $MH
30 folder -create +inbox > /dev/null
31 # create 10 basic messages
32 for i in `seq 1 10`;
33 do
34     cat > $MH_TEST_DIR/Mail/inbox/$i <<EOF
35 From: Test$i <test$i@example.com>
36 To: Some User <user@example.com>
37 Date: Fri, 29 Sep 2006 00:00:00
38 Subject: Testing message $i
39
40 This is message number $i
41 EOF
42 done
43
44 # now run the test
45 set +e
46 /bin/sh $1
47 return_value=$?
48 set -e
49
50 if [ $return_value -eq 0 ]; then
51     echo Test $1 PASS
52     status=0
53 elif [ $return_value -eq 120 ]; then
54     # indicates test was skipped (eg needed program not found)
55     # test itself should have printed a message about this,
56     # so print nothing here.
57     :
58 else
59     echo Test $1 FAIL
60 fi