I have updated the patch to test-pop that I included in my bug
report.  Unlike the test in the bug report, this version passes.

I propose that this patch be applied to HEAD now:


Enhance test-pop with two new features

First, the test includes a message with a long line.  The length
of the long line is a variable, and the default is something
that inc can handle.  Using an envvar to increase the line
length, the test can provide an easy way to validate
enhancements that let inc handle arbitrarily long lines.

Second, the test now checks the message length to verify that
inc did not truncate the message.  This makes the test more
thorough even for the current inc.

Passing with defaults:
$ make check-TESTS TESTS=test/inc/test-pop

Failing with a longer line:
$ MH_TEST_LONG_LINE=10000 make check-TESTS TESTS=test/inc/test-pop


diff --git a/test/inc/test-pop b/test/inc/test-pop
index 8b3fbe03..87ff9299 100755
--- a/test/inc/test-pop
+++ b/test/inc/test-pop
@@ -2,8 +2,6 @@
 ######################################################
 #
 # Test POP support in inc
-# Only tests checking of local maildrop, does not
-# test checking of POP server.
 #
 ######################################################
 
@@ -49,6 +47,22 @@ Hey man, how's it going?
 .
 Hope you're doing better.
 EOM
+# Test that inc can handle a message body with a long line.
+#   There are a few mail-senders that (incorrectly) generate image/jpeg
+#   parts with no newlines, resulting in one very long encoded line.
+# This test passes because it sets long_line to a value that inc can handle.
+#   When inc is fixed to handle arbitrarily long lines, change this
+#   test to use 50000.
+# You can run that harder test now by setting envvar MH_TEST_LONG_LINE=50000
+long_line=${MH_TEST_LONG_LINE:-5000}
+while [ "$long_line" -gt 0 ]; do
+    printf 'Abcdefghijklmnopqrstuvwxyz. ' >> "$testmessage"
+    arith_eval "$long_line" - 28
+    long_line=$arith_val
+done
+echo >> "$testmessage"
+msg_size=`wc -c < "$testmessage"`
+msg_size=`printf %7d "$msg_size"`
 
 cat > "${testmessage}.2" <<EOM
 Received: From somewhere
@@ -70,6 +84,16 @@ Date: Tuesday, 19 Dec 2006 4:15:16 -0500
 Dude, nmh is totally brutal.
 EOM
 
+# Create a custom format to include the message size in the scan,
+# to check whether "inc" truncated the message.
+formfile=$MH_TEST_DIR/form
+cat > "$formfile" <<EOF
+%4(msg)%<(cur)+%| %> \
+%02(mon{date})/%02(mday{date})%<{date} %|*%>\
+%7(size) \
+%17(friendly{from})  %{subject}<<%{body}
+EOF
+
 # Check netrc's permissions test
 start_test "netrc's permissions test"
 pid=`"${MH_OBJ_DIR}/test/fakepop" "$testport" '' '' "$testmessage"`
@@ -82,11 +106,10 @@ chmod go= $netrc
 pid=`"${MH_OBJ_DIR}/test/fakepop" "$testport" \
 			"$TESTUSER" "$TESTPASS" "$testmessage"`
 
-run_test "inc -user ${TESTUSER} -host 127.0.0.1 -port $testport -width 80" \
+run_test "inc -user ${TESTUSER} -host 127.0.0.1 -port $testport -width 80 -form ${formfile}" \
 	"Incorporating new mail into inbox...
 
-  11+ 12/17 No Such User       Hello<<Hey man, how's it going? . Hope you're do\
-i"
+  11+ 12/17 $msg_size No Such User       Hello<<Hey man, how's it going? . Hope yo"
 check "$testmessage" `mhpath +inbox 11` 'keep first'
 
 # Check multiple messages at once

Reply via email to