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: ${srcdir}/test/fakesendmail\n" >>"$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 "$0: dist -v generated unexpected output\n" >&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 Subject: Testing message 1
99 Resent-From: ${localmbox}
100 Resent-To: somebody@example.com
103 This is message number 1
106 test_dist -noedit -to somebody@example.com
108 # check +folder and msg
109 folder +outbox -fast >/dev/null
111 cat >"$expected" <<EOF
112 From: Test1 <test1@example.com>
113 To: Some User <user@example.com>
114 Date: Fri, 29 Sep 2006 00:00:00
115 Subject: Testing message 1
116 Resent-From: ${localmbox}
117 Resent-To: somebody@example.com
120 This is message number 1
123 test_dist +inbox 1 -noedit -to somebody@example.com
126 cat >"${MH_TEST_DIR}/Mail/distform" <<'EOF'
127 Resent-From: me@example.com
128 Resent-To: you@example.com
131 cat >"$expected" <<EOF
132 From: Test1 <test1@example.com>
133 To: Some User <user@example.com>
134 Date: Fri, 29 Sep 2006 00:00:00
135 Subject: Testing message 1
136 Resent-From: me@example.com
137 Resent-To: you@example.com
140 This is message number 1
143 test_dist 1 -noedit -form "${MH_TEST_DIR}"/Mail/distform
145 rm "${MH_TEST_DIR}"/Mail/distform
148 cat >"$expected" <<EOF
149 From: Test2 <test2@example.com>
150 To: Some User <user@example.com>
151 Date: Fri, 29 Sep 2006 00:00:00
152 Subject: Testing message 2
153 Resent-From: ${localmbox}
154 Resent-To: somebody@example.com
157 This is message number 2
160 test_dist 2 -noedit -to somebody@example.com -annotate
162 cat >"$expected" <<EOF
164 Resent: somebody@example.com
165 From: Test2 <test2@example.com>
166 To: Some User <user@example.com>
167 Date: Fri, 29 Sep 2006 00:00:00
168 Subject: Testing message 2
170 This is message number 2
173 # The annotation is done by a separate process, so we need to wait for
176 until grep '^Resent:' "${MH_TEST_DIR}"/Mail/inbox/2 >/dev/null; do
180 if [ $i -gt 60 ]; then
181 printf "$0: -annotate failed, will not wait any longer\n"
186 # Strip date from line of this form:
187 # Resent: Sat, 06 Oct 2012 08:24:08 -0500
188 sed -e 's/^Resent:.*:.*/Resent:/' "${MH_TEST_DIR}"/Mail/inbox/2 >"$actual"
190 check "$expected" "$actual"
193 cat >"$expected" <<EOF
194 From: Test1 <test1@example.com>
195 To: Some User <user@example.com>
196 Date: Fri, 29 Sep 2006 00:00:00
197 Subject: Testing message 1
198 Resent-From: ${localmbox}
199 Resent-To: somebody@example.com
202 This is message number 1
205 test_dist 1 -noedit -to somebody@example.com -annotate -noannotate
207 cat >"$expected" <<EOF
208 From: Test1 <test1@example.com>
209 To: Some User <user@example.com>
210 Date: Fri, 29 Sep 2006 00:00:00
211 Subject: Testing message 1
213 This is message number 1
216 check "${MH_TEST_DIR}"/Mail/inbox/1 "$expected" 'keep first'
219 if [ $hard_links_supported -eq 1 ]; then
221 # Hard link the message and verify that the new one doesn't get annotated.
222 cp "${MH_TEST_DIR}/Mail/inbox/8" "${MH_TEST_DIR}/Mail/inbox/8.copy"
223 ln "${MH_TEST_DIR}/Mail/inbox/8" "${MH_TEST_DIR}/Mail/inbox/8.link"
224 cat >"$expected" <<EOF
225 From: Test8 <test8@example.com>
226 To: Some User <user@example.com>
227 Date: Fri, 29 Sep 2006 00:00:00
228 Subject: Testing message 8
229 Resent-From: ${localmbox}
230 Resent-To: somebody@example.com
233 This is message number 8
235 test_dist 8 -noedit -to somebody@example.com -annotate -noinplace
236 mv -f "${MH_TEST_DIR}/Mail/inbox/8.copy" "${MH_TEST_DIR}/Mail/inbox/8"
237 check "${MH_TEST_DIR}/Mail/inbox/8" "${MH_TEST_DIR}/Mail/inbox/8.link" \
241 # Hard link the message and verify that the new one does get annotated.
242 ln "${MH_TEST_DIR}/Mail/inbox/8" "${MH_TEST_DIR}/Mail/inbox/8.link"
243 cat >"$expected" <<EOF
244 From: Test8 <test8@example.com>
245 To: Some User <user@example.com>
246 Date: Fri, 29 Sep 2006 00:00:00
247 Subject: Testing message 8
248 Resent-From: ${localmbox}
249 Resent-To: somebody@example.com
252 This is message number 8
254 test_dist 8 -noedit -to somebody@example.com -annotate -noinplace -inplace
255 check "${MH_TEST_DIR}/Mail/inbox/8" "${MH_TEST_DIR}/Mail/inbox/8.link"
259 cat >"$expected" <<EOF
260 From: Test3 <test3@example.com>
261 To: Some User <user@example.com>
262 Date: Fri, 29 Sep 2006 00:00:00
263 Subject: Testing message 3
264 Resent-From: ${localmbox}
265 Resent-To: somebody@example.com
268 This is message number 3
271 test_dist 3 -noedit -to somebody@example.com -draftfolder drafts
274 cat >"$expected" <<EOF
275 From: Test3 <test3@example.com>
276 To: Some User <user@example.com>
277 Date: Fri, 29 Sep 2006 00:00:00
278 Subject: Testing message 3
279 Resent-From: ${localmbox}
280 Resent-To: somebody@example.com
283 This is message number 3
286 touch $MH_TEST_DIR/Mail/drafts/3
287 test_dist 3 -noedit -to somebody@example.com -draftfolder drafts -draftmessage 2
289 # check -nodraftfolder
290 cat >"$expected" <<EOF
291 From: Test3 <test3@example.com>
292 To: Some User <user@example.com>
293 Date: Fri, 29 Sep 2006 00:00:00
294 Subject: Testing message 3
295 Resent-From: ${localmbox}
296 Resent-To: somebody@example.com
299 This is message number 3
302 test_dist 3 -noedit -to somebody@example.com -draftfolder nonexistent \
304 if test -d "${MH_TEST_DIR}/Mail/nonexistent"; then
305 echo "$0: -nodraftfolder test failed."
306 failed=`expr ${failed:-0} + 1`
310 cat >"$expected" <<EOF
311 From: Test1 <test1@example.com>
312 To: Some User <user@example.com>
313 Date: Fri, 29 Sep 2006 00:00:00
314 Subject: Testing message 1
315 Resent-From: me@example.com
316 Resent-To: somebody@example.com
319 This is message number 1
322 test_dist 1 -noedit -to somebody@example.com -from me@example.com
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 Subject: Testing message 1
330 Resent-From: ${localmbox}
331 Resent-To: somebody@example.com
332 Resent-cc: cc@example.com
335 This is message number 1
338 test_dist 1 -noedit -to somebody@example.com -cc cc@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 Subject: Testing message 1
346 Resent-From: ${localmbox}
347 Resent-To: somebody@example.com
350 This is message number 1
353 test_dist 1 -noedit -to somebody@example.com -fcc outbox
354 run_test 'scan +outbox -width 6' ' 1 '
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 Subject: Testing message 1
361 Resent-From: ${localmbox}
362 Resent-To: somebody@example.com
365 This is message number 1
368 test_dist +inbox 1 -noedit -to somebody@example.com -fcc +outbox
369 run_test 'scan +outbox -width 6 2' ' 2 '