]>
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 check_exit
'-eq 1' $slocal -
24 expected
="$MH_TEST_DIR"/$$.expected
25 actual
="$MH_TEST_DIR"/$$.actual
26 actual2
="$MH_TEST_DIR"/$$.actual2
27 md
="$MH_TEST_DIR"/Mail
/maildelivery
30 cat >"$expected" <<EOF
31 Usage: slocal [switches]
47 #### Skip nmh intro text.
48 run_prog
$slocal -help | sed '/^$/,$d' >"$actual" 2>&1
49 check
"$expected" "$actual"
52 case `$slocal -vers` in
54 * ) printf '%s: slocal -vers generated unexpected output\n' "$0" >&2
55 failed
=`expr ${failed:-0} + 1`;;
58 # check unknown switch
59 run_test
"$slocal -nonexistent" 'slocal: -nonexistent unknown'
61 # check non-switch argument
62 run_test
"$slocal nonexistent" 'slocal: only switch arguments are supported'
64 # If no mail spool, explicitly specify the mailbox.
65 if grep 'mmdfldir:.*/dev/null' ${MHMTSCONF}.old
>/dev
/null
; then
66 mbox
="-mailbox ${MH_TEST_DIR}/Mail/mbox"
71 #### Need to specify full path to tee on Cygwin.
72 [ -x /usr
/bin
/tee ] && tee=/usr
/bin
/tee || tee=tee
74 # check basic operation
75 # Can't use rcvstore because slocal wipes out the environment.
76 # So, it would put the message in the user's inbox, not the
77 # test inbox. slocal also freopens stdout and stderr to
78 # /dev/null, so we can't view them to verify simulated delivery.
80 * - qpipe A "$tee $actual"
84 run_prog
$slocal -maildelivery "$md" $mbox <"$MH_TEST_DIR"/Mail
/inbox
/1
85 check
"$MH_TEST_DIR/Mail/inbox/1" "$actual" 'keep first'
87 if [ ${failed:-0} -eq 1 ]; then
88 printf "\nRerunning failed basic slocal command with -verbose -debug to help
89 diagnose test failure . . .\n\n"
90 run_prog
$slocal -verbose -debug -maildelivery "$md" $mbox \
91 <"$MH_TEST_DIR"/Mail
/inbox
/1
96 run_prog
$slocal -debug -maildelivery "$md" $mbox <"$MH_TEST_DIR"/Mail
/inbox
/1 \
98 run_test
"grep ^retrieving $actual2" 'retrieving message from stdin'
101 run_prog
$slocal -verbose -maildelivery "$md" $mbox \
102 <"$MH_TEST_DIR"/Mail
/inbox
/1 >"$actual2" 2>&1
103 run_test
"grep ^delivering $actual2" "delivering to pipe \"$tee\", success."
106 run_prog
$slocal -verbose -noverbose -maildelivery "$md" $mbox \
107 <"$MH_TEST_DIR"/Mail
/inbox
/1 >"$actual2" 2>&1
108 run_test
"grep ^delivering $actual2" ''
111 # check match of From
113 From test2@example.com qpipe A "$tee $actual"
116 run_prog
$slocal -maildelivery "$md" $mbox <"$MH_TEST_DIR"/Mail
/inbox
/2
117 check
"$MH_TEST_DIR/Mail/inbox/2" "$actual" 'keep first'
121 From test3@example.com qpipe R "$tee $actual"
122 From test3@example.com qpipe ? "$tee $actual2"
125 run_prog
$slocal -maildelivery "$md" $mbox <"$MH_TEST_DIR"/Mail
/inbox
/3
126 check
"$MH_TEST_DIR/Mail/inbox/3" "$actual" 'keep first'
127 check
"$MH_TEST_DIR/Mail/inbox/3" "$actual2" 'keep first'
131 From test4@example.com qpipe R "$tee $actual"
132 From test4@example.com qpipe N "$tee $actual2"
135 run_prog
$slocal -maildelivery "$md" $mbox <"$MH_TEST_DIR"/Mail
/inbox
/4
136 check
"$MH_TEST_DIR/Mail/inbox/4" "$actual" 'keep first'
137 check
"$MH_TEST_DIR/Mail/inbox/4" "$actual2" 'keep first'
141 From test5@example.com qpipe R "$tee $actual"
142 default 1 qpipe A "$tee $actual2"
145 run_prog
$slocal -maildelivery "$md" $mbox <"$MH_TEST_DIR"/Mail
/inbox
/5
146 check
"$MH_TEST_DIR/Mail/inbox/5" "$actual" 'keep first'
147 check
"$MH_TEST_DIR/Mail/inbox/5" "$actual2" 'keep first'
151 addr someaddress qpipe A "$tee $actual"
154 run_prog
$slocal -addr someaddress
-maildelivery "$md" $mbox \
155 <"$MH_TEST_DIR"/Mail
/inbox
/6
156 check
"$MH_TEST_DIR/Mail/inbox/6" "$actual" 'keep first'
158 # check -addr with . in address
160 addr "first.last" qpipe A "$tee $actual"
162 run_prog
$slocal -addr 'first.last' \
163 -maildelivery "$md" $mbox <"$MH_TEST_DIR"/Mail
/inbox
/6
164 check
"$MH_TEST_DIR/Mail/inbox/6" "$actual" 'keep first'
168 * - qpipe A "\$(info) $actual"
171 run_prog
$slocal -info $tee -maildelivery "$md" $mbox \
172 <"$MH_TEST_DIR"/Mail
/inbox
/7
173 check
"$MH_TEST_DIR/Mail/inbox/7" "$actual" 'keep first'
175 # check -sender, which is compared with "source"
177 source somesender qpipe A "$tee $actual"
180 run_prog
$slocal -sender somesender
-maildelivery "$md" $mbox \
181 <"$MH_TEST_DIR"/Mail
/inbox
/8
182 check
"$MH_TEST_DIR/Mail/inbox/8" "$actual" 'keep first'
186 * - qpipe A "$tee $actual"
189 # Use current login for user because it must be an existing user on the host.
190 me
=`"$MH_LIBEXEC_DIR"/ap -format '%(me)' 0`
191 run_prog
$slocal -user "$me" -maildelivery "$md" $mbox \
192 <"$MH_TEST_DIR"/Mail
/inbox
/9
193 check
"$MH_TEST_DIR/Mail/inbox/9" "$actual" 'keep first'
195 # Can't check -user with . in address because the user must
196 # have an account on the local system, and we can't guarantee
203 run_prog
$slocal -mailbox "$actual" -maildelivery "$md" \
204 <"$MH_TEST_DIR"/Mail
/inbox
/10
205 inc
-file "$actual" -silent -truncate
207 check
"$MH_TEST_DIR/Mail/inbox/10" "$MH_TEST_DIR/Mail/inbox/11" 'keep first'
210 run_prog
$slocal -mailbox "$actual" -maildelivery "$md" \
211 -file "$MH_TEST_DIR"/Mail
/inbox
/1
212 inc
-file "$actual" -silent -truncate
214 check
"$MH_TEST_DIR/Mail/inbox/1" "$MH_TEST_DIR/Mail/inbox/11" 'keep first'
218 * - qpipe A "$tee $actual"
221 run_prog
$slocal -suppressdup -maildelivery "$md" $mbox \
222 <"$MH_TEST_DIR"/Mail
/inbox
/2
223 check
"$MH_TEST_DIR/Mail/inbox/2" "$actual" 'keep first'
225 run_prog
$slocal -suppressdup -maildelivery "$md" $mbox \
226 <"$MH_TEST_DIR"/Mail
/inbox
/2
227 if [ -f "$actual" ]; then
228 echo $0: check
-suppressdup failed
229 failed
=`expr ${failed:-0} + 1`
232 # check -nosuppressdup
233 run_prog
$slocal -suppress -nosuppressdup -maildelivery "$md" $mbox \
234 <"$MH_TEST_DIR"/Mail
/inbox
/2
235 check
"$MH_TEST_DIR/Mail/inbox/2" "$actual" 'keep first'