about summary refs log tree commit homepage
path: root/t/mbox_reader.t
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-02-12 00:05:52 -0700
committerEric Wong <e@80x24.org>2021-02-12 22:58:31 -0400
commit376778b910cdf787d6e08cfd11acab26118899f4 (patch)
treefac5cc3de7cefa9629510917ca98bc4d9ac40758 /t/mbox_reader.t
parent1138a7a940ec40ad4394aa55413456a6f6fd341e (diff)
downloadpublic-inbox-376778b910cdf787d6e08cfd11acab26118899f4.tar.gz
It's conceivable some cases won't generate an empty line before
an mboxrd or mboxo From_ line.  Ensure we can handle that case
and don't leave the Eml->{bdy} without a trailing LF character.

And drop an unnecessary alarm import while we're in the area.
Diffstat (limited to 't/mbox_reader.t')
-rw-r--r--t/mbox_reader.t22
1 files changed, 21 insertions, 1 deletions
diff --git a/t/mbox_reader.t b/t/mbox_reader.t
index 30a5e6e3..18d0fd68 100644
--- a/t/mbox_reader.t
+++ b/t/mbox_reader.t
@@ -74,9 +74,29 @@ for my $fmt (@mbox) { $check_fmt->($fmt) }
 s/\n/\r\n/sg for (values %raw);
 for my $fmt (@mbox) { $check_fmt->($fmt) }
 
+{
+        my $no_blank_eom = <<'EOM';
+From x@y Fri Oct  2 00:00:00 1993
+a: b
+
+body1
+From x@y Fri Oct  2 00:00:00 1993
+c: d
+
+body2
+EOM
+        # chop($no_blank_eom) eq "\n" or BAIL_OUT 'broken LF';
+        for my $variant (qw(mboxrd mboxo)) {
+                my @x;
+                open my $fh, '<', \$no_blank_eom or BAIL_OUT 'PerlIO::scalar';
+                $reader->$variant($fh, sub { push @x, shift });
+                is_deeply($x[0]->{bdy}, \"body1\n", 'LF preserved in 1st');
+                is_deeply($x[1]->{bdy}, \"body2\n", 'no LF added in 2nd');
+        }
+}
+
 SKIP: {
         use PublicInbox::Spawn qw(popen_rd);
-        use Time::HiRes qw(alarm);
         my $fh = popen_rd([ $^X, '-E', <<'' ]);
 say "From x@y Fri Oct  2 00:00:00 1993";
 print "a: b\n\n", "x" x 70000, "\n\n";