]> diplodocus.org Git - nmh/blob - test/repl/test-repl
sbr/oauth.c: Remove const to avoid curl's debug_callback warning.
[nmh] / test / repl / test-repl
1 #!/bin/sh
2 ######################################################
3 #
4 # Test repl
5 #
6 ######################################################
7
8 # This is not a comprehensive test of repl, but some day it will be :-)
9 # Please add to it.
10
11 set -e
12
13 if test -z "${MH_OBJ_DIR}"; then
14 srcdir=`dirname $0`/../..
15 MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
16 fi
17
18 . "$MH_OBJ_DIR/test/common.sh"
19
20 setup_test
21
22 check_exit '-eq 1' repl -
23
24 expected=$MH_TEST_DIR/$$.expected
25 actual=$MH_TEST_DIR/Mail/draft
26
27
28 # check -help
29 start_test -help
30 cat >$expected <<EOF
31 Usage: repl: [+folder] [msg] [switches]
32 switches are:
33 -[no]group
34 -[no]annotate
35 -[no]cc all|to|cc|me
36 -draftfolder +folder
37 -draftmessage msg
38 -nodraftfolder
39 -editor editor
40 -noedit
41 -convertargs type argstring
42 -fcc folder
43 -filter filterfile
44 -form formfile
45 -([no]forma)t
46 -[no]inplace
47 -[no]mime
48 -[no]query
49 -whatnowproc program
50 -nowhatnowproc
51 -width columns
52 -version
53 -help
54 -(file) file
55 -(build)
56 -[no]atfile
57 -fmtproc program
58 -nofmtproc
59 EOF
60
61 #### Skip nmh intro text.
62 run_prog repl -help | sed '/^$/,$d' >"$actual" 2>&1
63 check "$expected" "$actual"
64
65 # check -version
66 start_test -version
67 case `repl -v` in
68 repl\ --*) ;;
69 * ) printf '%s: repl -v generated unexpected output\n' "$0" >&2
70 failed=`expr ${failed:-0} + 1`;;
71 esac
72
73 # check unknown switch
74 start_test 'unknown switch'
75 run_test "repl -nonexistent" 'repl: -nonexistent unknown'
76
77 # check with no switches
78 start_test 'with no switches'
79 run_test "repl" 'repl: no cur message'
80
81
82 printf 'Local-Mailbox: mymailbox@localhost\n' >> "$MH"
83
84 # check -cc me
85 start_test '-cc me'
86 cat >$expected <<EOF
87 From: mymailbox@localhost
88 To: Test1 <test1@example.com>
89 cc: mymailbox@localhost
90 Fcc: +outbox
91 Subject: Re: Testing message 1
92 In-reply-to: 1@test.nmh
93 References: 1@test.nmh
94 Comments: In-reply-to Test1 <test1@example.com>
95 message dated "Fri, 29 Sep 2006 00:00:00."
96 --------
97 EOF
98
99 run_prog repl -cc me -editor true -nowhatnowproc 1
100 check $expected $actual
101
102 # check -nocc me
103 start_test '-nocc me'
104 cat >$expected <<EOF
105 From: mymailbox@localhost
106 To: Test1 <test1@example.com>
107 cc:
108 Fcc: +outbox
109 Subject: Re: Testing message 1
110 In-reply-to: 1@test.nmh
111 References: 1@test.nmh
112 Comments: In-reply-to Test1 <test1@example.com>
113 message dated "Fri, 29 Sep 2006 00:00:00."
114 --------
115 EOF
116
117 run_prog repl -cc me -nocc me -editor true -nowhatnowproc 1
118 check $expected $actual
119
120 # check -cc me with Local- and Alternate-Mailbox addtions, Bug #36635
121 start_test '-cc me with Local- and Alternate-Mailbox addtions, Bug #36635'
122 # -nocc me doesn't account for Alternate-Mailboxes.
123 printf 'Alternate-Mailboxes: user@example.com\n' >> "$MH"
124
125 cat >$expected <<EOF
126 From: mymailbox@localhost
127 To: Test1 <test1@example.com>
128 cc: mymailbox@localhost
129 Fcc: +outbox
130 Subject: Re: Testing message 1
131 In-reply-to: 1@test.nmh
132 References: 1@test.nmh
133 Comments: In-reply-to Test1 <test1@example.com>
134 message dated "Fri, 29 Sep 2006 00:00:00."
135 --------
136 EOF
137
138 run_prog repl -cc me -editor true -nowhatnowproc 1
139 check $expected $actual
140
141
142 # check -nocc me with Local- and Alternate-Mailbox addtions, Bug #36635
143 start_test '-nocc me with Local- and Alternate-Mailbox addtions, Bug #36635'
144 # -nocc me doesn't account for Alternate-Mailboxes.
145 cat >$expected <<EOF
146 From: mymailbox@localhost
147 To: Test1 <test1@example.com>
148 cc:
149 Fcc: +outbox
150 Subject: Re: Testing message 1
151 In-reply-to: 1@test.nmh
152 References: 1@test.nmh
153 Comments: In-reply-to Test1 <test1@example.com>
154 message dated "Fri, 29 Sep 2006 00:00:00."
155 --------
156 EOF
157
158 run_prog repl -cc me -nocc me -editor true -nowhatnowproc 1
159 check $expected $actual
160
161
162 # check quoting of local part of invalid address, Bug #26780
163 start_test 'quoting of local part of invalid address, Bug #26780'
164 cat >`mhpath new` <<EOF
165 From: Test11 <test11@example.com>
166 To: before_auser@example.com, A. User <auser@example.com>,
167 after_user@example.com
168 Date: Fri, 29 Sep 2006 00:00:11
169 Message-Id: 11@test.nmh
170 Subject: Testing message 11
171
172 This is message number 11
173
174 EOF
175
176 cat >$expected <<EOF
177 From: mymailbox@localhost
178 To: Test11 <test11@example.com>
179 cc: before_auser@example.com, "A. User" <auser@example.com>,
180 after_user@example.com
181 Fcc: +outbox
182 Subject: Re: Testing message 11
183 In-reply-to: 11@test.nmh
184 References: 11@test.nmh
185 Comments: In-reply-to Test11 <test11@example.com>
186 message dated "Fri, 29 Sep 2006 00:00:11."
187 --------
188 EOF
189
190 run_prog repl -cc to -editor true -nowhatnowproc 11
191 check $expected $actual
192
193
194 # check that Fcc: header isn't propagated
195 start_test "Fcc: header isn't propagated"
196 form="${MH_TEST_DIR}/$$.components"
197 cat > $form <<'EOF'
198 From: sender@example.com
199 %<{from}%(void(width))%(putaddr To: )%>
200 Fcc:%<{fcc} %{fcc}%>
201 Subject: %<{subject}Re: %(void{subject})%(trim)%(putstr)%>
202 --------
203 EOF
204 cat > $expected <<EOF
205 From: sender@example.com
206 To: recipient@example.com
207 Fcc:
208 Subject: Re: suppress Fcc:
209 --------
210 EOF
211 cat > `mhpath new`<<EOF
212 From: recipient@example.com
213 To: sender@example.com
214 Fcc: +mischievous
215 Subject: suppress Fcc:
216 --------
217 EOF
218
219 run_prog repl -form "${form}" -nowhatnowproc last
220 check "${expected}" "${actual}"
221
222
223 # check -fcc with Fcc: in replied-to message
224 start_test '-fcc with Fcc: in replied-to message'
225 form="${MH_TEST_DIR}/$$.components"
226 cat > $expected <<EOF
227 From: sender@example.com
228 To: recipient@example.com
229 Fcc: +myoutbox
230 Subject: Re: suppress Fcc:
231 --------
232 EOF
233
234 run_prog repl -fcc +myoutbox -form "${form}" -nowhatnowproc last
235 check "${expected}" "${actual}"
236
237 test "${failed:-0}" -eq 0 && rm "${form}"
238
239
240 finish_test
241 exit ${failed:-0}