]>
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 expected
=$MH_TEST_DIR/$$.expected
20 expected_err
=$MH_TEST_DIR/$$.expected_err
21 actual
=$MH_TEST_DIR/$$.actual
22 actual_err
=$MH_TEST_DIR/$$.actual_err
23 localmbox
=`${MH_LIBEXEC_DIR}/ap -format "%(localmbox)" 0 | sed 's/^<\(.*\)>$/\1/'`
25 #### Use sendmail/pipe below to override default mts.
26 mts_fakesendmail
="${MHMTSCONF}-fakesendmail"
27 sed -e 's/^mts:.*/mts: sendmail\/pipe/' "${MHMTSCONF}" > "$mts_fakesendmail"
28 printf 'sendmail: %s/test/fakesendmail\n' "$srcdir" >>"$mts_fakesendmail"
29 MHMTSCONF
="$mts_fakesendmail"
31 # arguments: dist switches
34 printf 'send\n' | run_prog dist
"$@" >/dev
/null
36 # fakesendmail drops the message and any cc's into this mbox.
37 mbox
="${MH_TEST_DIR}"/Mail
/fakesendmail.mbox
38 inc
-silent -file "$mbox"
39 rm -f "$mbox" "$mbox.map"
41 # It's hard to calculate the exact Date: header post is going to
42 # use, so we'll just use sed to remove the actual date so we can
43 # easily compare it against our "correct" output.
44 sed -e 's/^Resent-Date:.*/Resent-Date:/' `mhpath last` > "$actual"
46 check
"$expected" "$actual"
51 cat >"$expected" <<EOF
52 Usage: dist [+folder] [msg] [switches]
74 #### Skip nmh intro text.
75 dist
-help | sed '/^$/,$d' >"$actual" 2>&1
76 check
"$expected" "$actual"
81 * ) printf '%s: dist -v generated unexpected output\n' "$0" >&2
82 failed
=`expr ${failed:-0} + 1`;;
85 # check unknown switch
86 run_test
"dist -nonexistent" 'dist: -nonexistent unknown'
88 folder
+outbox
-create -fast >/dev
/null
89 folder
+inbox
-fast 1 >/dev
/null
91 # For most tests, use -nowhatnow and just check that the draft
94 # check basic dist operation, including -noedit and -to
95 cat >"$expected" <<EOF
96 From: Test1 <test1@example.com>
97 To: Some User <user@example.com>
98 Date: Fri, 29 Sep 2006 00:00:00
99 Message-Id: 1@test.nmh
100 Subject: Testing message 1
101 Resent-From: ${localmbox}
102 Resent-To: somebody@example.com
105 This is message number 1
108 test_dist
-noedit -to somebody@example.com
110 # check +folder and msg
111 folder
+outbox
-fast >/dev
/null
113 cat >"$expected" <<EOF
114 From: Test1 <test1@example.com>
115 To: Some User <user@example.com>
116 Date: Fri, 29 Sep 2006 00:00:00
117 Message-Id: 1@test.nmh
118 Subject: Testing message 1
119 Resent-From: ${localmbox}
120 Resent-To: somebody@example.com
123 This is message number 1
126 test_dist
+inbox
1 -noedit -to somebody@example.com
129 cat >"${MH_TEST_DIR}/Mail/distform" <<'EOF'
130 Resent-From: me@example.com
131 Resent-To: you@example.com
134 cat >"$expected" <<EOF
135 From: Test1 <test1@example.com>
136 To: Some User <user@example.com>
137 Date: Fri, 29 Sep 2006 00:00:00
138 Message-Id: 1@test.nmh
139 Subject: Testing message 1
140 Resent-From: me@example.com
141 Resent-To: you@example.com
144 This is message number 1
147 test_dist
1 -noedit -form "${MH_TEST_DIR}"/Mail
/distform
149 rm "${MH_TEST_DIR}"/Mail
/distform
152 cat >"$expected" <<EOF
153 From: Test2 <test2@example.com>
154 To: Some User <user@example.com>
155 Date: Fri, 29 Sep 2006 00:00:00
156 Message-Id: 2@test.nmh
157 Subject: Testing message 2
158 Resent-From: ${localmbox}
159 Resent-To: somebody@example.com
162 This is message number 2
165 test_dist
2 -noedit -to somebody@example.com
-annotate
167 cat >"$expected" <<EOF
169 Resent: somebody@example.com
170 From: Test2 <test2@example.com>
171 To: Some User <user@example.com>
172 Date: Fri, 29 Sep 2006 00:00:00
173 Message-Id: 2@test.nmh
174 Subject: Testing message 2
176 This is message number 2
179 # The annotation is done by a separate process, so we need to wait for
182 until grep '^Resent:' "${MH_TEST_DIR}"/Mail
/inbox
/2 >/dev
/null
; do
186 if [ $i -gt 60 ]; then
187 printf '%s: -annotate failed, will not wait any longer\n' "$0"
192 # Strip date from line of this form:
193 # Resent: Sat, 06 Oct 2012 08:24:08 -0500
194 sed -e 's/^Resent:.*:.*/Resent:/' "${MH_TEST_DIR}"/Mail
/inbox
/2 >"$actual"
196 check
"$expected" "$actual"
199 cat >"$expected" <<EOF
200 From: Test1 <test1@example.com>
201 To: Some User <user@example.com>
202 Date: Fri, 29 Sep 2006 00:00:00
203 Message-Id: 1@test.nmh
204 Subject: Testing message 1
205 Resent-From: ${localmbox}
206 Resent-To: somebody@example.com
209 This is message number 1
212 test_dist
1 -noedit -to somebody@example.com
-annotate -noannotate
214 cat >"$expected" <<EOF
215 From: Test1 <test1@example.com>
216 To: Some User <user@example.com>
217 Date: Fri, 29 Sep 2006 00:00:00
218 Message-Id: 1@test.nmh
219 Subject: Testing message 1
221 This is message number 1
224 check
"${MH_TEST_DIR}"/Mail
/inbox
/1 "$expected" 'keep first'
227 if [ $hard_links_supported -eq 1 ]; then
229 # Hard link the message and verify that the new one doesn't get annotated.
230 cp "${MH_TEST_DIR}/Mail/inbox/8" "${MH_TEST_DIR}/Mail/inbox/8.copy"
231 ln "${MH_TEST_DIR}/Mail/inbox/8" "${MH_TEST_DIR}/Mail/inbox/8.link"
232 cat >"$expected" <<EOF
233 From: Test8 <test8@example.com>
234 To: Some User <user@example.com>
235 Date: Fri, 29 Sep 2006 00:00:00
236 Message-Id: 8@test.nmh
237 Subject: Testing message 8
238 Resent-From: ${localmbox}
239 Resent-To: somebody@example.com
242 This is message number 8
244 test_dist
8 -noedit -to somebody@example.com
-annotate -noinplace
245 mv -f "${MH_TEST_DIR}/Mail/inbox/8.copy" "${MH_TEST_DIR}/Mail/inbox/8"
246 check
"${MH_TEST_DIR}/Mail/inbox/8" "${MH_TEST_DIR}/Mail/inbox/8.link" \
250 # Hard link the message and verify that the new one does get annotated.
251 ln "${MH_TEST_DIR}/Mail/inbox/9" "${MH_TEST_DIR}/Mail/inbox/9.link"
252 cat >"$expected" <<EOF
253 From: Test9 <test9@example.com>
254 To: Some User <user@example.com>
255 Date: Fri, 29 Sep 2006 00:00:00
256 Message-Id: 9@test.nmh
257 Subject: Testing message 9
258 Resent-From: ${localmbox}
259 Resent-To: somebody@example.com
262 This is message number 9
264 test_dist
9 -noedit -to somebody@example.com
-annotate -noinplace -inplace
265 check
"${MH_TEST_DIR}/Mail/inbox/9" "${MH_TEST_DIR}/Mail/inbox/9.link"
269 cat >"$expected" <<EOF
270 From: Test3 <test3@example.com>
271 To: Some User <user@example.com>
272 Date: Fri, 29 Sep 2006 00:00:00
273 Message-Id: 3@test.nmh
274 Subject: Testing message 3
275 Resent-From: ${localmbox}
276 Resent-To: somebody@example.com
279 This is message number 3
282 test_dist
3 -noedit -to somebody@example.com
-draftfolder drafts
285 cat >"$expected" <<EOF
286 From: Test3 <test3@example.com>
287 To: Some User <user@example.com>
288 Date: Fri, 29 Sep 2006 00:00:00
289 Message-Id: 3@test.nmh
290 Subject: Testing message 3
291 Resent-From: ${localmbox}
292 Resent-To: somebody@example.com
295 This is message number 3
298 touch $MH_TEST_DIR/Mail
/drafts
/3
299 test_dist
3 -noedit -to somebody@example.com
-draftfolder drafts
-draftmessage 2
301 # check -nodraftfolder
302 cat >"$expected" <<EOF
303 From: Test3 <test3@example.com>
304 To: Some User <user@example.com>
305 Date: Fri, 29 Sep 2006 00:00:00
306 Message-Id: 3@test.nmh
307 Subject: Testing message 3
308 Resent-From: ${localmbox}
309 Resent-To: somebody@example.com
312 This is message number 3
315 test_dist
3 -noedit -to somebody@example.com
-draftfolder nonexistent \
317 if test -d "${MH_TEST_DIR}/Mail/nonexistent"; then
318 echo "$0: -nodraftfolder test failed."
319 failed
=`expr ${failed:-0} + 1`
323 cat >"$expected" <<EOF
324 From: Test1 <test1@example.com>
325 To: Some User <user@example.com>
326 Date: Fri, 29 Sep 2006 00:00:00
327 Message-Id: 1@test.nmh
328 Subject: Testing message 1
329 Resent-From: me@example.com
330 Resent-To: somebody@example.com
333 This is message number 1
336 test_dist
1 -noedit -to somebody@example.com
-from me@example.com
339 cat >"$expected" <<EOF
340 From: Test1 <test1@example.com>
341 To: Some User <user@example.com>
342 Date: Fri, 29 Sep 2006 00:00:00
343 Message-Id: 1@test.nmh
344 Subject: Testing message 1
345 Resent-From: ${localmbox}
346 Resent-To: somebody@example.com
347 Resent-cc: cc@example.com
350 This is message number 1
353 test_dist
1 -noedit -to somebody@example.com
-cc cc@example.com
356 cat >"$expected" <<EOF
357 From: Test1 <test1@example.com>
358 To: Some User <user@example.com>
359 Date: Fri, 29 Sep 2006 00:00:00
360 Message-Id: 1@test.nmh
361 Subject: Testing message 1
362 Resent-From: ${localmbox}
363 Resent-To: somebody@example.com
366 This is message number 1
369 test_dist
1 -noedit -to somebody@example.com
-fcc outbox
370 run_test
'scan +outbox -width 6' ' 1 '
372 cat >"$expected" <<EOF
373 From: Test1 <test1@example.com>
374 To: Some User <user@example.com>
375 Date: Fri, 29 Sep 2006 00:00:00
376 Message-Id: 1@test.nmh
377 Subject: Testing message 1
378 Resent-From: ${localmbox}
379 Resent-To: somebody@example.com
382 This is message number 1
385 test_dist
+inbox
1 -noedit -to somebody@example.com
-fcc +outbox
386 run_test
'scan +outbox -width 6 2' ' 2 '
389 # Check that dist encodes headers using RFC-2047 properly
392 require_locale en_US.utf
-8 en_US.utf8
393 LC_ALL
=en_US.UTF
-8; export LC_ALL
395 cat >"$expected" <<EOF
396 From: Test1 <test1@example.com>
397 To: Some User <user@example.com>
398 Date: Fri, 29 Sep 2006 00:00:00
399 Message-Id: 1@test.nmh
400 Subject: Testing message 1
401 Resent-From: =?UTF-8?Q?Mr_F=C3=B8o_Bar?= <resent-from@example.com>
402 Resent-To: =?UTF-8?Q?Mr_Nobod=C3=BF?= <resent-to@example.com>
405 This is message number 1
408 test_dist
+inbox
1 -noedit -from 'Mr Føo Bar <resent-from@example.com>' \
409 -to 'Mr Nobodÿ <resent-to@example.com>' -fcc +outbox