# filter out pipes inherited from the parent
my @this = `lsof -p $$`;
my $bad;
- sub extract_inodes {
+ my $extract_inodes = sub {
map {;
my @f = split(' ', $_);
my $inode = $f[-2];
$bad = $_ if $inode !~ /\A[0-9]+\z/;
$inode => 1;
} grep (/\bpipe\b/, @_);
- }
- my %child = extract_inodes(@lsof);
- my %parent = extract_inodes(@this);
+ };
+ my %child = $extract_inodes->(@lsof);
+ my %parent = $extract_inodes->(@this);
skip("inode not in expected format: $bad", 1) if defined($bad);
delete @child{(keys %parent)};
is_deeply([], [keys %child], 'no extra pipes with -W0');
plan skip_all => "$mod missing for $0" if $@;
}
-my @xcpdb = qw(-xcpdb -q);
-
my $mime = PublicInbox::MIME->create(
header => [
From => 'a@example.com',
);
sub import_index_incremental {
- my ($v, $level) = @_;
+ my ($v, $level, $mime) = @_;
my $this = "pi-$v-$level-indexlevels";
my ($tmpdir, $for_destroy) = tmpdir();
local $ENV{PI_CONFIG} = "$tmpdir/config";
is_deeply(\@rw_nums, [1], 'unindex NNTP article'.$v.$level);
if ($level ne 'basic') {
- ok(run_script([@xcpdb, $mirror]), "v$v xcpdb OK");
+ ok(run_script(['-xcpdb', '-q', $mirror]), "v$v xcpdb OK");
is(PublicInbox::Admin::detect_indexlevel($ro_mirror), $level,
'indexlevel detectable by Admin after xcpdb v' .$v.$level);
delete $ro_mirror->{$_} for (qw(over search));
}
# we can probably cull some other tests
-import_index_incremental($PI_TEST_VERSION, 'basic');
+import_index_incremental($PI_TEST_VERSION, 'basic', $mime);
SKIP: {
require PublicInbox::Search;
PublicInbox::Search::load_xapian() or skip 'Search::Xapian missing', 2;
foreach my $l (qw(medium full)) {
- import_index_incremental($PI_TEST_VERSION, $l);
+ import_index_incremental($PI_TEST_VERSION, $l, $mime);
}
}
my $mime;
my $git = PublicInbox::Git->new($maindir);
+my $fail_bad_header = sub ($$$) {
+ my ($good_rev, $msg, $in) = @_;
+ my @f = glob("$faildir/*/*");
+ unlink @f if @f;
+ my ($out, $err) = ("", "");
+ my $opt = { 0 => \$in, 1 => \$out, 2 => \$err };
+ local $ENV{PATH} = $main_path;
+ ok(run_script(['-mda'], undef, $opt),
+ "no error on undeliverable ($msg)");
+ my $rev = $git->qx(qw(rev-list HEAD));
+ chomp $rev;
+ is($rev, $good_rev, "bad revision not commited ($msg)");
+ @f = glob("$faildir/*/*");
+ is(scalar @f, 1, "faildir written to");
+ [ $in, $out, $err ];
+};
+
{
ok(-x "$main_bin/spamc",
"spamc ham mock found (run in top of source tree");
is(scalar @new, 1, "PI_EMERGENCY is written to");
}
- fail_bad_header($good_rev, "bad recipient", <<"");
+ $fail_bad_header->($good_rev, "bad recipient", <<"");
From: Me <me\@example.com>
To: You <you\@example.com>
Message-Id: <bad-recipient\@example.com>
Subject: hihi
Date: Thu, 01 Jan 1970 00:00:00 +0000
- my $fail = fail_bad_header($good_rev, "duplicate Message-ID", <<"");
+ my $fail = $fail_bad_header->($good_rev, "duplicate Message-ID", <<"");
From: Me <me\@example.com>
To: You <you\@example.com>
Cc: $addr
like($fail->[2], qr/CONFLICT/, "duplicate Message-ID message");
- fail_bad_header($good_rev, "missing From:", <<"");
+ $fail_bad_header->($good_rev, "missing From:", <<"");
To: $addr
Message-ID: <missing-from\@example.com>
Subject: hihi
Date: Thu, 01 Jan 1970 00:00:00 +0000
- fail_bad_header($good_rev, "short subject:", <<"");
+ $fail_bad_header->($good_rev, "short subject:", <<"");
To: $addr
From: cat\@example.com
Message-ID: <short-subject\@example.com>
Subject: a
Date: Thu, 01 Jan 1970 00:00:00 +0000
- fail_bad_header($good_rev, "no date", <<"");
+ $fail_bad_header->($good_rev, "no date", <<"");
To: $addr
From: u\@example.com
Message-ID: <no-date\@example.com>
Subject: hihi
- fail_bad_header($good_rev, "bad date", <<"");
+ $fail_bad_header->($good_rev, "bad date", <<"");
To: $addr
From: u\@example.com
Message-ID: <bad-date\@example.com>
}
done_testing();
-
-sub fail_bad_header {
- my ($good_rev, $msg, $in) = @_;
- my @f = glob("$faildir/*/*");
- unlink @f if @f;
- my ($out, $err) = ("", "");
- my $opt = { 0 => \$in, 1 => \$out, 2 => \$err };
- local $ENV{PATH} = $main_path;
- ok(run_script(['-mda'], undef, $opt),
- "no error on undeliverable ($msg)");
- my $rev = $git->qx(qw(rev-list HEAD));
- chomp $rev;
- is($rev, $good_rev, "bad revision not commited ($msg)");
- @f = glob("$faildir/*/*");
- is(scalar @f, 1, "faildir written to");
- [ $in, $out, $err ];
-}
require PublicInbox::InboxWritable;
require PublicInbox::MIME;
require PublicInbox::SearchIdx;
-my $need_zlib;
+our $need_zlib;
eval { require Compress::Raw::Zlib } or
$need_zlib = 'Compress::Raw::Zlib missing';
my $version = 2; # v2 needs newer git
my $im = PublicInbox::V2Writable->new($ibx, 1);
$im->{parallel} = 0;
-sub deliver_patch ($) {
+my $deliver_patch = sub ($) {
open my $fh, '<', $_[0] or die "open: $!";
my $mime = PublicInbox::MIME->new(do { local $/; <$fh> });
$im->add($mime);
$im->done;
-}
+};
-deliver_patch('t/solve/0001-simple-mod.patch');
+$deliver_patch->('t/solve/0001-simple-mod.patch');
my $v1_0_0_tag = 'cb7c42b1e15577ed2215356a2bf925aef59cdd8d';
+
my $git = PublicInbox::Git->new($git_dir);
is('public-inbox 1.0.0',
$git->commit_title($v1_0_0_tag),
$solver->solve($psgi_env, $log, $git_v2_20_1_tag, {});
is($res, undef, 'no error on a tag not in our repo');
-deliver_patch('t/solve/0002-rename-with-modifications.patch');
+$deliver_patch->('t/solve/0002-rename-with-modifications.patch');
$solver = PublicInbox::SolverGit->new($ibx, sub { $res = $_[0] });
$solver->solve($psgi_env, $log, '0a92431', {});
ok($res, 'resolved without hints');
$v2w->done;
$ibx->cleanup;
-sub fetch_each_epoch {
+my $fetch_each_epoch = sub {
foreach my $i (0..$epoch_max) {
my $dir = "$tmpdir/m/git/$i.git";
is(system('git', "--git-dir=$dir", 'fetch', '-q'), 0,
'fetch successful');
}
-}
+};
-fetch_each_epoch();
+$fetch_each_epoch->();
my $mset = $mibx->search->reopen->query('m:15@example.com', {mset => 1});
is(scalar($mset->items), 0, 'new message not found in mirror, yet');
$mset = $ibx->search->reopen->query('m:10@example.com', {mset => 1});
is(scalar($mset->items), 0, 'purged message gone from origin');
-fetch_each_epoch();
+$fetch_each_epoch->();
{
$ibx->cleanup;
PublicInbox::InboxWritable::cleanup($mibx);
ok($v2w->remove($mime), 'removed <1@example.com> from source');
$v2w->done;
$ibx->cleanup;
- fetch_each_epoch();
+ $fetch_each_epoch->();
PublicInbox::InboxWritable::cleanup($mibx);
my $cmd = [ "-index", "$tmpdir/m" ];
};
$ctx->{-inbox}->{-primary_address} = 'test@example.com';
-sub msg_html ($) {
- my ($mime) = @_;
+sub msg_html ($$) {
+ my ($ctx, $mime) = @_;
my $s = '';
my $r = PublicInbox::View::msg_html($ctx, $mime);
body => $body,
)->as_string;
my $mime = Email::MIME->new($s);
- my $html = msg_html($mime);
+ my $html = msg_html($ctx, $mime);
# ghetto tests
like($html, qr!<a\nhref="raw"!s, "raw link present");
parts => $parts,
);
- my $html = msg_html($mime);
+ my $html = msg_html($ctx, $mime);
like($html, qr/hi\n.*-- Attachment #2.*\nbye\n/s, "multipart split");
}
parts => $parts,
);
- my $html = msg_html($mime);
+ my $html = msg_html($ctx, $mime);
like($html, qr!.*Attachment #2: foo&(?:amp|#38);\.patch --!,
"parts split with filename");
}
);
my $orig = $mime->body_raw;
- my $html = msg_html($mime);
+ my $html = msg_html($ctx, $mime);
like($orig, qr/hi =3D bye=/, "our test used QP correctly");
like($html, qr/\bhi = bye\b/, "HTML output decoded QP");
}
'got fingerprint with non-empty repo');
sub tiny_test {
- my ($host, $port) = @_;
+ my ($json, $host, $port) = @_;
my $http = HTTP::Tiny->new;
my $res = $http->get("http://$host:$port/manifest.js.gz");
is($res->{status}, 200, 'got manifest');
$td = start_script($cmd, $env, { 3 => $sock });
$sock = undef;
- tiny_test($host, $port);
+ tiny_test($json, $host, $port);
skip 'skipping grok-pull integration test', 2 if !which('grok-pull');