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_LIB_DIR}/ap -format "%(localmbox)" 0`
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' | 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 dist -help >"$actual" 2>&1
75 check "$expected" "$actual"
80 * ) printf '%s: dist -v generated unexpected output\n' "$0" >&2
81 failed=`expr ${failed:-0} + 1`;;
84 # check unknown switch
85 run_test "dist -nonexistent" 'dist: -nonexistent unknown'
87 folder +outbox -create -fast >/dev/null
88 folder +inbox -fast 1 >/dev/null
90 # For most tests, use -nowhatnow and just check that the draft
93 # check basic dist operation, including -noedit and -to
94 cat >"$expected" <<EOF
95 From: Test1 <test1@example.com>
96 To: Some User <user@example.com>
97 Date: Fri, 29 Sep 2006 00:00:00
98 Message-Id: 1@test.nmh
99 Subject: Testing message 1
100 Resent-From: ${localmbox}
101 Resent-To: somebody@example.com
104 This is message number 1
107 test_dist -noedit -to somebody@example.com
109 # check +folder and msg
110 folder +outbox -fast >/dev/null
112 cat >"$expected" <<EOF
113 From: Test1 <test1@example.com>
114 To: Some User <user@example.com>
115 Date: Fri, 29 Sep 2006 00:00:00
116 Message-Id: 1@test.nmh
117 Subject: Testing message 1
118 Resent-From: ${localmbox}
119 Resent-To: somebody@example.com
122 This is message number 1
125 test_dist +inbox 1 -noedit -to somebody@example.com
128 cat >"${MH_TEST_DIR}/Mail/distform" <<'EOF'
129 Resent-From: me@example.com
130 Resent-To: you@example.com
133 cat >"$expected" <<EOF
134 From: Test1 <test1@example.com>
135 To: Some User <user@example.com>
136 Date: Fri, 29 Sep 2006 00:00:00
137 Message-Id: 1@test.nmh
138 Subject: Testing message 1
139 Resent-From: me@example.com
140 Resent-To: you@example.com
143 This is message number 1
146 test_dist 1 -noedit -form "${MH_TEST_DIR}"/Mail/distform
148 rm "${MH_TEST_DIR}"/Mail/distform
151 cat >"$expected" <<EOF
152 From: Test2 <test2@example.com>
153 To: Some User <user@example.com>
154 Date: Fri, 29 Sep 2006 00:00:00
155 Message-Id: 2@test.nmh
156 Subject: Testing message 2
157 Resent-From: ${localmbox}
158 Resent-To: somebody@example.com
161 This is message number 2
164 test_dist 2 -noedit -to somebody@example.com -annotate
166 cat >"$expected" <<EOF
168 Resent: somebody@example.com
169 From: Test2 <test2@example.com>
170 To: Some User <user@example.com>
171 Date: Fri, 29 Sep 2006 00:00:00
172 Message-Id: 2@test.nmh
173 Subject: Testing message 2
175 This is message number 2
178 # The annotation is done by a separate process, so we need to wait for
181 until grep '^Resent:' "${MH_TEST_DIR}"/Mail/inbox/2 >/dev/null; do
185 if [ $i -gt 60 ]; then
186 printf '%s: -annotate failed, will not wait any longer\n' "$0"
191 # Strip date from line of this form:
192 # Resent: Sat, 06 Oct 2012 08:24:08 -0500
193 sed -e 's/^Resent:.*:.*/Resent:/' "${MH_TEST_DIR}"/Mail/inbox/2 >"$actual"
195 check "$expected" "$actual"
198 cat >"$expected" <<EOF
199 From: Test1 <test1@example.com>
200 To: Some User <user@example.com>
201 Date: Fri, 29 Sep 2006 00:00:00
202 Message-Id: 1@test.nmh
203 Subject: Testing message 1
204 Resent-From: ${localmbox}
205 Resent-To: somebody@example.com
208 This is message number 1
211 test_dist 1 -noedit -to somebody@example.com -annotate -noannotate
213 cat >"$expected" <<EOF
214 From: Test1 <test1@example.com>
215 To: Some User <user@example.com>
216 Date: Fri, 29 Sep 2006 00:00:00
217 Message-Id: 1@test.nmh
218 Subject: Testing message 1
220 This is message number 1
223 check "${MH_TEST_DIR}"/Mail/inbox/1 "$expected" 'keep first'
226 if [ $hard_links_supported -eq 1 ]; then
228 # Hard link the message and verify that the new one doesn't get annotated.
229 cp "${MH_TEST_DIR}/Mail/inbox/8" "${MH_TEST_DIR}/Mail/inbox/8.copy"
230 ln "${MH_TEST_DIR}/Mail/inbox/8" "${MH_TEST_DIR}/Mail/inbox/8.link"
231 cat >"$expected" <<EOF
232 From: Test8 <test8@example.com>
233 To: Some User <user@example.com>
234 Date: Fri, 29 Sep 2006 00:00:00
235 Message-Id: 8@test.nmh
236 Subject: Testing message 8
237 Resent-From: ${localmbox}
238 Resent-To: somebody@example.com
241 This is message number 8
243 test_dist 8 -noedit -to somebody@example.com -annotate -noinplace
244 mv -f "${MH_TEST_DIR}/Mail/inbox/8.copy" "${MH_TEST_DIR}/Mail/inbox/8"
245 check "${MH_TEST_DIR}/Mail/inbox/8" "${MH_TEST_DIR}/Mail/inbox/8.link" \
249 # Hard link the message and verify that the new one does get annotated.
250 ln "${MH_TEST_DIR}/Mail/inbox/8" "${MH_TEST_DIR}/Mail/inbox/8.link"
251 cat >"$expected" <<EOF
252 From: Test8 <test8@example.com>
253 To: Some User <user@example.com>
254 Date: Fri, 29 Sep 2006 00:00:00
255 Message-Id: 8@test.nmh
256 Subject: Testing message 8
257 Resent-From: ${localmbox}
258 Resent-To: somebody@example.com
261 This is message number 8
263 test_dist 8 -noedit -to somebody@example.com -annotate -noinplace -inplace
264 check "${MH_TEST_DIR}/Mail/inbox/8" "${MH_TEST_DIR}/Mail/inbox/8.link"
268 cat >"$expected" <<EOF
269 From: Test3 <test3@example.com>
270 To: Some User <user@example.com>
271 Date: Fri, 29 Sep 2006 00:00:00
272 Message-Id: 3@test.nmh
273 Subject: Testing message 3
274 Resent-From: ${localmbox}
275 Resent-To: somebody@example.com
278 This is message number 3
281 test_dist 3 -noedit -to somebody@example.com -draftfolder drafts
284 cat >"$expected" <<EOF
285 From: Test3 <test3@example.com>
286 To: Some User <user@example.com>
287 Date: Fri, 29 Sep 2006 00:00:00
288 Message-Id: 3@test.nmh
289 Subject: Testing message 3
290 Resent-From: ${localmbox}
291 Resent-To: somebody@example.com
294 This is message number 3
297 touch $MH_TEST_DIR/Mail/drafts/3
298 test_dist 3 -noedit -to somebody@example.com -draftfolder drafts -draftmessage 2
300 # check -nodraftfolder
301 cat >"$expected" <<EOF
302 From: Test3 <test3@example.com>
303 To: Some User <user@example.com>
304 Date: Fri, 29 Sep 2006 00:00:00
305 Message-Id: 3@test.nmh
306 Subject: Testing message 3
307 Resent-From: ${localmbox}
308 Resent-To: somebody@example.com
311 This is message number 3
314 test_dist 3 -noedit -to somebody@example.com -draftfolder nonexistent \
316 if test -d "${MH_TEST_DIR}/Mail/nonexistent"; then
317 echo "$0: -nodraftfolder test failed."
318 failed=`expr ${failed:-0} + 1`
322 cat >"$expected" <<EOF
323 From: Test1 <test1@example.com>
324 To: Some User <user@example.com>
325 Date: Fri, 29 Sep 2006 00:00:00
326 Message-Id: 1@test.nmh
327 Subject: Testing message 1
328 Resent-From: me@example.com
329 Resent-To: somebody@example.com
332 This is message number 1
335 test_dist 1 -noedit -to somebody@example.com -from me@example.com
338 cat >"$expected" <<EOF
339 From: Test1 <test1@example.com>
340 To: Some User <user@example.com>
341 Date: Fri, 29 Sep 2006 00:00:00
342 Message-Id: 1@test.nmh
343 Subject: Testing message 1
344 Resent-From: ${localmbox}
345 Resent-To: somebody@example.com
346 Resent-cc: cc@example.com
349 This is message number 1
352 test_dist 1 -noedit -to somebody@example.com -cc cc@example.com
355 cat >"$expected" <<EOF
356 From: Test1 <test1@example.com>
357 To: Some User <user@example.com>
358 Date: Fri, 29 Sep 2006 00:00:00
359 Message-Id: 1@test.nmh
360 Subject: Testing message 1
361 Resent-From: ${localmbox}
362 Resent-To: somebody@example.com
365 This is message number 1
368 test_dist 1 -noedit -to somebody@example.com -fcc outbox
369 run_test 'scan +outbox -width 6' ' 1 '
371 cat >"$expected" <<EOF
372 From: Test1 <test1@example.com>
373 To: Some User <user@example.com>
374 Date: Fri, 29 Sep 2006 00:00:00
375 Message-Id: 1@test.nmh
376 Subject: Testing message 1
377 Resent-From: ${localmbox}
378 Resent-To: somebody@example.com
381 This is message number 1
384 test_dist +inbox 1 -noedit -to somebody@example.com -fcc +outbox
385 run_test 'scan +outbox -width 6 2' ' 2 '