about summary refs log tree commit homepage
path: root/lib/PublicInbox/TestCommon.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2024-04-25 21:31:46 +0000
committerEric Wong <e@80x24.org>2024-04-28 17:05:29 +0000
commitcccff5cbaf8e9800dbcb67dd497586bdb0a8521e (patch)
treeda3292d5a6d59509fbac435479620fd44d2aee1b /lib/PublicInbox/TestCommon.pm
parentbad65d1197b8ee45a28e8bb7c894912145012fb5 (diff)
downloadpublic-inbox-cccff5cbaf8e9800dbcb67dd497586bdb0a8521e.tar.gz
Xapian helper processes are disabled by default once again.
However, they can be enabled via the new `-X INTEGER' parameter.
One big positive is the Xapian helpers being spawned by the
top-level daemon means they can be shared freely across all
workers for improved load balancing and memory reduction.
Diffstat (limited to 'lib/PublicInbox/TestCommon.pm')
-rw-r--r--lib/PublicInbox/TestCommon.pm9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/PublicInbox/TestCommon.pm b/lib/PublicInbox/TestCommon.pm
index a7ec9b5b..b8b7b827 100644
--- a/lib/PublicInbox/TestCommon.pm
+++ b/lib/PublicInbox/TestCommon.pm
@@ -17,6 +17,7 @@ my $lei_loud = $ENV{TEST_LEI_ERR_LOUD};
 our $tail_cmd = $ENV{TAIL};
 our ($lei_opt, $lei_out, $lei_err);
 use autodie qw(chdir close fcntl mkdir open opendir seek unlink);
+$ENV{XDG_CACHE_HOME} //= "$ENV{HOME}/.cache"; # reuse C++ xap_helper builds
 
 $_ = File::Spec->rel2abs($_) for (grep(!m!^/!, @INC));
 
@@ -565,6 +566,9 @@ sub start_script {
         my $run_mode = $ENV{TEST_RUN_MODE} // $opt->{run_mode} // 2;
         my $sub = $run_mode == 0 ? undef : key2sub($key);
         my $tail;
+        my $xh = $ENV{TEST_DAEMON_XH};
+        $xh && $key =~ /-(?:imapd|netd|httpd|pop3d|nntpd)\z/ and
+                push @argv, split(/\s+/, $xh);
         if ($tail_cmd) {
                 my @paths;
                 for (@argv) {
@@ -720,7 +724,10 @@ SKIP: {
         require PublicInbox::Spawn;
         require PublicInbox::Config;
         require File::Path;
-
+        eval { # use XDG_CACHE_HOME, first:
+                require PublicInbox::XapHelperCxx;
+                PublicInbox::XapHelperCxx::build();
+        };
         local %ENV = %ENV;
         delete $ENV{XDG_DATA_HOME};
         delete $ENV{XDG_CONFIG_HOME};