]> diplodocus.org Git - nmh/blob - test/comp/test-comp-format
Reverted commit 9a4b4a3d3b27fe4a7ff6d0b8724ce1c06b5917eb.
[nmh] / 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 check_exit '-eq 1' comp -
17 check_exit '-eq 1' comp -xyzzy
18 check_exit '-eq 0' comp -help
19 check_exit '-eq 0' comp -version
20 check_exit '-eq 1' comp -build -noedit -editor
21 check_exit '-eq 1' comp -whatnowproc
22 check_exit '-eq 1' comp -whatnowproc '' -
23 check_exit '-eq 1' comp -use -nouse -form
24 check_exit '-eq 1' comp -file
25 check_exit '-eq 1' comp -file foo -file
26 check_exit '-eq 1' comp -nodraftfolder -draftfolder
27 check_exit '-eq 1' comp -draftfolder foo -draftfolder
28 check_exit '-eq 1' comp -draftmessage
29 check_exit '-eq 1' comp -draftmessage foo -draftmessage
30 check_exit '-eq 1' comp -to
31 check_exit '-eq 1' comp -cc
32 check_exit '-eq 1' comp -from
33 check_exit '-eq 1' comp -fcc
34 check_exit '-eq 1' comp -fcc @ -
35 check_exit '-eq 1' comp -width
36 check_exit '-eq 1' comp -width 0
37 check_exit '-eq 1' comp -subject
38 check_exit '-eq 1' comp + @
39 check_exit '-eq 1' comp 42 314
40 check_exit '-eq 1' comp -form foo 42
41 check_exit '-eq 1' comp +
42 check_exit '-eq 1' comp 42
43
44 #
45 # Create a test template file (we create one here just in case the master
46 # one changes)
47 #
48
49 form="${MH_TEST_DIR}/$$.components"
50 cat > $form <<EOF
51 %(void{from})%(void(width))%(putaddr From: )
52 %(void{to})%(void(width))%(putaddr To: )
53 %(void{cc})%(void(width))%(putaddr cc: )
54 Fcc: %{fcc}
55 Subject: %{subject}
56 --------
57 EOF
58
59 expected="${MH_TEST_DIR}/$$.expected"
60 actual="${MH_TEST_DIR}/Mail/draft"
61 from="Mr Test User <test@example.com>"
62 to1="User One <userone@example.com>"
63 to2="User Two <usertwo@example.com>"
64 cc1="CC User One <ccuserone@example.com>"
65 cc2="CC User Two <ccusertwo@example.com>"
66 cc3="CC User Three <ccuserthree@example.com>"
67 cc4="CC User Four <ccuserfour@example.com>"
68 fcc1="+nosuchmailbox"
69 fcc2="+nosuchmailbox2"
70 subject="Totally bogus subject"
71
72 cat > $expected <<EOF
73 From: ${from}
74 To: ${to1},
75 ${to2}
76 cc: ${cc1},
77 ${cc2},
78 ${cc3},
79 ${cc4}
80 Fcc: ${fcc1}, ${fcc2}
81 Subject: ${subject}
82 --------
83 EOF
84
85 run_prog \
86 comp -editor true -form "${form}" -from "${from}" -to "${to1}" -to "${to2}" \
87 -cc "${cc1}" -cc "${cc2}" -cc "${cc3}" -cc "${cc4}" -fcc "${fcc1}" \
88 -fcc "${fcc2}" -subject "${subject}" -width 60 -nowhatnowproc || exit 1
89
90 check "${expected}" "${actual}"
91
92 test "${failed:-0}" -eq 0 && rm "${form}"
93
94 exit $failed