diff options
author | Eric Wong <e@80x24.org> | 2021-01-19 09:34:31 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2021-01-21 03:29:10 +0000 |
commit | a14bc9e6cdd70f38eaa2961d1ea775300b9577ea (patch) | |
tree | f97c4ff6a3e1e8824e8fa1f72939444845183f33 /t | |
parent | 15bed10a92def9645d81ccb319f285e927dc3327 (diff) | |
download | public-inbox-a14bc9e6cdd70f38eaa2961d1ea775300b9577ea.tar.gz |
We need to delay writing out the mailbox until the compressor process is up and running, so have startq wait a bit. This means we must create the pipe early and hand it off to the workers before augmenting, despite spawning the gzip/pigz/xz/bzip2 process after augment is complete.
Diffstat (limited to 't')
-rw-r--r-- | t/lei.t | 42 | ||||
-rw-r--r-- | t/lei_to_mail.t | 4 |
2 files changed, 28 insertions, 18 deletions
@@ -189,25 +189,35 @@ my $test_external = sub { # No double-quoting should be imposed on users on the CLI $lei->('q', 's:use boolean prefix'); like($out, qr/search: use boolean prefix/, 'phrase search got result'); + require IO::Uncompress::Gunzip; + for my $sfx ('', '.gz') { + my $f = "$home/mbox$sfx"; + $lei->('q', '-o', "mboxcl2:$f", 's:use boolean prefix'); + my $cat = $sfx eq '' ? sub { + open my $mb, '<', $f or fail "no mbox: $!"; + <$mb> + } : sub { + my $z = IO::Uncompress::Gunzip->new($f, MultiStream=>1); + <$z>; + }; + my @s = grep(/^Subject:/, $cat->()); + is(scalar(@s), 1, "1 result in mbox$sfx"); + $lei->('q', '-a', '-o', "mboxcl2:$f", 's:see attachment'); + is($err, '', 'no errors from augment'); + @s = grep(/^Subject:/, my @wtf = $cat->()); + is(scalar(@s), 2, "2 results in mbox$sfx"); - $lei->('q', '-o', "mboxcl2:$home/mbox", 's:use boolean prefix'); - open my $mb, '<', "$home/mbox" or fail "no mbox: $!"; - my @s = grep(/^Subject:/, <$mb>); - is(scalar(@s), 1, '1 result in mbox'); - $lei->('q', '-a', '-o', "mboxcl2:$home/mbox", 's:see attachment'); - is($err, '', 'no errors from augment'); - seek($mb, 0, SEEK_SET) or BAIL_OUT "seek: $!"; - @s = grep(/^Subject:/, <$mb>); - is(scalar(@s), 2, '2 results in mbox'); + $lei->('q', '-a', '-o', "mboxcl2:$f", 's:nonexistent'); + is($err, '', "no errors on no results ($sfx)"); - $lei->('q', '-a', '-o', "mboxcl2:$home/mbox", 's:nonexistent'); - is($err, '', 'no errors on no results'); - seek($mb, 0, SEEK_SET) or BAIL_OUT "seek: $!"; - my @s2 = grep(/^Subject:/, <$mb>); - is_deeply(\@s2, \@s, 'same 2 old results w/ --augment and bad search'); + my @s2 = grep(/^Subject:/, $cat->()); + is_deeply(\@s2, \@s, + "same 2 old results w/ --augment and bad search $sfx"); - $lei->('q', '-o', "mboxcl2:$home/mbox", 's:nonexistent'); - is(-s "$home/mbox", 0, 'clobber w/o --augment'); + $lei->('q', '-o', "mboxcl2:$f", 's:nonexistent'); + my @res = $cat->(); + is_deeply(\@res, [], "clobber w/o --augment $sfx"); + } }; my $test_lei_common = sub { diff --git a/t/lei_to_mail.t b/t/lei_to_mail.t index e5ac8eac..6673d9a6 100644 --- a/t/lei_to_mail.t +++ b/t/lei_to_mail.t @@ -94,9 +94,9 @@ my $wcb_get = sub { my $dup = Storable::thaw(Storable::freeze($l2m)); is_deeply($dup, $l2m, "$fmt round-trips through storable"); } - $l2m->pre_augment($lei); + my $zpipe = $l2m->pre_augment($lei); $l2m->do_augment($lei); - $l2m->post_augment($lei); + $l2m->post_augment($lei, $zpipe); my $cb = $l2m->write_cb($lei); delete $lei->{1}; $cb; |