my $epoch_max = $v2w->{epoch_max};
ok($epoch_max > 0, "multiple epochs");
$v2w->done;
+$ibx->cleanup;
my ($sock, $pid);
-END { kill 'TERM', $pid if defined $pid };
+
+# TODO: replace this with ->DESTROY:
+my $owner_pid = $$;
+END { kill('TERM', $pid) if defined($pid) && $owner_pid == $$ };
$! = 0;
$sock = tcp_server();
@cmd = ("-init", '-V2', 'm', "$tmpdir/m", 'http://example.com/m',
'alt@example.com');
-ok(run_script(\@cmd, undef, {run_mode => 0}), 'initialized public-inbox -V2');
-ok(run_script(['-index', "$tmpdir/m"], undef, { run_mode => 0}), 'indexed');
+ok(run_script(\@cmd), 'initialized public-inbox -V2');
+
+ok(run_script(['-index', "$tmpdir/m"]), 'indexed');
my $mibx = { inboxdir => "$tmpdir/m", address => 'alt@example.com' };
$mibx = PublicInbox::Inbox->new($mibx);
$mime->header_set('Subject', "subject = $i");
ok($v2w->add($mime), "add msg $i OK");
}
-$v2w->barrier;
+$v2w->done;
+$ibx->cleanup;
sub fetch_each_epoch {
foreach my $i (0..$epoch_max) {
my $mset = $mibx->search->reopen->query('m:15@example.com', {mset => 1});
is(scalar($mset->items), 0, 'new message not found in mirror, yet');
-ok(run_script(["-index", "$tmpdir/m"], undef, {run_mode=>0}), 'index updated');
+ok(run_script(["-index", "$tmpdir/m"]), 'index updated');
is_deeply([$mibx->mm->minmax], [$ibx->mm->minmax], 'index synched minmax');
$mset = $mibx->search->reopen->query('m:15@example.com', {mset => 1});
is(scalar($mset->items), 1, 'found message in mirror');
is_deeply(\@subj, ["# subject = 10"], "only rewrote one");
}
-$v2w->barrier;
+$v2w->done;
my $msgs = $mibx->search->{over_ro}->get_thread('10@example.com');
my $to_purge = $msgs->[0]->{blob};
fetch_each_epoch();
{
+ $ibx->cleanup;
+ PublicInbox::InboxWritable::cleanup($mibx);
+ $v2w->done;
my $cmd = [ '-index', '--prune', "$tmpdir/m" ];
my ($out, $err) = ('', '');
- my $opt = { 1 => \$out, 2 => \$err, run_mode => 0 };
+ my $opt = { 1 => \$out, 2 => \$err };
ok(run_script($cmd, undef, $opt), '-index --prune');
like($err, qr/discontiguous range/, 'warned about discontiguous range');
unlike($err, qr/fatal/, 'no scary fatal error shown');
$mime->header_set('Subject', 'subject = 1');
ok($v2w->remove($mime), 'removed <1@example.com> from source');
$v2w->done;
+ $ibx->cleanup;
fetch_each_epoch();
+ PublicInbox::InboxWritable::cleanup($mibx);
my $cmd = [ "-index", "$tmpdir/m" ];
my ($out, $err) = ('', '');
- my $opt = { 1 => \$out, 2 => \$err, run_mode => 0 };
+ my $opt = { 1 => \$out, 2 => \$err };
ok(run_script($cmd, undef, $opt), 'index ran');
is($err, '', 'no errors reported by index');
$mset = $mibx->search->reopen->query('m:1@example.com', {mset => 1});