* [PATCH 0/2] test fixes for optional deps
@ 2023-09-12 12:25 Eric Wong
2023-09-12 12:25 ` [PATCH 1/2] tests: favor IO::Socket::IP for IPv6 listeners Eric Wong
2023-09-12 12:25 ` [PATCH 2/2] tests: allow more tests to pass without xapian-compact Eric Wong
0 siblings, 2 replies; 3+ messages in thread
From: Eric Wong @ 2023-09-12 12:25 UTC (permalink / raw)
To: meta
More corner-cases uncovered...
Eric Wong (2):
tests: favor IO::Socket::IP for IPv6 listeners
tests: allow more tests to pass without xapian-compact
lib/PublicInbox/TestCommon.pm | 11 ++++++++---
t/extsearch.t | 2 +-
t/nntpd.t | 4 ++--
t/xcpdb-reshard.t | 2 +-
4 files changed, 12 insertions(+), 7 deletions(-)
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] tests: favor IO::Socket::IP for IPv6 listeners
2023-09-12 12:25 [PATCH 0/2] test fixes for optional deps Eric Wong
@ 2023-09-12 12:25 ` Eric Wong
2023-09-12 12:25 ` [PATCH 2/2] tests: allow more tests to pass without xapian-compact Eric Wong
1 sibling, 0 replies; 3+ messages in thread
From: Eric Wong @ 2023-09-12 12:25 UTC (permalink / raw)
To: meta
IO::Socket::IP is bundled with Perl 5.24+ so it's more likely
to be available than IO::Socket::INET6.
---
lib/PublicInbox/TestCommon.pm | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/lib/PublicInbox/TestCommon.pm b/lib/PublicInbox/TestCommon.pm
index 17057e18..b1a37ced 100644
--- a/lib/PublicInbox/TestCommon.pm
+++ b/lib/PublicInbox/TestCommon.pm
@@ -62,8 +62,12 @@ sub tcp_server () {
);
eval {
die 'IPv4-only' if $ENV{TEST_IPV4_ONLY};
- require IO::Socket::INET6;
- IO::Socket::INET6->new(%opt, LocalAddr => '[::1]')
+ my $pkg;
+ for (qw(IO::Socket::IP IO::Socket::INET6)) {
+ eval "require $_" or next;
+ $pkg = $_ and last;
+ }
+ $pkg->new(%opt, LocalAddr => '[::1]');
} || eval {
die 'IPv6-only' if $ENV{TEST_IPV6_ONLY};
IO::Socket::INET->new(%opt, LocalAddr => '127.0.0.1')
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] tests: allow more tests to pass without xapian-compact
2023-09-12 12:25 [PATCH 0/2] test fixes for optional deps Eric Wong
2023-09-12 12:25 ` [PATCH 1/2] tests: favor IO::Socket::IP for IPv6 listeners Eric Wong
@ 2023-09-12 12:25 ` Eric Wong
1 sibling, 0 replies; 3+ messages in thread
From: Eric Wong @ 2023-09-12 12:25 UTC (permalink / raw)
To: meta
---
lib/PublicInbox/TestCommon.pm | 3 ++-
t/extsearch.t | 2 +-
t/nntpd.t | 4 ++--
t/xcpdb-reshard.t | 2 +-
4 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/lib/PublicInbox/TestCommon.pm b/lib/PublicInbox/TestCommon.pm
index b1a37ced..a8323e4d 100644
--- a/lib/PublicInbox/TestCommon.pm
+++ b/lib/PublicInbox/TestCommon.pm
@@ -105,7 +105,8 @@ sub require_cmd ($;$) {
my $bin = $CACHE{$cmd} //= PublicInbox::Spawn::which($cmd);
return $bin if $bin;
return plan(skip_all => "$cmd missing from PATH for $0") if !$nr;
- defined(wantarray) ? undef : skip("$cmd missing, skipping $nr tests")
+ defined(wantarray) ? undef :
+ skip("$cmd missing, skipping $nr tests", $nr);
}
sub have_xapian_compact (;$) {
diff --git a/t/extsearch.t b/t/extsearch.t
index 545330aa..8ded3382 100644
--- a/t/extsearch.t
+++ b/t/extsearch.t
@@ -480,7 +480,7 @@ SKIP: {
for my $i (2..3) {
is(grep(m!/ei[0-9]+/$i\z!, @dirs), 0, "no shard [$i]");
}
- skip 'xapian-compact missing', 4 unless have_xapian_compact;
+ have_xapian_compact 1;
ok(run_script([qw(-compact), $d], undef, $o), 'compact');
# n.b. stderr contains xapian-compact output
diff --git a/t/nntpd.t b/t/nntpd.t
index f98d638e..9a7efd86 100644
--- a/t/nntpd.t
+++ b/t/nntpd.t
@@ -341,8 +341,8 @@ Date: Fri, 02 Oct 1993 00:00:00 +0000
}
# -compact requires Xapian
SKIP: {
- require_mods('Xapian', 2);
- have_xapian_compact or skip 'xapian-compact missing', 2;
+ require_mods('Xapian', 1);
+ have_xapian_compact 1;
is(xsys(qw(git config), "--file=$home/.public-inbox/config",
"publicinbox.$group.indexlevel", 'medium'),
0, 'upgraded indexlevel');
diff --git a/t/xcpdb-reshard.t b/t/xcpdb-reshard.t
index cde9f151..7797aaaf 100644
--- a/t/xcpdb-reshard.t
+++ b/t/xcpdb-reshard.t
@@ -43,7 +43,7 @@ my $XapianDatabase = do {
for my $R (qw(2 4 1 3 3)) {
delete $ibx->{search}; # release old handles
my $cmd = [@xcpdb, "-R$R", $ibx->{inboxdir}];
- push @$cmd, '--compact' if $R == 1 && have_xapian_compact;
+ push @$cmd, '--compact' if $R == 1 && have_xapian_compact(1);
ok(run_script($cmd, $env), "xcpdb -R$R");
my @new_shards = grep(m!/\d+\z!, glob("$ibx->{inboxdir}/xap*/*"));
is(scalar(@new_shards), $R, 'resharded to two shards');
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-09-12 12:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-12 12:25 [PATCH 0/2] test fixes for optional deps Eric Wong
2023-09-12 12:25 ` [PATCH 1/2] tests: favor IO::Socket::IP for IPv6 listeners Eric Wong
2023-09-12 12:25 ` [PATCH 2/2] tests: allow more tests to pass without xapian-compact Eric Wong
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).