Added mhbuild: -nocontentid to profile used for tests, to simplify
[mmh] / test / mhmail / test-mhmail
index 0877d06..fdb3617 100755 (executable)
@@ -57,8 +57,7 @@ test_mhmail ()
 
     sed -e 's/^Date:.*/Date:/' \
         -e 's/^Resent-Date:.*/Resent-Date:/' \
-        -e 's/^Message-ID:.*/Message-ID:/' \
-        -e 's/^Content-ID:.*/Content-ID:/' "$actual" > "$actual".nodate
+        -e 's/^Message-ID:.*/Message-ID:/' "$actual" > "$actual".nodate
     rm -f "$actual"
 
     check "$actual".nodate "$1"
@@ -73,7 +72,7 @@ actual_err=$MH_TEST_DIR/test-mhmail$$.actual_err
 # check -help
 # Verified behavior consistent with compiled sendmail.
 cat >$expected <<EOF
-Usage: mhmail [addrs ... [switches]]
+Usage: mhmail [-t(o)] addrs ... [switches]
   switches are:
   -at(tach) file [-at(tach) file] ...
   -b(ody) text
@@ -88,6 +87,7 @@ Usage: mhmail [addrs ... [switches]]
   -v(ersion)
   -hel(p)
   and all post(8)/send(1) switches
+  mhmail with no arguments is equivalent to inc
 EOF
 
 mhmail -help >$actual 2>&1
@@ -102,8 +102,22 @@ case `mhmail -v` in
                 failed=`expr ${failed:-0} + 1`;;
 esac
 
-
-# check with no arguments
+# check for missing argument to switches that require them
+for switch in attach body cc from headerfield subject to; do
+  run_test "mhmail recipient -$switch" \
+           "mhmail: missing argument to -$switch"
+done
+for switch in attach body cc from headerfield subject to; do
+  run_test "mhmail recipient -$switch -nosend" \
+           "mhmail: missing argument to -$switch"
+done
+for switch in attach body cc from headerfield subject to; do
+  run_test "mhmail recipient -$switch -server 127.0.0.1" \
+           "mhmail: missing argument to -$switch"
+done
+
+
+# check with no switches
 # That will just run inc, which we don't want to do anything,
 # so tell inc to just display its version.
 # Verified same behavior as compiled mhmail.
@@ -294,7 +308,7 @@ test_mhmail "$expected" '-from sender@localhost -profile' '|' message
 [ ${failed:-0} -eq 0 ] || exit ${failed:-0}
 
 
-# check repeated -from and -subject arguments
+# check repeated -from and -subject switches
 # Verified same behavior as compiled mhmail.
 cat > "$expected" <<EOF
 EHLO nosuchhost.example.com
@@ -315,7 +329,7 @@ test_mhmail "$expected" '-from sender@localhost -from sender2@localhost '\
 '-subject Subject1 -subject Subject2' -b message
 [ ${failed:-0} -eq 0 ] || exit ${failed:-0}
 
-# check repeated -body arguments
+# check repeated -body switches
 # Verified same behavior as compiled mhmail.
 cat > "$expected" <<EOF
 EHLO nosuchhost.example.com
@@ -335,7 +349,7 @@ test_mhmail "$expected" "-from sender@localhost -body body1" -b body2
 [ ${failed:-0} -eq 0 ] || exit ${failed:-0}
 
 
-# check multiple -cc arguments
+# check multiple -cc switches
 # Verified same behavior as compiled mhmail.
 cat > "$expected" <<EOF
 EHLO nosuchhost.example.com
@@ -385,6 +399,33 @@ test_mhmail "$expected" \
 [ ${failed:-0} -eq 0 ] || exit ${failed:-0}
 
 
+# check -cc switch followed by -to switch
+# Verified same behavior as compiled mhmail.
+cat > "$expected" <<EOF
+EHLO nosuchhost.example.com
+MAIL FROM:<sender@localhost>
+RCPT TO:<recipient@example.com>
+RCPT TO:<recipient2@example.com>
+RCPT TO:<cc1@example.com>
+DATA
+To: recipient@example.com, recipient2@example.com
+Cc: cc1@example.com
+Subject: Test
+From: sender@localhost
+Date:
+
+message
+.
+QUIT
+EOF
+
+test_mhmail "$expected" \
+  "-from sender@localhost -cc cc1@example.com -subject Test \
+   -to recipient2@example.com" \
+  -b message
+[ ${failed:-0} -eq 0 ] || exit ${failed:-0}
+
+
 # check with no newline on stdin
 # Shows different behavior than compiled mhmail, which was silent in this case.
 cat > "$expected" <<EOF
@@ -753,7 +794,6 @@ To: recipient@example.com
 From: sender@example.com
 MIME-Version: 1.0
 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
-Content-ID:
 Date:
 Message-ID: