]> Sergey Matveev's repositories - public-inbox.git/blobdiff - t/nntpd.t
t/nntpd: reduce dependencies on internal API
[public-inbox.git] / t / nntpd.t
index 43b14d66389ab6544a38b22d453f33e7295f00f7..2d7280a50d5e8a466c9a36649a916c8603aa293a 100644 (file)
--- a/t/nntpd.t
+++ b/t/nntpd.t
@@ -4,9 +4,8 @@ use strict;
 use warnings;
 use Test::More;
 use PublicInbox::TestCommon;
+use PublicInbox::Spawn qw(which);
 require_mods(qw(DBD::SQLite));
-require PublicInbox::SearchIdx;
-require PublicInbox::Msgmap;
 require PublicInbox::InboxWritable;
 use Email::Simple;
 use IO::Socket;
@@ -48,7 +47,7 @@ $ibx = PublicInbox::Inbox->new($ibx);
        my @cmd = ('-init', $group, $inboxdir, 'http://example.com/', $addr);
        push @cmd, "-V$version", '-Lbasic';
        ok(run_script(\@cmd), 'init OK');
-       is(system(qw(git config), "--file=$home/.public-inbox/config",
+       is(xsys(qw(git config), "--file=$home/.public-inbox/config",
                        "publicinbox.$group.newsgroup", $group),
                0, 'enabled newsgroup');
        my $len;
@@ -78,8 +77,8 @@ EOF
                $im->add($mime);
                $im->done;
                if ($version == 1) {
-                       my $s = PublicInbox::SearchIdx->new($ibx, 1);
-                       $s->index_sync;
+                       ok(run_script(['-index', $ibx->{inboxdir}]),
+                               'indexed v1');
                }
        }
 
@@ -253,8 +252,8 @@ Date: Fri, 02 Oct 1993 00:00:00 +0000
                $im->add($for_leafnode);
                $im->done;
                if ($version == 1) {
-                       my $s = PublicInbox::SearchIdx->new($ibx, 1);
-                       $s->index_sync;
+                       ok(run_script(['-index', $ibx->{inboxdir}]),
+                               'indexed v1');
                }
                my $hdr = $n->head("<$long_hdr>");
                my $expect = qr/\AMessage-ID: /i . qr/\Q<$long_hdr>\E/;
@@ -268,7 +267,7 @@ Date: Fri, 02 Oct 1993 00:00:00 +0000
                        $for_leafnode->header_set('Message-ID', @mids);
                        $for_leafnode->body_set('not-a-dupe');
                        my $warn = '';
-                       $SIG{__WARN__} = sub { $warn .= join('', @_) };
+                       local $SIG{__WARN__} = sub { $warn .= join('', @_) };
                        $im->add($for_leafnode);
                        $im->done;
                        like($warn, qr/reused/, 'warned for reused MID');
@@ -304,7 +303,9 @@ Date: Fri, 02 Oct 1993 00:00:00 +0000
                if ($INC{'Search/Xapian.pm'} && ($ENV{TEST_RUN_MODE}//2)) {
                        skip 'Search/Xapian.pm pre-loaded (by t/run.perl?)', 1;
                }
-               my @of = `lsof -p $td->{pid} 2>/dev/null`;
+               my $lsof = which('lsof') or skip 'lsof missing', 1;
+               my $rdr = { 2 => \(my $null) };
+               my @of = xqx([$lsof, '-p', $td->{pid}], undef, $rdr);
                skip('lsof broken', 1) if (!scalar(@of) || $?);
                my @xap = grep m!Search/Xapian!, @of;
                is_deeply(\@xap, [], 'Xapian not loaded in nntpd');