]>
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
31 cat >"$expected" <<EOF
32 Usage: slocal [switches]
48 #### Skip nmh intro text.
49 run_prog
$slocal -help 2>&1 | sed '/^$/,$d' >"$actual"
50 check
"$expected" "$actual"
54 case `$slocal -vers` in
56 * ) printf '%s: slocal -vers generated unexpected output\n' "$0" >&2
57 failed
=`expr ${failed:-0} + 1`;;
60 # check unknown switch
61 start_test
"unknown switch"
62 run_test
"$slocal -nonexistent" 'slocal: -nonexistent unknown'
64 # check non-switch argument
65 start_test
"non-switch argument"
66 run_test
"$slocal nonexistent" 'slocal: only switch arguments are supported'
68 # If no mail spool, explicitly specify the mailbox.
69 if grep 'mmdfldir:.*/dev/null' ${MHMTSCONF}.old
>/dev
/null
; then
70 mbox
="-mailbox ${MH_TEST_DIR}/Mail/mbox"
75 #### Need to specify full path to tee on Cygwin.
76 [ -x /usr
/bin
/tee ] && tee=/usr
/bin
/tee || tee=tee
78 # check basic operation
79 start_test
"basic operation"
80 # Can't use rcvstore because slocal wipes out the environment.
81 # So, it would put the message in the user's inbox, not the
82 # test inbox. slocal also freopens stdout and stderr to
83 # /dev/null, so we can't view them to verify simulated delivery.
85 * - qpipe A "$tee $actual"
89 run_prog
$slocal -maildelivery "$md" $mbox <"$MH_TEST_DIR"/Mail
/inbox
/1
90 check
"$MH_TEST_DIR/Mail/inbox/1" "$actual" 'keep first'
92 if [ ${failed:-0} -eq 1 ]; then
93 printf "\nRerunning failed basic slocal command with -verbose -debug to help
94 diagnose test failure . . .\n\n"
95 run_prog
$slocal -verbose -debug -maildelivery "$md" $mbox \
96 <"$MH_TEST_DIR"/Mail
/inbox
/1
102 run_prog
$slocal -debug -maildelivery "$md" $mbox <"$MH_TEST_DIR"/Mail
/inbox
/1 \
104 run_test
"grep ^retrieving $actual2" 'retrieving message from stdin'
107 start_test
"-verbose"
108 run_prog
$slocal -verbose -maildelivery "$md" $mbox \
109 <"$MH_TEST_DIR"/Mail
/inbox
/1 >"$actual2" 2>&1
110 run_test
"grep ^delivering $actual2" "delivering to pipe \"$tee\", success."
113 start_test
"-noverbose"
114 run_prog
$slocal -verbose -noverbose -maildelivery "$md" $mbox \
115 <"$MH_TEST_DIR"/Mail
/inbox
/1 >"$actual2" 2>&1
116 run_test
"grep ^delivering $actual2" ''
119 # check match of From
120 start_test
"match of From"
122 From test2@example.com qpipe A "$tee $actual"
125 run_prog
$slocal -maildelivery "$md" $mbox <"$MH_TEST_DIR"/Mail
/inbox
/2
126 check
"$MH_TEST_DIR/Mail/inbox/2" "$actual" 'keep first'
131 From test3@example.com qpipe R "$tee $actual"
132 From test3@example.com qpipe ? "$tee $actual2"
135 run_prog
$slocal -maildelivery "$md" $mbox <"$MH_TEST_DIR"/Mail
/inbox
/3
136 check
"$MH_TEST_DIR/Mail/inbox/3" "$actual" 'keep first'
137 check
"$MH_TEST_DIR/Mail/inbox/3" "$actual2" 'keep first'
142 From test4@example.com qpipe R "$tee $actual"
143 From test4@example.com qpipe N "$tee $actual2"
146 run_prog
$slocal -maildelivery "$md" $mbox <"$MH_TEST_DIR"/Mail
/inbox
/4
147 check
"$MH_TEST_DIR/Mail/inbox/4" "$actual" 'keep first'
148 check
"$MH_TEST_DIR/Mail/inbox/4" "$actual2" 'keep first'
153 From test5@example.com qpipe R "$tee $actual"
154 default 1 qpipe A "$tee $actual2"
157 run_prog
$slocal -maildelivery "$md" $mbox <"$MH_TEST_DIR"/Mail
/inbox
/5
158 check
"$MH_TEST_DIR/Mail/inbox/5" "$actual" 'keep first'
159 check
"$MH_TEST_DIR/Mail/inbox/5" "$actual2" 'keep first'
164 addr someaddress qpipe A "$tee $actual"
167 run_prog
$slocal -addr someaddress
-maildelivery "$md" $mbox \
168 <"$MH_TEST_DIR"/Mail
/inbox
/6
169 check
"$MH_TEST_DIR/Mail/inbox/6" "$actual" 'keep first'
171 # check -addr with . in address
172 start_test
"-addr with . in address"
174 addr "first.last" qpipe A "$tee $actual"
176 run_prog
$slocal -addr 'first.last' \
177 -maildelivery "$md" $mbox <"$MH_TEST_DIR"/Mail
/inbox
/6
178 check
"$MH_TEST_DIR/Mail/inbox/6" "$actual" 'keep first'
183 * - qpipe A "\$(info) $actual"
186 run_prog
$slocal -info $tee -maildelivery "$md" $mbox \
187 <"$MH_TEST_DIR"/Mail
/inbox
/7
188 check
"$MH_TEST_DIR/Mail/inbox/7" "$actual" 'keep first'
190 # check -sender, which is compared with "source"
191 start_test
"-sender, which is compared with "source""
193 source somesender qpipe A "$tee $actual"
196 run_prog
$slocal -sender somesender
-maildelivery "$md" $mbox \
197 <"$MH_TEST_DIR"/Mail
/inbox
/8
198 check
"$MH_TEST_DIR/Mail/inbox/8" "$actual" 'keep first'
203 * - qpipe A "$tee $actual"
206 # Use current login for user because it must be an existing user on the host.
207 me
=`"$MH_LIBEXEC_DIR"/ap -format '%(me)' 0`
208 run_prog
$slocal -user "$me" -maildelivery "$md" $mbox \
209 <"$MH_TEST_DIR"/Mail
/inbox
/9
210 check
"$MH_TEST_DIR/Mail/inbox/9" "$actual" 'keep first'
212 # Can't check -user with . in address because the user must
213 # have an account on the local system, and we can't guarantee
217 start_test
"-mailbox"
221 run_prog
$slocal -mailbox "$actual" -maildelivery "$md" \
222 <"$MH_TEST_DIR"/Mail
/inbox
/10
223 inc
-file "$actual" -silent -truncate
225 check
"$MH_TEST_DIR/Mail/inbox/10" "$MH_TEST_DIR/Mail/inbox/11" 'keep first'
229 run_prog
$slocal -mailbox "$actual" -maildelivery "$md" \
230 -file "$MH_TEST_DIR"/Mail
/inbox
/1
231 inc
-file "$actual" -silent -truncate
233 check
"$MH_TEST_DIR/Mail/inbox/1" "$MH_TEST_DIR/Mail/inbox/11" 'keep first'
236 start_test
"-suppressdup"
238 * - qpipe A "$tee $actual"
241 run_prog
$slocal -suppressdup -maildelivery "$md" $mbox \
242 <"$MH_TEST_DIR"/Mail
/inbox
/2
243 check
"$MH_TEST_DIR/Mail/inbox/2" "$actual" 'keep first'
245 run_prog
$slocal -suppressdup -maildelivery "$md" $mbox \
246 <"$MH_TEST_DIR"/Mail
/inbox
/2
247 if [ -f "$actual" ]; then
248 echo $0: check
-suppressdup failed
249 failed
=`expr ${failed:-0} + 1`
252 # check -nosuppressdup
253 start_test
"-nosuppressdup"
254 run_prog
$slocal -suppress -nosuppressdup -maildelivery "$md" $mbox \
255 <"$MH_TEST_DIR"/Mail
/inbox
/2
256 check
"$MH_TEST_DIR/Mail/inbox/2" "$actual" 'keep first'