Updates to test/common.sh.in:
[mmh] / test / forw / test-forw-format
1 #!/bin/sh
2 #
3 # Tests to see if the -from, -to, -cc, -fcc, and -subject switches to
4 # "forw" 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}/$$.forwcomps"
22 cat > $form <<EOF
23 %(void{nmh-from})%(void(width))%(putaddr From: )
24 %(void{nmh-to})%(void(width))%(putaddr To: )
25 %(void{nmh-cc})%(void(width))%(putaddr cc: )
26 Fcc: %{fcc}
27 Subject:%<{nmh-subject} %(trim)%(putlit)%?{subject} %(trim)%(putlit) (fwd)%>
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
56 ------- Forwarded Message
57
58 EOF
59
60 cat `mhpath +inbox 1` >> "$expected"
61
62 cat >> "$expected" <<EOF
63
64 ------- End of Forwarded Message
65 EOF
66
67 forw -editor true -form "${form}" -from "${from}" -to "${to1}" -to "${to2}" \
68     -cc "${cc1}" -cc "${cc2}" -cc "${cc3}" -cc "${cc4}" -fcc "${fcc1}" \
69     -fcc "${fcc2}" -subject "${subject}" -width 60 -nowhatnowproc 1 || exit 1
70
71 check "${expected}" "${actual}"
72
73 test "${failed:-0}" -eq 0 && rm "${form}"
74
75 exit $failed