]>
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
-
20 check_exit
'-eq 1' dist
-editor
21 check_exit
'-eq 1' dist
-editor foo
-editor
22 check_exit
'-eq 1' dist
-nowhatnowproc -whatnowproc foo
-whatnowproc
23 check_exit
'-eq 1' dist
-file
24 check_exit
'-eq 1' dist
-file foo
-file bar
25 check_exit
'-eq 1' dist
-form
26 check_exit
'-eq 1' dist
-draftfolder
27 check_exit
'-eq 1' dist
-draftfolder foo
-draftfolder bar
28 check_exit
'-eq 1' dist
-draftmessage
29 check_exit
'-eq 1' dist
-draftmessage 42 -draftmessage 314
30 check_exit
'-eq 1' dist
-from
31 check_exit
'-eq 1' dist
-to
32 check_exit
'-eq 1' dist
-cc
33 check_exit
'-eq 1' dist
-fcc
34 check_exit
'-eq 1' dist
-width
35 check_exit
'-eq 1' dist
-width 42 -width 0
36 check_exit
'-eq 1' dist
-atfile -noatfile -
37 check_exit
'-eq 1' dist
+ @
38 check_exit
'-eq 1' dist
42 314
39 check_exit
'-eq 1' dist
-file foo
42
41 expected
=$MH_TEST_DIR/$$.expected
42 expected_err
=$MH_TEST_DIR/$$.expected_err
43 actual
=$MH_TEST_DIR/$$.actual
44 actual_err
=$MH_TEST_DIR/$$.actual_err
45 localmbox
=`${MH_LIBEXEC_DIR}/ap -format "%(localmbox)" 0 | sed 's/^<\(.*\)>$/\1/'`
47 #### Use sendmail/pipe below to override default mts.
48 mts_fakesendmail
="${MHMTSCONF}-fakesendmail"
49 sed -e 's/^mts:.*/mts: sendmail\/pipe/' "${MHMTSCONF}" > "$mts_fakesendmail"
50 printf 'sendmail: %s/test/fakesendmail\n' "$srcdir" >>"$mts_fakesendmail"
51 MHMTSCONF
="$mts_fakesendmail"
53 # arguments: dist switches
56 printf 'send\n' | run_prog dist
"$@" >/dev
/null
58 # fakesendmail drops the message and any cc's into this mbox.
59 mbox
="${MH_TEST_DIR}"/Mail
/fakesendmail.mbox
60 inc
-silent -file "$mbox"
61 rm -f "$mbox" "$mbox.map"
63 # It's hard to calculate the exact Date: header post is going to
64 # use, so we'll just use sed to remove the actual date so we can
65 # easily compare it against our "correct" output.
66 sed -e 's/^Resent-Date:.*/Resent-Date:/' `mhpath last` > "$actual"
68 check
"$expected" "$actual"
73 cat >"$expected" <<EOF
74 Usage: dist [+folder] [msg] [switches]
96 #### Skip nmh intro text.
97 dist
-help | sed '/^$/,$d' >"$actual" 2>&1
98 check
"$expected" "$actual"
103 * ) printf '%s: dist -v generated unexpected output\n' "$0" >&2
104 failed
=`expr ${failed:-0} + 1`;;
107 # check unknown switch
108 run_test
"dist -nonexistent" 'dist: -nonexistent unknown'
110 folder
+outbox
-create -fast >/dev
/null
111 folder
+inbox
-fast 1 >/dev
/null
113 # For most tests, use -nowhatnow and just check that the draft
116 # check basic dist operation, including -noedit and -to
117 cat >"$expected" <<EOF
118 From: Test1 <test1@example.com>
119 To: Some User <user@example.com>
120 Date: Fri, 29 Sep 2006 00:00:00
121 Message-Id: 1@test.nmh
122 Subject: Testing message 1
123 Resent-From: ${localmbox}
124 Resent-To: somebody@example.com
127 This is message number 1
130 test_dist
-noedit -to somebody@example.com
132 # check +folder and msg
133 folder
+outbox
-fast >/dev
/null
135 cat >"$expected" <<EOF
136 From: Test1 <test1@example.com>
137 To: Some User <user@example.com>
138 Date: Fri, 29 Sep 2006 00:00:00
139 Message-Id: 1@test.nmh
140 Subject: Testing message 1
141 Resent-From: ${localmbox}
142 Resent-To: somebody@example.com
145 This is message number 1
148 test_dist
+inbox
1 -noedit -to somebody@example.com
151 cat >"${MH_TEST_DIR}/Mail/distform" <<'EOF'
152 Resent-From: me@example.com
153 Resent-To: you@example.com
156 cat >"$expected" <<EOF
157 From: Test1 <test1@example.com>
158 To: Some User <user@example.com>
159 Date: Fri, 29 Sep 2006 00:00:00
160 Message-Id: 1@test.nmh
161 Subject: Testing message 1
162 Resent-From: me@example.com
163 Resent-To: you@example.com
166 This is message number 1
169 test_dist
1 -noedit -form "${MH_TEST_DIR}"/Mail
/distform
171 rm "${MH_TEST_DIR}"/Mail
/distform
174 cat >"$expected" <<EOF
175 From: Test2 <test2@example.com>
176 To: Some User <user@example.com>
177 Date: Fri, 29 Sep 2006 00:00:00
178 Message-Id: 2@test.nmh
179 Subject: Testing message 2
180 Resent-From: ${localmbox}
181 Resent-To: somebody@example.com
184 This is message number 2
187 test_dist
2 -noedit -to somebody@example.com
-annotate
189 cat >"$expected" <<EOF
191 Resent: somebody@example.com
192 From: Test2 <test2@example.com>
193 To: Some User <user@example.com>
194 Date: Fri, 29 Sep 2006 00:00:00
195 Message-Id: 2@test.nmh
196 Subject: Testing message 2
198 This is message number 2
201 # The annotation is done by a separate process, so we need to wait for
204 until grep '^Resent:' "${MH_TEST_DIR}"/Mail
/inbox
/2 >/dev
/null
; do
208 if [ $i -gt 60 ]; then
209 printf '%s: -annotate failed, will not wait any longer\n' "$0"
214 # Strip date from line of this form:
215 # Resent: Sat, 06 Oct 2012 08:24:08 -0500
216 sed -e 's/^Resent:.*:.*/Resent:/' "${MH_TEST_DIR}"/Mail
/inbox
/2 >"$actual"
218 check
"$expected" "$actual"
221 cat >"$expected" <<EOF
222 From: Test1 <test1@example.com>
223 To: Some User <user@example.com>
224 Date: Fri, 29 Sep 2006 00:00:00
225 Message-Id: 1@test.nmh
226 Subject: Testing message 1
227 Resent-From: ${localmbox}
228 Resent-To: somebody@example.com
231 This is message number 1
234 test_dist
1 -noedit -to somebody@example.com
-annotate -noannotate
236 cat >"$expected" <<EOF
237 From: Test1 <test1@example.com>
238 To: Some User <user@example.com>
239 Date: Fri, 29 Sep 2006 00:00:00
240 Message-Id: 1@test.nmh
241 Subject: Testing message 1
243 This is message number 1
246 check
"${MH_TEST_DIR}"/Mail
/inbox
/1 "$expected" 'keep first'
249 if [ $hard_links_supported -eq 1 ]; then
251 # Hard link the message and verify that the new one doesn't get annotated.
252 cp "${MH_TEST_DIR}/Mail/inbox/8" "${MH_TEST_DIR}/Mail/inbox/8.copy"
253 ln "${MH_TEST_DIR}/Mail/inbox/8" "${MH_TEST_DIR}/Mail/inbox/8.link"
254 cat >"$expected" <<EOF
255 From: Test8 <test8@example.com>
256 To: Some User <user@example.com>
257 Date: Fri, 29 Sep 2006 00:00:00
258 Message-Id: 8@test.nmh
259 Subject: Testing message 8
260 Resent-From: ${localmbox}
261 Resent-To: somebody@example.com
264 This is message number 8
266 test_dist
8 -noedit -to somebody@example.com
-annotate -noinplace
267 mv -f "${MH_TEST_DIR}/Mail/inbox/8.copy" "${MH_TEST_DIR}/Mail/inbox/8"
268 check
"${MH_TEST_DIR}/Mail/inbox/8" "${MH_TEST_DIR}/Mail/inbox/8.link" \
272 # Hard link the message and verify that the new one does get annotated.
273 ln "${MH_TEST_DIR}/Mail/inbox/9" "${MH_TEST_DIR}/Mail/inbox/9.link"
274 cat >"$expected" <<EOF
275 From: Test9 <test9@example.com>
276 To: Some User <user@example.com>
277 Date: Fri, 29 Sep 2006 00:00:00
278 Message-Id: 9@test.nmh
279 Subject: Testing message 9
280 Resent-From: ${localmbox}
281 Resent-To: somebody@example.com
284 This is message number 9
286 test_dist
9 -noedit -to somebody@example.com
-annotate -noinplace -inplace
287 check
"${MH_TEST_DIR}/Mail/inbox/9" "${MH_TEST_DIR}/Mail/inbox/9.link"
291 cat >"$expected" <<EOF
292 From: Test3 <test3@example.com>
293 To: Some User <user@example.com>
294 Date: Fri, 29 Sep 2006 00:00:00
295 Message-Id: 3@test.nmh
296 Subject: Testing message 3
297 Resent-From: ${localmbox}
298 Resent-To: somebody@example.com
301 This is message number 3
304 test_dist
3 -noedit -to somebody@example.com
-draftfolder drafts
307 cat >"$expected" <<EOF
308 From: Test3 <test3@example.com>
309 To: Some User <user@example.com>
310 Date: Fri, 29 Sep 2006 00:00:00
311 Message-Id: 3@test.nmh
312 Subject: Testing message 3
313 Resent-From: ${localmbox}
314 Resent-To: somebody@example.com
317 This is message number 3
320 touch $MH_TEST_DIR/Mail
/drafts
/3
321 test_dist
3 -noedit -to somebody@example.com
-draftfolder drafts
-draftmessage 2
323 # check -nodraftfolder
324 cat >"$expected" <<EOF
325 From: Test3 <test3@example.com>
326 To: Some User <user@example.com>
327 Date: Fri, 29 Sep 2006 00:00:00
328 Message-Id: 3@test.nmh
329 Subject: Testing message 3
330 Resent-From: ${localmbox}
331 Resent-To: somebody@example.com
334 This is message number 3
337 test_dist
3 -noedit -to somebody@example.com
-draftfolder nonexistent \
339 if test -d "${MH_TEST_DIR}/Mail/nonexistent"; then
340 echo "$0: -nodraftfolder test failed."
341 failed
=`expr ${failed:-0} + 1`
345 cat >"$expected" <<EOF
346 From: Test1 <test1@example.com>
347 To: Some User <user@example.com>
348 Date: Fri, 29 Sep 2006 00:00:00
349 Message-Id: 1@test.nmh
350 Subject: Testing message 1
351 Resent-From: me@example.com
352 Resent-To: somebody@example.com
355 This is message number 1
358 test_dist
1 -noedit -to somebody@example.com
-from me@example.com
361 cat >"$expected" <<EOF
362 From: Test1 <test1@example.com>
363 To: Some User <user@example.com>
364 Date: Fri, 29 Sep 2006 00:00:00
365 Message-Id: 1@test.nmh
366 Subject: Testing message 1
367 Resent-From: ${localmbox}
368 Resent-To: somebody@example.com
369 Resent-cc: cc@example.com
372 This is message number 1
375 test_dist
1 -noedit -to somebody@example.com
-cc cc@example.com
378 cat >"$expected" <<EOF
379 From: Test1 <test1@example.com>
380 To: Some User <user@example.com>
381 Date: Fri, 29 Sep 2006 00:00:00
382 Message-Id: 1@test.nmh
383 Subject: Testing message 1
384 Resent-From: ${localmbox}
385 Resent-To: somebody@example.com
388 This is message number 1
391 test_dist
1 -noedit -to somebody@example.com
-fcc outbox
392 run_test
'scan +outbox -width 6' ' 1 '
394 cat >"$expected" <<EOF
395 From: Test1 <test1@example.com>
396 To: Some User <user@example.com>
397 Date: Fri, 29 Sep 2006 00:00:00
398 Message-Id: 1@test.nmh
399 Subject: Testing message 1
400 Resent-From: ${localmbox}
401 Resent-To: somebody@example.com
404 This is message number 1
407 test_dist
+inbox
1 -noedit -to somebody@example.com
-fcc +outbox
408 run_test
'scan +outbox -width 6 2' ' 2 '
411 # Check that dist encodes headers using RFC-2047 properly
414 require_locale en_US.UTF
-8 en_US.UTF8 en_US.utf
-8 en_US.utf8
416 cat >"$expected" <<EOF
417 From: Test1 <test1@example.com>
418 To: Some User <user@example.com>
419 Date: Fri, 29 Sep 2006 00:00:00
420 Message-Id: 1@test.nmh
421 Subject: Testing message 1
422 Resent-From: =?UTF-8?Q?Mr_F=C3=B8o_Bar?= <resent-from@example.com>
423 Resent-To: =?UTF-8?Q?Mr_Nobod=C3=BF?= <resent-to@example.com>
426 This is message number 1
429 test_dist
+inbox
1 -noedit -from 'Mr Føo Bar <resent-from@example.com>' \
430 -to 'Mr Nobodÿ <resent-to@example.com>' -fcc +outbox