Fixed the trap in mhmail.
[mmh] / test / comp / test-comp-format
1 #!/bin/sh
2 #
3 # Tests to see if the -from, -to, -cc, -fcc, and -subject switches to
4 # "comp" work correctly.
5 #
6
7 if test -z "${MH_OBJ_DIR}"; then
8     srcdir=`dirname "$0"`/../..
9     MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
10 fi
11
12 . "$MH_OBJ_DIR/test/common.sh"
13
14 setup_test
15
16 #
17 # Create a test template file (we create one here just in case the master
18 # one changes)
19 #
20
21 form="${MH_TEST_DIR}/$$.components"
22 cat > $form <<EOF
23 %(void{from})%(void(width))%(putaddr From: )
24 %(void{to})%(void(width))%(putaddr To: )
25 %(void{cc})%(void(width))%(putaddr cc: )
26 Fcc: %{fcc}
27 Subject: %{subject}
28 --------
29 EOF
30
31 expected="${MH_TEST_DIR}/$$.expected"
32 actual="${MH_TEST_DIR}/Mail/draft"
33 from="Mr Test User <test@example.com>"
34 to1="User One <userone@example.com>"
35 to2="User Two <usertwo@example.com>"
36 cc1="CC User One <ccuserone@example.com>"
37 cc2="CC User Two <ccusertwo@example.com>"
38 cc3="CC User Three <ccuserthree@example.com>"
39 cc4="CC User Four <ccuserfour@example.com>"
40 fcc1="+nosuchmailbox"
41 fcc2="+nosuchmailbox2"
42 subject="Totally bogus subject"
43
44 cat > $expected <<EOF
45 From: ${from}
46 To: ${to1},
47     ${to2}
48 cc: ${cc1},
49     ${cc2},
50     ${cc3},
51     ${cc4}
52 Fcc: ${fcc1}, ${fcc2}
53 Subject: ${subject}
54 --------
55 EOF
56
57 comp -editor true -form "${form}" -from "${from}" -to "${to1}" -to "${to2}" \
58     -cc "${cc1}" -cc "${cc2}" -cc "${cc3}" -cc "${cc4}" -fcc "${fcc1}" \
59     -fcc "${fcc2}" -subject "${subject}" -width 60 -nowhatnowproc || exit 1
60
61 check "${expected}" "${actual}"
62
63 test "${failed:-0}" -eq 0 && rm "${form}"
64
65 exit $failed