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 check_exit '-eq 1' $rcvdist -
24 expected=$MH_TEST_DIR/$$.expected
25 actual=$MH_TEST_DIR/$$.actual
30 Usage: rcvdist [switches] [switches for postproc] address ...
37 #### Skip nmh intro text.
38 run_prog "$rcvdist" -help | sed '/^$/,$d' >"$actual" 2>&1
39 check "$expected" "$actual"
44 * ) printf '%s: rcvdist -v generated unexpected output\n' "$0" >&2
45 failed=`expr ${failed:-0} + 1`;;
48 # check unknown switch
49 run_test "$rcvdist -nonexistent" \
50 'rcvdist: usage: rcvdist [switches] [switches for postproc] address ...'
52 # check with no switches
54 'rcvdist: usage: rcvdist [switches] [switches for postproc] address ...'
56 #### Use sendmail/pipe below to override default mts.
57 mts_fakesendmail="${MHMTSCONF}-fakesendmail"
58 sed -e 's/^mts:.*/mts: sendmail\/pipe/' "${MHMTSCONF}" > "$mts_fakesendmail"
59 printf 'sendmail: %s/test/fakesendmail\n' "$srcdir" >>"$mts_fakesendmail"
60 MHMTSCONF="$mts_fakesendmail"
62 # arguments: rcvdist switches
65 run_prog $rcvdist "$@"
67 # fakesendmail drops the message and any cc's into this mbox.
68 mbox="${MH_TEST_DIR}"/Mail/fakesendmail.mbox
69 inc -silent -file "$mbox"
72 # It's hard to calculate the exact Date: header post is going to
73 # use, so we'll just use sed to remove the actual date so we can
74 # easily compare it against our "correct" output.
75 sed -e 's/^Resent-Date:.*/Resent-Date:/' `mhpath last` > "$actual"
77 check "$expected" "$actual"
81 cat > "$expected" <<EOF
82 From: Test1 <test1@example.com>
83 To: Some User <user@example.com>
84 Date: Fri, 29 Sep 2006 00:00:00
85 Message-Id: 1@test.nmh
86 Subject: Testing message 1
87 Resent-From: `${MH_LIBEXEC_DIR}/ap -format '%(localmbox)' 0 | \
88 sed 's/^<\(.*\)>$/\1/'`
89 Resent-To: recipient@example.com
92 This is message number 1
95 test_rcvdist recipient@example.com < "$MH_TEST_DIR/Mail/inbox/1"
98 cat > "$expected" <<EOF
99 From: Test2 <test2@example.com>
100 To: Some User <user@example.com>
101 Date: Fri, 29 Sep 2006 00:00:00
102 Message-Id: 2@test.nmh
103 Subject: Testing message 2
104 Resent-To: recipient@example.com
105 Resent-From: Some User <user@example.com>
108 This is message number 2
111 cat > "$MH_TEST_DIR/Mail/rcvdistcomps" <<'EOF'
112 %(lit)%(formataddr{addresses})\
113 %<(nonnull)%(void(width))%(putaddr Resent-To:)%>
114 %(lit)%(formataddr{to})\
115 %<(nonnull)%(void(width))%(putaddr Resent-From:)\n%>
118 test_rcvdist -form "$MH_TEST_DIR/Mail/rcvdistcomps" recipient@example.com \
119 < "$MH_TEST_DIR/Mail/inbox/2"