]> diplodocus.org Git - nmh/blobdiff - test/slocal/test-slocal
new.c: Order two return statements to match comment.
[nmh] / test / slocal / test-slocal
index 40e3ee3289df4dfe0fd388491cb5ef0907cd03ec..1213117b00fc39e2dfdeb910cf77cc4ca0650e14 100755 (executable)
@@ -17,7 +17,9 @@ fi
 setup_test
 
 # Use proper program, maybe not the first one on PATH.
-slocal="$MH_LIB_DIR"/slocal
+slocal="$MH_LIBEXEC_DIR"/slocal
+
+check_exit '-eq 1' $slocal -
 
 expected="$MH_TEST_DIR"/$$.expected
 actual="$MH_TEST_DIR"/$$.actual
@@ -42,7 +44,8 @@ Usage: slocal [switches]
   -help
 EOF
 
-$slocal -help >"$actual" 2>&1
+#### Skip nmh intro text.
+run_prog $slocal -help | sed '/^$/,$d' >"$actual" 2>&1
 check "$expected" "$actual"
 
 # check -version
@@ -73,136 +76,162 @@ fi
 # So, it would put the message in the user's inbox, not the
 # test inbox.  slocal also freopens stdout and stderr to
 # /dev/null, so we can't view them to verify simulated delivery.
-cat >$md  <<EOF
-* 1 qpipe A "$tee $actual"
+cat >"$md"  <<EOF
+* - qpipe A "$tee $actual"
 EOF
+chmod go-w "$md"
 
-$slocal -maildelivery $md $mbox <"$MH_TEST_DIR"/Mail/inbox/1
+run_prog $slocal -maildelivery "$md" $mbox <"$MH_TEST_DIR"/Mail/inbox/1
 check "$MH_TEST_DIR/Mail/inbox/1" "$actual" 'keep first'
 
+if [ ${failed:-0} -eq 1 ]; then
+  printf "\nRerunning failed basic slocal command with -verbose -debug to help
+    diagnose test failure . . .\n\n"
+  run_prog $slocal -verbose -debug -maildelivery "$md" $mbox \
+    <"$MH_TEST_DIR"/Mail/inbox/1
+  exit 1
+fi
+
 # check -debug
-$slocal -debug -maildelivery $md $mbox <"$MH_TEST_DIR"/Mail/inbox/1 \
+run_prog $slocal -debug -maildelivery "$md" $mbox <"$MH_TEST_DIR"/Mail/inbox/1 \
   >"$actual2" 2>&1
 run_test "grep ^retrieving $actual2" 'retrieving message from stdin'
 
 # check -verbose
-$slocal -verbose -maildelivery $md $mbox <"$MH_TEST_DIR"/Mail/inbox/1 \
-  >"$actual2" 2>&1
+run_prog $slocal -verbose -maildelivery "$md" $mbox \
+  <"$MH_TEST_DIR"/Mail/inbox/1 >"$actual2" 2>&1
 run_test "grep ^delivering $actual2" "delivering to pipe \"$tee\", success."
 
 # check -noverbose
-$slocal -verbose -noverbose -maildelivery $md $mbox \
+run_prog $slocal -verbose -noverbose -maildelivery "$md" $mbox \
   <"$MH_TEST_DIR"/Mail/inbox/1 >"$actual2" 2>&1
 run_test "grep ^delivering $actual2" ''
 rm -f "$actual2"
 
 # check match of From
-cat >$md  <<EOF
+cat >"$md"  <<EOF
 From test2@example.com qpipe A "$tee $actual"
 EOF
 
-$slocal -maildelivery $md $mbox <"$MH_TEST_DIR"/Mail/inbox/2
+run_prog $slocal -maildelivery "$md" $mbox <"$MH_TEST_DIR"/Mail/inbox/2
 check "$MH_TEST_DIR/Mail/inbox/2" "$actual" 'keep first'
 
 # check R and ?
-cat >$md  <<EOF
+cat >"$md"  <<EOF
 From test3@example.com qpipe R "$tee $actual"
 From test3@example.com qpipe ? "$tee $actual2"
 EOF
 
-$slocal -maildelivery $md $mbox <"$MH_TEST_DIR"/Mail/inbox/3
+run_prog $slocal -maildelivery "$md" $mbox <"$MH_TEST_DIR"/Mail/inbox/3
 check "$MH_TEST_DIR/Mail/inbox/3" "$actual" 'keep first'
 check "$MH_TEST_DIR/Mail/inbox/3" "$actual2" 'keep first'
 
 # check R and N
-cat >$md  <<EOF
+cat >"$md"  <<EOF
 From test4@example.com qpipe R "$tee $actual"
 From test4@example.com qpipe N "$tee $actual2"
 EOF
 
-$slocal -maildelivery $md $mbox <"$MH_TEST_DIR"/Mail/inbox/4
+run_prog $slocal -maildelivery "$md" $mbox <"$MH_TEST_DIR"/Mail/inbox/4
 check "$MH_TEST_DIR/Mail/inbox/4" "$actual" 'keep first'
 check "$MH_TEST_DIR/Mail/inbox/4" "$actual2" 'keep first'
 
 # check default
-cat >$md  <<EOF
+cat >"$md"  <<EOF
 From test5@example.com qpipe R "$tee $actual"
 default 1 qpipe A "$tee $actual2"
 EOF
 
-$slocal -maildelivery $md $mbox <"$MH_TEST_DIR"/Mail/inbox/5
+run_prog $slocal -maildelivery "$md" $mbox <"$MH_TEST_DIR"/Mail/inbox/5
 check "$MH_TEST_DIR/Mail/inbox/5" "$actual" 'keep first'
 check "$MH_TEST_DIR/Mail/inbox/5" "$actual2" 'keep first'
 
-# Use current login for address, user, etc., because it must be an
-# existing user on the host.
-me=`"$MH_LIB_DIR"/ap -format '%(me)' 0`
-
 # check -addr
-cat >$md  <<EOF
-addr "$me" qpipe A "$tee $actual"
+cat >"$md"  <<EOF
+addr someaddress qpipe A "$tee $actual"
 EOF
 
-$slocal -addr "$me" -maildelivery $md $mbox <"$MH_TEST_DIR"/Mail/inbox/6
+run_prog $slocal -addr someaddress -maildelivery "$md" $mbox \
+  <"$MH_TEST_DIR"/Mail/inbox/6
+check "$MH_TEST_DIR/Mail/inbox/6" "$actual" 'keep first'
+
+# check -addr with . in address
+cat >"$md"  <<EOF
+addr "first.last" qpipe A "$tee $actual"
+EOF
+run_prog $slocal -addr 'first.last' \
+  -maildelivery "$md" $mbox <"$MH_TEST_DIR"/Mail/inbox/6
 check "$MH_TEST_DIR/Mail/inbox/6" "$actual" 'keep first'
 
 # check -info
-cat >$md  <<EOF
-* 1 qpipe A "\$(info) $actual"
+cat >"$md"  <<EOF
+* - qpipe A "\$(info) $actual"
 EOF
 
-$slocal -info $tee -maildelivery $md $mbox <"$MH_TEST_DIR"/Mail/inbox/7
+run_prog $slocal -info $tee -maildelivery "$md" $mbox \
+  <"$MH_TEST_DIR"/Mail/inbox/7
 check "$MH_TEST_DIR/Mail/inbox/7" "$actual" 'keep first'
 
 # check -sender, which is compared with "source"
-cat >$md  <<EOF
-source "$me" qpipe A "$tee $actual"
+cat >"$md"  <<EOF
+source somesender qpipe A "$tee $actual"
 EOF
 
-$slocal -sender "$me" -maildelivery $md $mbox <"$MH_TEST_DIR"/Mail/inbox/8
+run_prog $slocal -sender somesender -maildelivery "$md" $mbox \
+  <"$MH_TEST_DIR"/Mail/inbox/8
 check "$MH_TEST_DIR/Mail/inbox/8" "$actual" 'keep first'
 
 # check -user
-cat >$md  <<EOF
-* 1 qpipe A "$tee $actual"
+cat >"$md"  <<EOF
+* - qpipe A "$tee $actual"
 EOF
 
-$slocal -user "$me" -maildelivery $md $mbox <"$MH_TEST_DIR"/Mail/inbox/9
+# Use current login for user because it must be an existing user on the host.
+me=`"$MH_LIBEXEC_DIR"/ap -format '%(me)' 0`
+run_prog $slocal -user "$me" -maildelivery "$md" $mbox \
+  <"$MH_TEST_DIR"/Mail/inbox/9
 check "$MH_TEST_DIR/Mail/inbox/9" "$actual" 'keep first'
 
+# Can't check -user with . in address because the user must
+# have an account on the local system, and we can't guarantee
+# that there is one.
+
 # check -mailbox
-cat >$md  <<EOF
+cat >"$md"  <<EOF
 EOF
 
-$slocal -mailbox "$actual" -maildelivery $md <"$MH_TEST_DIR"/Mail/inbox/10
+run_prog $slocal -mailbox "$actual" -maildelivery "$md" \
+  <"$MH_TEST_DIR"/Mail/inbox/10
 inc -file "$actual" -silent -truncate
 rm -f "$actual"
 check "$MH_TEST_DIR/Mail/inbox/10" "$MH_TEST_DIR/Mail/inbox/11" 'keep first'
 
 # check -file
-$slocal -mailbox "$actual" -maildelivery $md -file "$MH_TEST_DIR"/Mail/inbox/1
+run_prog $slocal -mailbox "$actual" -maildelivery "$md" \
+  -file "$MH_TEST_DIR"/Mail/inbox/1
 inc -file "$actual" -silent -truncate
 rm -f "$actual"
 check "$MH_TEST_DIR/Mail/inbox/1" "$MH_TEST_DIR/Mail/inbox/11" 'keep first'
 
 # check -suppressdup
-cat >$md  <<EOF
-* 1 qpipe A "$tee $actual"
+cat >"$md"  <<EOF
+* - qpipe A "$tee $actual"
 EOF
 
-$slocal -suppressdup -maildelivery $md $mbox <"$MH_TEST_DIR"/Mail/inbox/2
+run_prog $slocal -suppressdup -maildelivery "$md" $mbox \
+  <"$MH_TEST_DIR"/Mail/inbox/2
 check "$MH_TEST_DIR/Mail/inbox/2" "$actual" 'keep first'
 
-$slocal -suppressdup -maildelivery $md $mbox <"$MH_TEST_DIR"/Mail/inbox/2
+run_prog $slocal -suppressdup -maildelivery "$md" $mbox \
+  <"$MH_TEST_DIR"/Mail/inbox/2
 if [ -f "$actual" ]; then
   echo $0: check -suppressdup failed
   failed=`expr ${failed:-0} + 1`
 fi
 
 # check -nosuppressdup
-$slocal -suppress -nosuppressdup -maildelivery $md $mbox \
+run_prog $slocal -suppress -nosuppressdup -maildelivery "$md" $mbox \
   <"$MH_TEST_DIR"/Mail/inbox/2
 check "$MH_TEST_DIR/Mail/inbox/2" "$actual" 'keep first'
 
-
 exit ${failed:-0}