]> diplodocus.org Git - nmh/blob - test/rcv/test-rcvdist
Removed -m from sendmail invocation with sendmail/pipe. Modern
[nmh] / test / rcv / test-rcvdist
1 #!/bin/sh
2 ######################################################
3 #
4 # Test rcvdist
5 #
6 ######################################################
7
8 set -e
9
10 if test -z "${MH_OBJ_DIR}"; then
11 srcdir=`dirname $0`/../..
12 MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
13 fi
14
15 . "$MH_OBJ_DIR/test/common.sh"
16
17 setup_test
18
19 # Use proper program, likely not the first one on PATH.
20 rcvdist="${MH_LIB_DIR}/rcvdist"
21
22 expected=$MH_TEST_DIR/$$.expected
23 actual=$MH_TEST_DIR/$$.actual
24
25
26 # check -help
27 cat >$expected <<EOF
28 Usage: rcvdist [switches] [switches for postproc] address ...
29 switches are:
30 -(form) formfile
31 -version
32 -help
33 EOF
34
35 $rcvdist -help >"$actual" 2>&1
36 check "$expected" "$actual"
37
38 # check -version
39 case `$rcvdist -v` in
40 rcvdist\ --*) ;;
41 * ) printf "$0: rcvdist -v generated unexpected output\n" >&2
42 failed=`expr ${failed:-0} + 1`;;
43 esac
44
45 # check unknown switch
46 run_test "$rcvdist -nonexistent" \
47 'rcvdist: usage: rcvdist [switches] [switches for postproc] address ...'
48
49 # check with no switches
50 run_test "$rcvdist" \
51 'rcvdist: usage: rcvdist [switches] [switches for postproc] address ...'
52
53 # check with address
54 # Replace post:
55 cat >"$MH_TEST_DIR/Mail/notpost" <<EOF
56 cp "\$2" "$actual"
57 EOF
58 chmod u+x "$MH_TEST_DIR/Mail/notpost"
59 sed 's/postproc:.*/#:/' "$MH" > "${MH}-new"
60 printf "postproc: $MH_TEST_DIR/Mail/notpost\n" >>"${MH}-new"
61 mv -f "${MH}-new" "$MH"
62
63 #### An extra space gets inserted between each header field name
64 #### and body. That probably should be fixed.
65 cat > "$expected" <<EOF
66 From: Test1 <test1@example.com>
67 To: Some User <user@example.com>
68 Date: Fri, 29 Sep 2006 00:00:00
69 Subject: Testing message 1
70 Resent-To: recipient@example.com
71
72 This is message number 1
73 EOF
74
75 $rcvdist recipient@example.com < "$MH_TEST_DIR/Mail/inbox/1"
76 check "$expected" "$actual"
77
78 # check -form
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 Subject: Testing message 1
84 Resent-To: recipient@example.com
85 Resent-From: Some User <user@example.com>
86
87 This is message number 1
88 EOF
89
90 cat > "$MH_TEST_DIR/Mail/rcvdistcomps" <<'EOF'
91 %(lit)%(formataddr{addresses})\
92 %<(nonnull)%(void(width))%(putaddr Resent-To:)%>
93 %(lit)%(formataddr{to})\
94 %<(nonnull)%(void(width))%(putaddr Resent-From:)\n%>
95 EOF
96
97 $rcvdist -form "$MH_TEST_DIR/Mail/rcvdistcomps" recipient@example.com < \
98 "$MH_TEST_DIR/Mail/inbox/1"
99 check "$expected" "$actual"
100
101 exit ${failed:-0}