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 # Use proper program, likely not the first one on PATH.
20 rcvdist
="${MH_LIBEXEC_DIR}/rcvdist"
22 expected
=$MH_TEST_DIR/$$.expected
23 actual
=$MH_TEST_DIR/$$.actual
28 Usage: rcvdist [switches] [switches for postproc] address ...
35 #### Skip nmh intro text.
36 run_prog
"$rcvdist" -help | sed '/^$/,$d' >"$actual" 2>&1
37 check
"$expected" "$actual"
42 * ) printf '%s: rcvdist -v generated unexpected output\n' "$0" >&2
43 failed
=`expr ${failed:-0} + 1`;;
46 # check unknown switch
47 run_test
"$rcvdist -nonexistent" \
48 'rcvdist: usage: rcvdist [switches] [switches for postproc] address ...'
50 # check with no switches
52 'rcvdist: usage: rcvdist [switches] [switches for postproc] address ...'
54 #### Use sendmail/pipe below to override default mts.
55 mts_fakesendmail
="${MHMTSCONF}-fakesendmail"
56 sed -e 's/^mts:.*/mts: sendmail\/pipe/' "${MHMTSCONF}" > "$mts_fakesendmail"
57 printf 'sendmail: %s/test/fakesendmail\n' "$srcdir" >>"$mts_fakesendmail"
58 MHMTSCONF
="$mts_fakesendmail"
60 # arguments: rcvdist switches
63 run_prog
$rcvdist "$@"
65 # fakesendmail drops the message and any cc's into this mbox.
66 mbox
="${MH_TEST_DIR}"/Mail
/fakesendmail.mbox
67 inc
-silent -file "$mbox"
68 rm -f "$mbox" "$mbox.map"
70 # It's hard to calculate the exact Date: header post is going to
71 # use, so we'll just use sed to remove the actual date so we can
72 # easily compare it against our "correct" output.
73 sed -e 's/^Resent-Date:.*/Resent-Date:/' `mhpath last` > "$actual"
75 check
"$expected" "$actual"
79 cat > "$expected" <<EOF
80 From: Test1 <test1@example.com>
81 To: Some User <user@example.com>
82 Date: Fri, 29 Sep 2006 00:00:00
83 Message-Id: 1@test.nmh
84 Subject: Testing message 1
85 Resent-From: `${MH_LIBEXEC_DIR}/ap -format '%(localmbox)' 0 | \
86 sed 's/^<\(.*\)>$/\1/'`
87 Resent-To: recipient@example.com
90 This is message number 1
93 test_rcvdist recipient@example.com
< "$MH_TEST_DIR/Mail/inbox/1"
96 cat > "$expected" <<EOF
97 From: Test2 <test2@example.com>
98 To: Some User <user@example.com>
99 Date: Fri, 29 Sep 2006 00:00:00
100 Message-Id: 2@test.nmh
101 Subject: Testing message 2
102 Resent-To: recipient@example.com
103 Resent-From: Some User <user@example.com>
106 This is message number 2
109 cat > "$MH_TEST_DIR/Mail/rcvdistcomps" <<'EOF'
110 %(lit)%(formataddr{addresses})\
111 %<(nonnull)%(void(width))%(putaddr Resent-To:)%>
112 %(lit)%(formataddr{to})\
113 %<(nonnull)%(void(width))%(putaddr Resent-From:)\n%>
116 test_rcvdist
-form "$MH_TEST_DIR/Mail/rcvdistcomps" recipient@example.com \
117 < "$MH_TEST_DIR/Mail/inbox/2"