user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
* [PATCH 0/3] t/nntpd: small fixes and cleanups
@ 2020-04-21  3:22 Eric Wong
  2020-04-21  3:22 ` [PATCH 1/3] t/nntpd: fix lsof check w/ TEST_RUN_MODE=0 Eric Wong
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Eric Wong @ 2020-04-21  3:22 UTC (permalink / raw)
  To: meta

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(-)


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] t/nntpd: fix lsof check w/ TEST_RUN_MODE=0
  2020-04-21  3:22 [PATCH 0/3] t/nntpd: small fixes and cleanups Eric Wong
@ 2020-04-21  3:22 ` Eric Wong
  2020-04-21  3:22 ` [PATCH 2/3] t/nntpd: reduce dependencies on internal API Eric Wong
  2020-04-21  3:22 ` [PATCH 3/3] t/nntpd: die if we can't open stderr output Eric Wong
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2020-04-21  3:22 UTC (permalink / raw)
  To: meta

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');

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/3] t/nntpd: reduce dependencies on internal API
  2020-04-21  3:22 [PATCH 0/3] t/nntpd: small fixes and cleanups Eric Wong
  2020-04-21  3:22 ` [PATCH 1/3] t/nntpd: fix lsof check w/ TEST_RUN_MODE=0 Eric Wong
@ 2020-04-21  3:22 ` Eric Wong
  2020-04-21  3:22 ` [PATCH 3/3] t/nntpd: die if we can't open stderr output Eric Wong
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2020-04-21  3:22 UTC (permalink / raw)
  To: meta

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/;

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 3/3] t/nntpd: die if we can't open stderr output
  2020-04-21  3:22 [PATCH 0/3] t/nntpd: small fixes and cleanups Eric Wong
  2020-04-21  3:22 ` [PATCH 1/3] t/nntpd: fix lsof check w/ TEST_RUN_MODE=0 Eric Wong
  2020-04-21  3:22 ` [PATCH 2/3] t/nntpd: reduce dependencies on internal API Eric Wong
@ 2020-04-21  3:22 ` Eric Wong
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2020-04-21  3:22 UTC (permalink / raw)
  To: meta

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');
 }
 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-04-21  3:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-21  3:22 [PATCH 0/3] t/nntpd: small fixes and cleanups Eric Wong
2020-04-21  3:22 ` [PATCH 1/3] t/nntpd: fix lsof check w/ TEST_RUN_MODE=0 Eric Wong
2020-04-21  3:22 ` [PATCH 2/3] t/nntpd: reduce dependencies on internal API Eric Wong
2020-04-21  3:22 ` [PATCH 3/3] t/nntpd: die if we can't open stderr output Eric Wong

Code repositories for project(s) associated with this inbox:

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).