]>
diplodocus.org Git - nmh/blob - test/slocal/test-slocal
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, maybe not the first one on PATH.
20 slocal
="$MH_LIBEXEC_DIR"/slocal
22 expected
="$MH_TEST_DIR"/$$.expected
23 actual
="$MH_TEST_DIR"/$$.actual
24 actual2
="$MH_TEST_DIR"/$$.actual2
25 md
="$MH_TEST_DIR"/Mail
/maildelivery
28 cat >"$expected" <<EOF
29 Usage: slocal [switches]
45 #### Skip nmh intro text.
46 run_prog
$slocal -help | sed '/^$/,$d' >"$actual" 2>&1
47 check
"$expected" "$actual"
50 case `$slocal -vers` in
52 * ) printf '%s: slocal -vers generated unexpected output\n' "$0" >&2
53 failed
=`expr ${failed:-0} + 1`;;
56 # check unknown switch
57 run_test
"$slocal -nonexistent" 'slocal: -nonexistent unknown'
59 # check non-switch argument
60 run_test
"$slocal nonexistent" 'slocal: only switch arguments are supported'
62 # If no mail spool, explicitly specify the mailbox.
63 if grep 'mmdfldir:.*/dev/null' ${MHMTSCONF}.old
>/dev
/null
; then
64 mbox
="-mailbox ${MH_TEST_DIR}/Mail/mbox"
69 #### Need to specify full path to tee on Cygwin.
70 [ -x /usr
/bin
/tee ] && tee=/usr
/bin
/tee || tee=tee
72 # check basic operation
73 # Can't use rcvstore because slocal wipes out the environment.
74 # So, it would put the message in the user's inbox, not the
75 # test inbox. slocal also freopens stdout and stderr to
76 # /dev/null, so we can't view them to verify simulated delivery.
78 * - qpipe A "$tee $actual"
82 run_prog
$slocal -maildelivery "$md" $mbox <"$MH_TEST_DIR"/Mail
/inbox
/1
83 check
"$MH_TEST_DIR/Mail/inbox/1" "$actual" 'keep first'
85 if [ ${failed:-0} -eq 1 ]; then
86 printf "\nRerunning failed basic slocal command with -verbose -debug to help
87 diagnose test failure . . .\n\n"
88 run_prog
$slocal -verbose -debug -maildelivery "$md" $mbox \
89 <"$MH_TEST_DIR"/Mail
/inbox
/1
94 run_prog
$slocal -debug -maildelivery "$md" $mbox <"$MH_TEST_DIR"/Mail
/inbox
/1 \
96 run_test
"grep ^retrieving $actual2" 'retrieving message from stdin'
99 run_prog
$slocal -verbose -maildelivery "$md" $mbox \
100 <"$MH_TEST_DIR"/Mail
/inbox
/1 >"$actual2" 2>&1
101 run_test
"grep ^delivering $actual2" "delivering to pipe \"$tee\", success."
104 run_prog
$slocal -verbose -noverbose -maildelivery "$md" $mbox \
105 <"$MH_TEST_DIR"/Mail
/inbox
/1 >"$actual2" 2>&1
106 run_test
"grep ^delivering $actual2" ''
109 # check match of From
111 From test2@example.com qpipe A "$tee $actual"
114 run_prog
$slocal -maildelivery "$md" $mbox <"$MH_TEST_DIR"/Mail
/inbox
/2
115 check
"$MH_TEST_DIR/Mail/inbox/2" "$actual" 'keep first'
119 From test3@example.com qpipe R "$tee $actual"
120 From test3@example.com qpipe ? "$tee $actual2"
123 run_prog
$slocal -maildelivery "$md" $mbox <"$MH_TEST_DIR"/Mail
/inbox
/3
124 check
"$MH_TEST_DIR/Mail/inbox/3" "$actual" 'keep first'
125 check
"$MH_TEST_DIR/Mail/inbox/3" "$actual2" 'keep first'
129 From test4@example.com qpipe R "$tee $actual"
130 From test4@example.com qpipe N "$tee $actual2"
133 run_prog
$slocal -maildelivery "$md" $mbox <"$MH_TEST_DIR"/Mail
/inbox
/4
134 check
"$MH_TEST_DIR/Mail/inbox/4" "$actual" 'keep first'
135 check
"$MH_TEST_DIR/Mail/inbox/4" "$actual2" 'keep first'
139 From test5@example.com qpipe R "$tee $actual"
140 default 1 qpipe A "$tee $actual2"
143 run_prog
$slocal -maildelivery "$md" $mbox <"$MH_TEST_DIR"/Mail
/inbox
/5
144 check
"$MH_TEST_DIR/Mail/inbox/5" "$actual" 'keep first'
145 check
"$MH_TEST_DIR/Mail/inbox/5" "$actual2" 'keep first'
149 addr someaddress qpipe A "$tee $actual"
152 run_prog
$slocal -addr someaddress
-maildelivery "$md" $mbox \
153 <"$MH_TEST_DIR"/Mail
/inbox
/6
154 check
"$MH_TEST_DIR/Mail/inbox/6" "$actual" 'keep first'
156 # check -addr with . in address
158 addr "first.last" qpipe A "$tee $actual"
160 run_prog
$slocal -addr 'first.last' \
161 -maildelivery "$md" $mbox <"$MH_TEST_DIR"/Mail
/inbox
/6
162 check
"$MH_TEST_DIR/Mail/inbox/6" "$actual" 'keep first'
166 * - qpipe A "\$(info) $actual"
169 run_prog
$slocal -info $tee -maildelivery "$md" $mbox \
170 <"$MH_TEST_DIR"/Mail
/inbox
/7
171 check
"$MH_TEST_DIR/Mail/inbox/7" "$actual" 'keep first'
173 # check -sender, which is compared with "source"
175 source somesender qpipe A "$tee $actual"
178 run_prog
$slocal -sender somesender
-maildelivery "$md" $mbox \
179 <"$MH_TEST_DIR"/Mail
/inbox
/8
180 check
"$MH_TEST_DIR/Mail/inbox/8" "$actual" 'keep first'
184 * - qpipe A "$tee $actual"
187 # Use current login for user because it must be an existing user on the host.
188 me
=`"$MH_LIBEXEC_DIR"/ap -format '%(me)' 0`
189 run_prog
$slocal -user "$me" -maildelivery "$md" $mbox \
190 <"$MH_TEST_DIR"/Mail
/inbox
/9
191 check
"$MH_TEST_DIR/Mail/inbox/9" "$actual" 'keep first'
193 # Can't check -user with . in address because the user must
194 # have an account on the local system, and we can't guarantee
201 run_prog
$slocal -mailbox "$actual" -maildelivery "$md" \
202 <"$MH_TEST_DIR"/Mail
/inbox
/10
203 inc
-file "$actual" -silent -truncate
205 check
"$MH_TEST_DIR/Mail/inbox/10" "$MH_TEST_DIR/Mail/inbox/11" 'keep first'
208 run_prog
$slocal -mailbox "$actual" -maildelivery "$md" \
209 -file "$MH_TEST_DIR"/Mail
/inbox
/1
210 inc
-file "$actual" -silent -truncate
212 check
"$MH_TEST_DIR/Mail/inbox/1" "$MH_TEST_DIR/Mail/inbox/11" 'keep first'
216 * - qpipe A "$tee $actual"
219 run_prog
$slocal -suppressdup -maildelivery "$md" $mbox \
220 <"$MH_TEST_DIR"/Mail
/inbox
/2
221 check
"$MH_TEST_DIR/Mail/inbox/2" "$actual" 'keep first'
223 run_prog
$slocal -suppressdup -maildelivery "$md" $mbox \
224 <"$MH_TEST_DIR"/Mail
/inbox
/2
225 if [ -f "$actual" ]; then
226 echo $0: check
-suppressdup failed
227 failed
=`expr ${failed:-0} + 1`
230 # check -nosuppressdup
231 run_prog
$slocal -suppress -nosuppressdup -maildelivery "$md" $mbox \
232 <"$MH_TEST_DIR"/Mail
/inbox
/2
233 check
"$MH_TEST_DIR/Mail/inbox/2" "$actual" 'keep first'