]> Sergey Matveev's repositories - public-inbox.git/blobdiff - t/mbox_reader.t
t/lei-watch: avoid race between glob + readlink
[public-inbox.git] / t / mbox_reader.t
index 30a5e6e3590e5d3c6e63963afbfe3f5973e4e172..da0ce7f1e58aff03c0c82eebfaf7536e550af96f 100644 (file)
@@ -24,6 +24,16 @@ my %raw = (
                (("b: ".('b' x 72)."\n") x 1000) .
                "From hell\n",
 );
+{
+       my $eml = PublicInbox::Eml->new($raw{small});
+       my $mbox_keywords = PublicInbox::MboxReader->can('mbox_keywords');
+       is_deeply($mbox_keywords->($eml), [], 'no keywords');
+       $eml->header_set('Status', 'RO');
+       is_deeply($mbox_keywords->($eml), ['seen'], 'seen extracted');
+       $eml->header_set('X-Status', 'A');
+       is_deeply($mbox_keywords->($eml), [qw(answered seen)],
+               'seen+answered extracted');
+}
 
 if ($ENV{TEST_EXTRA}) {
        for my $fn (glob('t/*.eml'), glob('t/*/*.{patch,eml}')) {
@@ -74,9 +84,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";