Create a test for the new mh-format processing available in comp(1).
authorKen Hornstein <kenh@pobox.com>
Thu, 23 Feb 2012 17:03:09 +0000 (12:03 -0500)
committerKen Hornstein <kenh@pobox.com>
Thu, 23 Feb 2012 17:03:09 +0000 (12:03 -0500)
Makefile.am
test/comp/test-comp-format [new file with mode: 0755]

index e86320e..2d3342b 100644 (file)
@@ -40,7 +40,8 @@ TESTS_ENVIRONMENT = MH_OBJ_DIR=@abs_builddir@ \
 ##
 ## Important note: the "cleanup" test should always be last
 ##
-TESTS = test/bad-input/test-header test/folder/test-create \
+TESTS = test/bad-input/test-header test/comp/test-comp-format \
+       test/folder/test-create \
        test/folder/test-total test/format/test-localmbox \
        test/format/test-myname test/format/test-myhost \
        test/format/test-mymbox \
diff --git a/test/comp/test-comp-format b/test/comp/test-comp-format
new file mode 100755 (executable)
index 0000000..1f1f8c5
--- /dev/null
@@ -0,0 +1,64 @@
+#!/bin/sh
+#
+# Tests to see if the -from, -to, -cc, -fcc, and -subject switches to
+# "comp" work correctly.
+#
+
+if test -z "${MH_OBJ_DIR}"; then
+    srcdir=`dirname "$0"`/../..
+    MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
+fi
+
+. "$MH_OBJ_DIR/test/common.sh"
+
+setup_test
+
+#
+# Create a test template file (we create one here just in case the master
+# one changes)
+#
+
+form="${MH_TEST_DIR}/$$.components"
+cat > $form <<EOF
+%(void{from})%(void(width))%(putaddr From: )
+%(void{to})%(void(width))%(putaddr To: )
+%(void{cc})%(void(width))%(putaddr cc: )
+Fcc: %{fcc}
+Subject: %{subject}
+--------
+EOF
+
+expected="${MH_TEST_DIR}/$$.expected"
+actual="${MH_TEST_DIR}/Mail/draft"
+from="Mr Test User <test@user.com>"
+to1="User One <userone@test.com>"
+to2="User Two <usertwo@test.com>"
+cc1="CC User One <ccuserone@test.com>"
+cc2="CC User Two <ccusertwo@test.com>"
+cc3="CC User Three <ccuserthree@test.com>"
+cc4="CC User Four <ccuserfour@test.com>"
+fcc1="+nosuchmailbox"
+fcc2="+nosuchmailbox2"
+subject="Totally bogus subject"
+
+cat > $expected <<EOF
+From: ${from}
+To: ${to1}, ${to2}
+cc: ${cc1},
+    ${cc2},
+    ${cc3},
+    ${cc4}
+Fcc: ${fcc1}, ${fcc2}
+Subject: ${subject}
+--------
+EOF
+
+comp -editor true -form "${form}" -from "${from}" -to "${to1}" -to "${to2}" \
+    -cc "${cc1}" -cc "${cc2}" -cc "${cc3}" -cc "${cc4}" -fcc "${fcc1}" \
+    -fcc "${fcc2}" -subject "${subject}" -width 60 -nowhatnowproc || exit 1
+
+check "${expected}" "${actual}"
+
+test "${failed:-0}" -eq 0 && rm "${form}"
+
+exit $failed