# Use proper program, maybe not the first one on PATH.
slocal="$MH_LIBEXEC_DIR"/slocal
+check_exit '-eq 1' $slocal -
+
expected="$MH_TEST_DIR"/$$.expected
actual="$MH_TEST_DIR"/$$.actual
actual2="$MH_TEST_DIR"/$$.actual2
md="$MH_TEST_DIR"/Mail/maildelivery
# check -help
+start_test "-help"
cat >"$expected" <<EOF
Usage: slocal [switches]
switches are:
EOF
#### Skip nmh intro text.
-run_prog $slocal -help | sed '/^$/,$d' >"$actual" 2>&1
+run_prog $slocal -help 2>&1 | sed '/^$/,$d' >"$actual"
check "$expected" "$actual"
# check -version
+start_test "-version"
case `$slocal -vers` in
slocal\ --*) ;;
* ) printf '%s: slocal -vers generated unexpected output\n' "$0" >&2
esac
# check unknown switch
+start_test "unknown switch"
run_test "$slocal -nonexistent" 'slocal: -nonexistent unknown'
# check non-switch argument
+start_test "non-switch argument"
run_test "$slocal nonexistent" 'slocal: only switch arguments are supported'
# If no mail spool, explicitly specify the mailbox.
[ -x /usr/bin/tee ] && tee=/usr/bin/tee || tee=tee
# check basic operation
+start_test "basic operation"
# Can't use rcvstore because slocal wipes out the environment.
# So, it would put the message in the user's inbox, not the
# test inbox. slocal also freopens stdout and stderr to
fi
# check -debug
+start_test "-debug"
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
+start_test "-verbose"
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
+start_test "-noverbose"
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
+start_test "match of From"
cat >"$md" <<EOF
From test2@example.com qpipe A "$tee $actual"
EOF
check "$MH_TEST_DIR/Mail/inbox/2" "$actual" 'keep first'
# check R and ?
+start_test "R and ?"
cat >"$md" <<EOF
From test3@example.com qpipe R "$tee $actual"
From test3@example.com qpipe ? "$tee $actual2"
check "$MH_TEST_DIR/Mail/inbox/3" "$actual2" 'keep first'
# check R and N
+start_test "R and N"
cat >"$md" <<EOF
From test4@example.com qpipe R "$tee $actual"
From test4@example.com qpipe N "$tee $actual2"
check "$MH_TEST_DIR/Mail/inbox/4" "$actual2" 'keep first'
# check default
+start_test "default"
cat >"$md" <<EOF
From test5@example.com qpipe R "$tee $actual"
default 1 qpipe A "$tee $actual2"
check "$MH_TEST_DIR/Mail/inbox/5" "$actual2" 'keep first'
# check -addr
+start_test "-addr"
cat >"$md" <<EOF
addr someaddress qpipe A "$tee $actual"
EOF
check "$MH_TEST_DIR/Mail/inbox/6" "$actual" 'keep first'
# check -addr with . in address
+start_test "-addr with . in address"
cat >"$md" <<EOF
addr "first.last" qpipe A "$tee $actual"
EOF
check "$MH_TEST_DIR/Mail/inbox/6" "$actual" 'keep first'
# check -info
+start_test "-info"
cat >"$md" <<EOF
* - qpipe A "\$(info) $actual"
EOF
check "$MH_TEST_DIR/Mail/inbox/7" "$actual" 'keep first'
# check -sender, which is compared with "source"
+start_test "-sender, which is compared with "source""
cat >"$md" <<EOF
source somesender qpipe A "$tee $actual"
EOF
check "$MH_TEST_DIR/Mail/inbox/8" "$actual" 'keep first'
# check -user
+start_test "-user"
cat >"$md" <<EOF
* - qpipe A "$tee $actual"
EOF
# that there is one.
# check -mailbox
+start_test "-mailbox"
cat >"$md" <<EOF
EOF
check "$MH_TEST_DIR/Mail/inbox/10" "$MH_TEST_DIR/Mail/inbox/11" 'keep first'
# check -file
+start_test "-file"
run_prog $slocal -mailbox "$actual" -maildelivery "$md" \
-file "$MH_TEST_DIR"/Mail/inbox/1
inc -file "$actual" -silent -truncate
check "$MH_TEST_DIR/Mail/inbox/1" "$MH_TEST_DIR/Mail/inbox/11" 'keep first'
# check -suppressdup
+start_test "-suppressdup"
cat >"$md" <<EOF
* - qpipe A "$tee $actual"
EOF
fi
# check -nosuppressdup
+start_test "-nosuppressdup"
run_prog $slocal -suppress -nosuppressdup -maildelivery "$md" $mbox \
<"$MH_TEST_DIR"/Mail/inbox/2
check "$MH_TEST_DIR/Mail/inbox/2" "$actual" 'keep first'
+finish_test
exit ${failed:-0}