]> diplodocus.org Git - nmh/blob - test/repl/test-convert
Added context_find_prefix().
[nmh] / test / repl / test-convert
1 #!/bin/sh
2 ######################################################
3 #
4 # Test repl -convertarg
5 #
6 ######################################################
7
8 set -e
9
10 if test -z "${MH_OBJ_DIR}"; then
11 srcdir=`dirname $0`/../..
12 MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
13 fi
14
15 . "${srcdir}/test/post/test-post-common.sh"
16
17 expected="$MH_TEST_DIR/test-convert$$.expected"
18 actual=`mhpath +`/draft
19
20 printf 'Local-Mailbox: recipient@example.com' >>"$MH"
21
22
23 #### Make sure that this works with 7-bit encoding.
24 LC_ALL=C; export LC_ALL
25
26
27 # check -convertarg with multiple parts and additional text in draft
28 cat >"$expected" <<'EOF'
29 From: recipient@example.com
30 To: sender@example.com
31 cc:
32 Fcc: +outbox
33 Subject: Re: test
34 Comments: In-reply-to sender@example.com
35 message dated "Thu, 11 Dec 2014 08:19:02 -0600."
36 MIME-Version: 1.0
37 Content-Type: text/plain; charset="US-ASCII"
38
39 > This is part 1.
40
41 > This is part 2.
42 EOF
43
44 cat >`mhpath new` <<'EOF'
45 From: sender@example.com
46 To: recipient@example.com
47 Subject: test
48 Date: Thu, 11 Dec 2014 08:19:02 -0600
49 Content-Type: multipart/mixed; boundary="_001_"
50 MIME-Version: 1.0
51
52 --_001_
53 Content-Type: text/plain
54
55 This is part 1.
56
57 --_001_
58 Content-Type: text/plain
59
60 This is part 2.
61
62 --_001_
63 Content-Type: text/enriched
64
65 This should not appear in the reply
66 because the content type isn't matched.
67
68 --_001_--
69 EOF
70
71 repl -noformat -convertarg text/plain '' -nowhatnowproc last
72 mhbuild "$actual"
73 check "$actual" "$expected"
74
75
76 #### Make sure that this works with 8-bit encoding.
77 require_locale en_US.utf-8 en_US.utf8
78 LC_ALL=en_US.UTF-8; export LC_ALL
79
80
81 # check -convertarg with multiple parts and no additional text in draft
82 cat >"$expected" <<'EOF'
83 From: recipient@example.com
84 To: sender@example.com
85 cc:
86 Fcc: +outbox
87 Subject: Re: test
88 Comments: In-reply-to sender@example.com
89 message dated "Thu, 11 Dec 2014 08:19:02 -0600."
90 MIME-Version: 1.0
91 Content-Type: text/plain; charset="UTF-8"
92 Content-Transfer-Encoding: 8bit
93
94 sender@example.com writes:
95
96 > This is part 1.
97
98 > This is part 2.
99 EOF
100
101 cat >`mhpath new` <<'EOF'
102 From: sender@example.com
103 To: recipient@example.com
104 Subject: test
105 Date: Thu, 11 Dec 2014 08:19:02 -0600
106 Content-Type: multipart/mixed; boundary="_001_"
107 MIME-Version: 1.0
108
109 --_001_
110 Content-Type: text/plain
111
112 This is part 1.
113
114 --_001_
115 Content-Type: text/plain
116
117 This is part 2.
118
119 --_001_--
120 EOF
121
122 repl -filter mhl.replywithoutbody -convertarg text/plain '' -nowhatnowproc last
123 mhbuild "$actual"
124 check "$actual" "$expected"
125
126
127 # check message with text part in multipart/related
128 cat >"$expected" <<'EOF'
129 From: recipient@example.com
130 To: sender@example.com
131 cc:
132 Fcc: +outbox
133 Subject: Re: test with text part in multipart/related
134 Comments: In-reply-to sender@example.com
135 message dated "."
136 MIME-Version: 1.0
137 Content-Type: text/plain; charset="UTF-8"
138 Content-Transfer-Encoding: 8bit
139
140 sender@example.com writes:
141
142 > This is a test.
143 EOF
144
145 cat >`mhpath new` <<'EOF'
146 From: sender@example.com
147 To: recipient@example.com
148 Subject: test with text part in multipart/related
149 Content-Type: multipart/alternative; boundary="_001_"
150 MIME-Version: 1.0
151
152 --_001_
153 Content-Type: multipart/related; type="text/plain"; boundary="_002_"
154
155 --_002_
156 Content-Type: text/plain
157
158 This is a test.
159
160 --_002_--
161
162 --_001_--
163 EOF
164
165 repl -filter mhl.replywithoutbody -convertarg text/plain '' -nowhatnowproc last
166 mhbuild "$actual"
167 check "$actual" "$expected"
168
169
170 # check reply to calendar request
171 cat >"$expected" <<'EOF'
172 From: recipient@example.com
173 To: sender@example.com
174 cc:
175 Fcc: +outbox
176 Subject: Re: test iCalendar reply
177 Comments: In-reply-to sender@example.com
178 message dated "."
179 MIME-Version: 1.0
180 Content-Type: text/calendar; method="REPLY"; charset="UTF-8"
181
182 BEGIN:VCALENDAR
183 METHOD:REPLY
184 PRODID:nmh mhical v0.1
185 VERSION:2.0
186 BEGIN:VTIMEZONE
187 TZID:Eastern Standard Time
188 BEGIN:STANDARD
189 DTSTART:16010101T020000
190 TZOFFSETFROM:-0400
191 TZOFFSETTO:-0500
192 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11
193 END:STANDARD
194 BEGIN:DAYLIGHT
195 DTSTART:16010101T020000
196 TZOFFSETFROM:-0500
197 TZOFFSETTO:-0400
198 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3
199 END:DAYLIGHT
200 END:VTIMEZONE
201 BEGIN:VEVENT
202 ORGANIZER;CN=Requester:MAILTO:requester@example.com
203 ATTENDEE;PARTSTAT=ACCEPTED;CN=Recip:MAILTO:recipient@example.com
204 SUMMARY;LANGUAGE=en-US:Accepted: test request
205 DTSTART;TZID=Eastern Standard Time:20150105T090000
206 DTEND;TZID=Eastern Standard Time:20150105T093000
207 UID:0123456789
208 CLASS:PUBLIC
209 PRIORITY:5
210 TRANSP:OPAQUE
211 STATUS:CONFIRMED
212 SEQUENCE:0
213 LOCATION;LANGUAGE=en-US:
214 END:VEVENT
215 END:VCALENDAR
216 EOF
217
218 cat >`mhpath new` <<'EOF'
219 From: sender@example.com
220 To: recipient@example.com
221 Subject: test iCalendar reply
222 Content-Type: text/calendar; charset="UTF-8"
223 MIME-Version: 1.0
224
225 BEGIN:VCALENDAR
226 METHOD:REQUEST
227 PRODID:test-convert
228 VERSION:2.0
229 BEGIN:VTIMEZONE
230 TZID:Eastern Standard Time
231 BEGIN:STANDARD
232 DTSTART:16010101T020000
233 TZOFFSETFROM:-0400
234 TZOFFSETTO:-0500
235 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11
236 END:STANDARD
237 BEGIN:DAYLIGHT
238 DTSTART:16010101T020000
239 TZOFFSETFROM:-0500
240 TZOFFSETTO:-0400
241 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3
242 END:DAYLIGHT
243 END:VTIMEZONE
244 BEGIN:VEVENT
245 ORGANIZER;CN=Requester:MAILTO:requester@example.com
246 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee1
247 :MAILTO:requestee1@example.com
248 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee2
249 :MAILTO:requestee2@example.com
250 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee3
251 :MAILTO:requestee3@example.com
252 SUMMARY;LANGUAGE=en-US:test request
253 DTSTART;TZID=Eastern Standard Time:20150105T090000
254 DTEND;TZID=Eastern Standard Time:20150105T093000
255 UID:0123456789
256 CLASS:PUBLIC
257 PRIORITY:5
258 DTSTAMP:20150101T171600Z
259 TRANSP:OPAQUE
260 STATUS:CONFIRMED
261 SEQUENCE:0
262 LOCATION;LANGUAGE=en-US:
263 BEGIN:VALARM
264 ACTION:DISPLAY
265 DESCRIPTION:REMINDER
266 TRIGGER;RELATED=START:-PT15M
267 END:VALARM
268 END:VEVENT
269 END:VCALENDAR
270 EOF
271
272 actual="$MH_TEST_DIR/test-convert$$.actual"
273 repl -noformat \
274 -convertargs text/calendar '-reply accept -contenttype' -nowhatnowproc last
275 SIGNATURE=Recip mhbuild - <`mhpath +`/draft | egrep -v '^DTSTAMP:' >"$actual"
276 check "$actual" "$expected"
277
278
279 exit $failed