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-26 11:29:43 +0000
committerEric Wong <e@80x24.org>2024-04-28 17:05:32 +0000
commitc807cdd1c2e85237e769532a36819888ca97f8b1 (patch)
tree5832f3904e63020b4c430538fd3abfa2dd4f3825 /lib/PublicInbox/TestCommon.pm
parent5f4c4163ad8d8045dbcfddaeddfdb986a79d4969 (diff)
downloadpublic-inbox-c807cdd1c2e85237e769532a36819888ca97f8b1.tar.gz
When read-only daemons reopen log files via SIGUSR1, be sure to
propagate it to Xapian helper processes to ensure old log files
can be closed and archived.
Diffstat (limited to 'lib/PublicInbox/TestCommon.pm')
-rw-r--r--lib/PublicInbox/TestCommon.pm11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/PublicInbox/TestCommon.pm b/lib/PublicInbox/TestCommon.pm
index 708fa698..aeff5d1d 100644
--- a/lib/PublicInbox/TestCommon.pm
+++ b/lib/PublicInbox/TestCommon.pm
@@ -20,7 +20,7 @@ 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));
-
+our $CURRENT_DAEMON;
 BEGIN {
         @EXPORT = qw(tmpdir tcp_server tcp_connect require_git require_mods
                 run_script start_script key2sub xsys xsys_e xqx eml_load tick
@@ -566,9 +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);
+        my @xh = split(/\s+/, $ENV{TEST_DAEMON_XH} // '');
+        @xh = () if $key !~ /-(?:imapd|netd|httpd|pop3d|nntpd)\z/;
+        push @argv, @xh;
         if ($tail_cmd) {
                 my @paths;
                 for (@argv) {
@@ -616,7 +616,7 @@ sub start_script {
                         $ENV{LISTEN_FDS} = $fds;
                 }
                 if ($opt->{-C}) { chdir($opt->{-C}) }
-                $0 = join(' ', @$cmd);
+                $0 = join(' ', @$cmd, @xh);
                 local @SIG{keys %SIG} = map { undef } values %SIG;
                 local $SIG{FPE} = 'IGNORE'; # Perl default
                 undef $tmp_mask;
@@ -952,6 +952,7 @@ sub test_httpd ($$;$$) {
                 local $ENV{PLACK_TEST_EXTERNALSERVER_URI} = "http://$h:$p";
                 my $ua = LWP::UserAgent->new;
                 $ua->max_redirect(0);
+                local $CURRENT_DAEMON = $td;
                 Plack::Test::ExternalServer::test_psgi(client => $client,
                                                         ua => $ua);
                 $cb->() if $cb;