about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-09-14 06:29:26 +0000
committerEric Wong <e@80x24.org>2020-09-14 21:29:56 +0000
commit23eab6127c62d0228a0cfcec78a267fe5e7011c7 (patch)
treeb0a0d8e3cfe2a279e81fd775bf85838b8c9dfd53
parentee8cadb3a71ab4c951642a96ba123688244de720 (diff)
downloadpublic-inbox-23eab6127c62d0228a0cfcec78a267fe5e7011c7.tar.gz
We may need to test against development versions of Xapian,
which may rely on setting `XAPIAN_COMPACT=xapian-compact-1.5'.
Ensure it's possible to do that.

And add a missing check in t/xcpdb-reshard.t, too.
-rw-r--r--lib/PublicInbox/TestCommon.pm9
-rw-r--r--t/convert-compact.t3
-rw-r--r--t/indexlevels-mirror.t6
-rw-r--r--t/nntpd.t2
-rw-r--r--t/xcpdb-reshard.t2
5 files changed, 13 insertions, 9 deletions
diff --git a/lib/PublicInbox/TestCommon.pm b/lib/PublicInbox/TestCommon.pm
index 42819179..299b9c6a 100644
--- a/lib/PublicInbox/TestCommon.pm
+++ b/lib/PublicInbox/TestCommon.pm
@@ -10,7 +10,8 @@ use Fcntl qw(FD_CLOEXEC F_SETFD F_GETFD :seek);
 use POSIX qw(dup2);
 use IO::Socket::INET;
 our @EXPORT = qw(tmpdir tcp_server tcp_connect require_git require_mods
-        run_script start_script key2sub xsys xqx eml_load tick);
+        run_script start_script key2sub xsys xqx eml_load tick
+        have_xapian_compact);
 
 sub eml_load ($) {
         my ($path, $cb) = @_;
@@ -397,6 +398,12 @@ sub start_script {
         PublicInboxTestProcess->new($pid, $tail_pid);
 }
 
+sub have_xapian_compact () {
+        require PublicInbox::Spawn;
+        # $ENV{XAPIAN_COMPACT} is used by PublicInbox/Xapcmd.pm, too
+        PublicInbox::Spawn::which($ENV{XAPIAN_COMPACT} || 'xapian-compact');
+}
+
 package PublicInboxTestProcess;
 use strict;
 
diff --git a/t/convert-compact.t b/t/convert-compact.t
index 575262e8..e479476d 100644
--- a/t/convert-compact.t
+++ b/t/convert-compact.t
@@ -4,11 +4,10 @@ use strict;
 use warnings;
 use Test::More;
 use PublicInbox::Eml;
-use PublicInbox::Spawn qw(which);
 use PublicInbox::TestCommon;
 require_git(2.6);
 require_mods(qw(DBD::SQLite Search::Xapian));
-which('xapian-compact') or
+have_xapian_compact or
         plan skip_all => 'xapian-compact missing for '.__FILE__;
 
 use_ok 'PublicInbox::V2Writable';
diff --git a/t/indexlevels-mirror.t b/t/indexlevels-mirror.t
index 291e0d2f..b12bd3cb 100644
--- a/t/indexlevels-mirror.t
+++ b/t/indexlevels-mirror.t
@@ -6,13 +6,11 @@ use Test::More;
 use PublicInbox::Eml;
 use PublicInbox::Inbox;
 use PublicInbox::InboxWritable;
-use PublicInbox::Spawn qw(which);
 require PublicInbox::Admin;
 use PublicInbox::TestCommon;
 my $PI_TEST_VERSION = $ENV{PI_TEST_VERSION} || 2;
 require_git('2.6') if $PI_TEST_VERSION == 2;
 require_mods(qw(DBD::SQLite));
-my $have_xapian_compact = which($ENV{XAPIAN_COMPACT} || 'xapian-compact');
 
 my $mime = PublicInbox::Eml->new(<<'EOF');
 From: a@example.com
@@ -43,7 +41,7 @@ my $import_index_incremental = sub {
 
         # index master (required for v1)
         my @cmd = (qw(-index -j0), $ibx->{inboxdir}, "-L$level");
-        push @cmd, '-c' if $have_xapian_compact;
+        push @cmd, '-c' if have_xapian_compact;
         ok(run_script(\@cmd, undef, { 2 => \$err }), 'index master');
         my $ro_master = PublicInbox::Inbox->new({
                 inboxdir => $ibx->{inboxdir},
@@ -164,7 +162,7 @@ my $import_index_incremental = sub {
            'indexlevel detectable by Admin '.$v.$level);
 
         SKIP: {
-                skip 'xapian-compact missing', 1 if !$have_xapian_compact;
+                skip 'xapian-compact missing', 1 if have_xapian_compact;
                 my $cmd = [ qw(-compact), $mirror ];
                 ok(run_script($cmd, undef, { 2 => \$err}), "compact $level");
         }
diff --git a/t/nntpd.t b/t/nntpd.t
index 14db1a93..c7a7ee6b 100644
--- a/t/nntpd.t
+++ b/t/nntpd.t
@@ -349,7 +349,7 @@ Date: Fri, 02 Oct 1993 00:00:00 +0000
         # -compact requires Xapian
         SKIP: {
                 require_mods('Search::Xapian', 2);
-                which('xapian-compact') or skip 'xapian-compact missing', 2;
+                have_xapian_compact or skip 'xapian-compact missing', 2;
                 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 c1af5d9a..ede736c1 100644
--- a/t/xcpdb-reshard.t
+++ b/t/xcpdb-reshard.t
@@ -45,7 +45,7 @@ my %nums = map {; "$_->{num}" => 1 } @$orig;
 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;
+        push @$cmd, '--compact' if $R == 1 && have_xapian_compact;
         ok(run_script($cmd), "xcpdb -R$R");
         my @new_shards = grep(m!/\d+\z!, glob("$ibx->{inboxdir}/xap*/*"));
         is(scalar(@new_shards), $R, 'resharded to two shards');