Eric Wong (3): t/nntpd: fix lsof check w/ TEST_RUN_MODE=0 t/nntpd: reduce dependencies on internal API t/nntpd: die if we can't open stderr output t/nntpd.t | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
The `xqx' sub requires an absolute path for optional commands. Fixes: 6e07def560b211d9 ("testcommon: spawn-aware system() and qx[] workalikes") --- t/nntpd.t | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/t/nntpd.t b/t/nntpd.t index 66aa48f1..b2ef575d 100644 --- a/t/nntpd.t +++ b/t/nntpd.t @@ -4,6 +4,7 @@ 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; @@ -304,8 +305,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 $lsof = which('lsof') or skip 'lsof missing', 1; my $rdr = { 2 => \(my $null) }; - my @of = xqx(['lsof', '-p', $td->{pid}], undef, $rdr); + 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');
Since the advent of run_script(), we can rely on it to simplify our test code. Changes like this will let us evolve the internal API more easily while preserving stable CLI interfaces, especially since we test the v2 path by default, now. --- t/nntpd.t | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/t/nntpd.t b/t/nntpd.t index b2ef575d..2d7280a5 100644 --- a/t/nntpd.t +++ b/t/nntpd.t @@ -6,8 +6,6 @@ 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; @@ -79,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'); } } @@ -254,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/;
We need to detect FS errors and bail out on the test if we can't open a file -nntpd was just writing to. --- t/nntpd.t | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/t/nntpd.t b/t/nntpd.t index 2d7280a5..5a3a62fb 100644 --- a/t/nntpd.t +++ b/t/nntpd.t @@ -329,12 +329,12 @@ Date: Fri, 02 Oct 1993 00:00:00 +0000 $n = $s = undef; $td->join; - my $eout = eval { - local $/; + is($?, 0, 'no error in exited process'); + my $eout = do { open my $fh, '<', $err or die "open $err failed: $!"; + local $/; <$fh>; }; - is($?, 0, 'no error in exited process'); unlike($eout, qr/wide/i, 'no Wide character warnings'); }