]>
diplodocus.org Git - nmh/blob - test/dist/test-dist
2 ######################################################
6 ######################################################
10 if test -z "${MH_OBJ_DIR}"; then
11 srcdir
=`dirname $0`/..
/..
12 MH_OBJ_DIR
=`cd $srcdir && pwd`; export MH_OBJ_DIR
15 .
"$MH_OBJ_DIR/test/common.sh"
19 check_exit
'-eq 1' dist
- # gcov
21 expected
=$MH_TEST_DIR/$$.expected
22 expected_err
=$MH_TEST_DIR/$$.expected_err
23 actual
=$MH_TEST_DIR/$$.actual
24 actual_err
=$MH_TEST_DIR/$$.actual_err
25 localmbox
=`${MH_LIBEXEC_DIR}/ap -format "%(localmbox)" 0 | sed 's/^<\(.*\)>$/\1/'`
27 #### Use sendmail/pipe below to override default mts.
28 mts_fakesendmail
="${MHMTSCONF}-fakesendmail"
29 sed -e 's/^mts:.*/mts: sendmail\/pipe/' "${MHMTSCONF}" > "$mts_fakesendmail"
30 printf 'sendmail: %s/test/fakesendmail\n' "$srcdir" >>"$mts_fakesendmail"
31 MHMTSCONF
="$mts_fakesendmail"
33 # arguments: dist switches
36 printf 'send\n' | run_prog dist
"$@" >/dev
/null
38 # fakesendmail drops the message and any cc's into this mbox.
39 mbox
="${MH_TEST_DIR}"/Mail
/fakesendmail.mbox
40 inc
-silent -file "$mbox"
41 rm -f "$mbox" "$mbox.map"
43 # It's hard to calculate the exact Date: header post is going to
44 # use, so we'll just use sed to remove the actual date so we can
45 # easily compare it against our "correct" output.
46 sed -e 's/^Resent-Date:.*/Resent-Date:/' `mhpath last` > "$actual"
48 check
"$expected" "$actual"
53 cat >"$expected" <<EOF
54 Usage: dist [+folder] [msg] [switches]
76 #### Skip nmh intro text.
77 dist
-help | sed '/^$/,$d' >"$actual" 2>&1
78 check
"$expected" "$actual"
83 * ) printf '%s: dist -v generated unexpected output\n' "$0" >&2
84 failed
=`expr ${failed:-0} + 1`;;
87 # check unknown switch
88 run_test
"dist -nonexistent" 'dist: -nonexistent unknown'
90 folder
+outbox
-create -fast >/dev
/null
91 folder
+inbox
-fast 1 >/dev
/null
93 # For most tests, use -nowhatnow and just check that the draft
96 # check basic dist operation, including -noedit and -to
97 cat >"$expected" <<EOF
98 From: Test1 <test1@example.com>
99 To: Some User <user@example.com>
100 Date: Fri, 29 Sep 2006 00:00:00
101 Message-Id: 1@test.nmh
102 Subject: Testing message 1
103 Resent-From: ${localmbox}
104 Resent-To: somebody@example.com
107 This is message number 1
110 test_dist
-noedit -to somebody@example.com
112 # check +folder and msg
113 folder
+outbox
-fast >/dev
/null
115 cat >"$expected" <<EOF
116 From: Test1 <test1@example.com>
117 To: Some User <user@example.com>
118 Date: Fri, 29 Sep 2006 00:00:00
119 Message-Id: 1@test.nmh
120 Subject: Testing message 1
121 Resent-From: ${localmbox}
122 Resent-To: somebody@example.com
125 This is message number 1
128 test_dist
+inbox
1 -noedit -to somebody@example.com
131 cat >"${MH_TEST_DIR}/Mail/distform" <<'EOF'
132 Resent-From: me@example.com
133 Resent-To: you@example.com
136 cat >"$expected" <<EOF
137 From: Test1 <test1@example.com>
138 To: Some User <user@example.com>
139 Date: Fri, 29 Sep 2006 00:00:00
140 Message-Id: 1@test.nmh
141 Subject: Testing message 1
142 Resent-From: me@example.com
143 Resent-To: you@example.com
146 This is message number 1
149 test_dist
1 -noedit -form "${MH_TEST_DIR}"/Mail
/distform
151 rm "${MH_TEST_DIR}"/Mail
/distform
154 cat >"$expected" <<EOF
155 From: Test2 <test2@example.com>
156 To: Some User <user@example.com>
157 Date: Fri, 29 Sep 2006 00:00:00
158 Message-Id: 2@test.nmh
159 Subject: Testing message 2
160 Resent-From: ${localmbox}
161 Resent-To: somebody@example.com
164 This is message number 2
167 test_dist
2 -noedit -to somebody@example.com
-annotate
169 cat >"$expected" <<EOF
171 Resent: somebody@example.com
172 From: Test2 <test2@example.com>
173 To: Some User <user@example.com>
174 Date: Fri, 29 Sep 2006 00:00:00
175 Message-Id: 2@test.nmh
176 Subject: Testing message 2
178 This is message number 2
181 # The annotation is done by a separate process, so we need to wait for
184 until grep '^Resent:' "${MH_TEST_DIR}"/Mail
/inbox
/2 >/dev
/null
; do
188 if [ $i -gt 60 ]; then
189 printf '%s: -annotate failed, will not wait any longer\n' "$0"
194 # Strip date from line of this form:
195 # Resent: Sat, 06 Oct 2012 08:24:08 -0500
196 sed -e 's/^Resent:.*:.*/Resent:/' "${MH_TEST_DIR}"/Mail
/inbox
/2 >"$actual"
198 check
"$expected" "$actual"
201 cat >"$expected" <<EOF
202 From: Test1 <test1@example.com>
203 To: Some User <user@example.com>
204 Date: Fri, 29 Sep 2006 00:00:00
205 Message-Id: 1@test.nmh
206 Subject: Testing message 1
207 Resent-From: ${localmbox}
208 Resent-To: somebody@example.com
211 This is message number 1
214 test_dist
1 -noedit -to somebody@example.com
-annotate -noannotate
216 cat >"$expected" <<EOF
217 From: Test1 <test1@example.com>
218 To: Some User <user@example.com>
219 Date: Fri, 29 Sep 2006 00:00:00
220 Message-Id: 1@test.nmh
221 Subject: Testing message 1
223 This is message number 1
226 check
"${MH_TEST_DIR}"/Mail
/inbox
/1 "$expected" 'keep first'
229 if [ $hard_links_supported -eq 1 ]; then
231 # Hard link the message and verify that the new one doesn't get annotated.
232 cp "${MH_TEST_DIR}/Mail/inbox/8" "${MH_TEST_DIR}/Mail/inbox/8.copy"
233 ln "${MH_TEST_DIR}/Mail/inbox/8" "${MH_TEST_DIR}/Mail/inbox/8.link"
234 cat >"$expected" <<EOF
235 From: Test8 <test8@example.com>
236 To: Some User <user@example.com>
237 Date: Fri, 29 Sep 2006 00:00:00
238 Message-Id: 8@test.nmh
239 Subject: Testing message 8
240 Resent-From: ${localmbox}
241 Resent-To: somebody@example.com
244 This is message number 8
246 test_dist
8 -noedit -to somebody@example.com
-annotate -noinplace
247 mv -f "${MH_TEST_DIR}/Mail/inbox/8.copy" "${MH_TEST_DIR}/Mail/inbox/8"
248 check
"${MH_TEST_DIR}/Mail/inbox/8" "${MH_TEST_DIR}/Mail/inbox/8.link" \
252 # Hard link the message and verify that the new one does get annotated.
253 ln "${MH_TEST_DIR}/Mail/inbox/9" "${MH_TEST_DIR}/Mail/inbox/9.link"
254 cat >"$expected" <<EOF
255 From: Test9 <test9@example.com>
256 To: Some User <user@example.com>
257 Date: Fri, 29 Sep 2006 00:00:00
258 Message-Id: 9@test.nmh
259 Subject: Testing message 9
260 Resent-From: ${localmbox}
261 Resent-To: somebody@example.com
264 This is message number 9
266 test_dist
9 -noedit -to somebody@example.com
-annotate -noinplace -inplace
267 check
"${MH_TEST_DIR}/Mail/inbox/9" "${MH_TEST_DIR}/Mail/inbox/9.link"
271 cat >"$expected" <<EOF
272 From: Test3 <test3@example.com>
273 To: Some User <user@example.com>
274 Date: Fri, 29 Sep 2006 00:00:00
275 Message-Id: 3@test.nmh
276 Subject: Testing message 3
277 Resent-From: ${localmbox}
278 Resent-To: somebody@example.com
281 This is message number 3
284 test_dist
3 -noedit -to somebody@example.com
-draftfolder drafts
287 cat >"$expected" <<EOF
288 From: Test3 <test3@example.com>
289 To: Some User <user@example.com>
290 Date: Fri, 29 Sep 2006 00:00:00
291 Message-Id: 3@test.nmh
292 Subject: Testing message 3
293 Resent-From: ${localmbox}
294 Resent-To: somebody@example.com
297 This is message number 3
300 touch $MH_TEST_DIR/Mail
/drafts
/3
301 test_dist
3 -noedit -to somebody@example.com
-draftfolder drafts
-draftmessage 2
303 # check -nodraftfolder
304 cat >"$expected" <<EOF
305 From: Test3 <test3@example.com>
306 To: Some User <user@example.com>
307 Date: Fri, 29 Sep 2006 00:00:00
308 Message-Id: 3@test.nmh
309 Subject: Testing message 3
310 Resent-From: ${localmbox}
311 Resent-To: somebody@example.com
314 This is message number 3
317 test_dist
3 -noedit -to somebody@example.com
-draftfolder nonexistent \
319 if test -d "${MH_TEST_DIR}/Mail/nonexistent"; then
320 echo "$0: -nodraftfolder test failed."
321 failed
=`expr ${failed:-0} + 1`
325 cat >"$expected" <<EOF
326 From: Test1 <test1@example.com>
327 To: Some User <user@example.com>
328 Date: Fri, 29 Sep 2006 00:00:00
329 Message-Id: 1@test.nmh
330 Subject: Testing message 1
331 Resent-From: me@example.com
332 Resent-To: somebody@example.com
335 This is message number 1
338 test_dist
1 -noedit -to somebody@example.com
-from me@example.com
341 cat >"$expected" <<EOF
342 From: Test1 <test1@example.com>
343 To: Some User <user@example.com>
344 Date: Fri, 29 Sep 2006 00:00:00
345 Message-Id: 1@test.nmh
346 Subject: Testing message 1
347 Resent-From: ${localmbox}
348 Resent-To: somebody@example.com
349 Resent-cc: cc@example.com
352 This is message number 1
355 test_dist
1 -noedit -to somebody@example.com
-cc cc@example.com
358 cat >"$expected" <<EOF
359 From: Test1 <test1@example.com>
360 To: Some User <user@example.com>
361 Date: Fri, 29 Sep 2006 00:00:00
362 Message-Id: 1@test.nmh
363 Subject: Testing message 1
364 Resent-From: ${localmbox}
365 Resent-To: somebody@example.com
368 This is message number 1
371 test_dist
1 -noedit -to somebody@example.com
-fcc outbox
372 run_test
'scan +outbox -width 6' ' 1 '
374 cat >"$expected" <<EOF
375 From: Test1 <test1@example.com>
376 To: Some User <user@example.com>
377 Date: Fri, 29 Sep 2006 00:00:00
378 Message-Id: 1@test.nmh
379 Subject: Testing message 1
380 Resent-From: ${localmbox}
381 Resent-To: somebody@example.com
384 This is message number 1
387 test_dist
+inbox
1 -noedit -to somebody@example.com
-fcc +outbox
388 run_test
'scan +outbox -width 6 2' ' 2 '
391 # Check that dist encodes headers using RFC-2047 properly
394 require_locale en_US.UTF
-8 en_US.UTF8 en_US.utf
-8 en_US.utf8
396 cat >"$expected" <<EOF
397 From: Test1 <test1@example.com>
398 To: Some User <user@example.com>
399 Date: Fri, 29 Sep 2006 00:00:00
400 Message-Id: 1@test.nmh
401 Subject: Testing message 1
402 Resent-From: =?UTF-8?Q?Mr_F=C3=B8o_Bar?= <resent-from@example.com>
403 Resent-To: =?UTF-8?Q?Mr_Nobod=C3=BF?= <resent-to@example.com>
406 This is message number 1
409 test_dist
+inbox
1 -noedit -from 'Mr Føo Bar <resent-from@example.com>' \
410 -to 'Mr Nobodÿ <resent-to@example.com>' -fcc +outbox