#!perl -w
-# Copyright (C) 2020 all contributors <meta@public-inbox.org>
+# Copyright (C) 2020-2021 all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
use strict;
use v5.10.1;
}
my $reader = PublicInbox::MboxReader->new;
-my $write_in_full = PublicInbox::LeiToMail->can('write_in_full');
my $check_fmt = sub {
my $fmt = shift;
my @order = shuffle(keys %raw);
for my $k (@order) {
my $eml = PublicInbox::Eml->new($raw{$k});
my $buf = $eml2mbox->($eml);
- $write_in_full->($fh, $buf, undef);
+ print $fh $$buf or BAIL_OUT "print $!";
}
seek($fh, 0, SEEK_SET) or BAIL_OUT "seek: $!";
$reader->$fmt($fh, sub {
my ($eml) = @_;
+ $eml->header_set('Status');
+ $eml->header_set('Lines');
my $cur = shift @order;
my @cl = $eml->header_raw('Content-Length');
if ($fmt =~ /\Amboxcl/) {
s/\n/\r\n/sg for (values %raw);
for my $fmt (@mbox) { $check_fmt->($fmt) }
+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";
+say "From x@y Fri Oct 2 00:00:00 2010";
+print "Final: bit\n\n", "Incomplete\n\n";
+exit 1
+
+ my @x;
+ eval { $reader->mboxrd($fh, sub { push @x, shift->as_string }) };
+ like($@, qr/error closing mbox/, 'detects error reading from pipe');
+ is(scalar(@x), 1, 'only saw one message');
+ is(scalar(grep(/Final/, @x)), 0, 'no incomplete bit');
+}
+
done_testing;