require PublicInbox::Spawn;
my $pid = PublicInbox::Spawn::spawn($cmd, undef, { 1 => 2 });
wait_for_tail($pid, scalar @_);
- PublicInboxTestProcess->new($pid, \&wait_for_tail);
+ require PublicInbox::AutoReap;
+ PublicInbox::AutoReap->new($pid, \&wait_for_tail);
}
sub start_script {
die "FAIL: ",join(' ', $key, @argv), ": $!\n";
}
}
- my $td = PublicInboxTestProcess->new($pid);
+ require PublicInbox::AutoReap;
+ my $td = PublicInbox::AutoReap->new($pid);
$td->{-extra} = $tail;
$td;
}
require_git(2.6, 1) or skip('git 2.6+ required for lei test', 2);
my $mods = $test_opt->{mods} // [ 'lei' ];
require_mods(@$mods, 2);
+
+ # set PERL_INLINE_DIRECTORY before clobbering XDG_CACHE_HOME
+ require PublicInbox::Spawn;
require PublicInbox::Config;
require File::Path;
+
local %ENV = %ENV;
delete $ENV{XDG_DATA_HOME};
delete $ENV{XDG_CONFIG_HOME};
+ delete $ENV{XDG_CACHE_HOME};
$ENV{GIT_COMMITTER_EMAIL} = 'lei@example.com';
$ENV{GIT_COMMITTER_NAME} = 'lei user';
my (undef, $fn, $lineno) = caller(0);
my $t = "$fn:$lineno";
- require PublicInbox::Spawn;
state $lei_daemon = PublicInbox::Spawn->can('send_cmd4') ||
eval { require Socket::MsgHdr; 1 };
unless ($lei_daemon) {
my %opt = @_;
require PublicInbox::Lock;
require PublicInbox::InboxWritable;
+ require PublicInbox::Import;
my ($base) = ($0 =~ m!\b([^/]+)\.[^\.]+\z!);
- my $dir = "t/data-gen/$base.$ident";
+ my ($db) = (PublicInbox::Import::default_branch() =~ m!([^/]+)\z!);
+ my $dir = "t/data-gen/$base.$ident-$db";
my $new = !-d $dir;
if ($new) {
mkdir $dir; # may race
};
-package PublicInboxTestProcess;
-use strict;
-
-# prevent new threads from inheriting these objects
-sub CLONE_SKIP { 1 }
-
-sub new {
- my ($cls, $pid, $cb) = @_;
- bless { pid => $pid, cb => $cb, owner => $$ }, $cls;
-}
-
-sub kill {
- my ($self, $sig) = @_;
- CORE::kill($sig // 'TERM', $self->{pid});
-}
-
-sub join {
- my ($self, $sig) = @_;
- my $pid = delete $self->{pid} or return;
- $self->{cb}->() if defined $self->{cb};
- CORE::kill($sig, $pid) if defined $sig;
- my $ret = waitpid($pid, 0) // die "waitpid($pid): $!";
- $ret == $pid or die "waitpid($pid) != $ret";
-}
-
-sub DESTROY {
- my ($self) = @_;
- return if $self->{owner} != $$;
- $self->join('TERM');
-}
-
package PublicInbox::TestCommon::InboxWakeup;
use strict;
sub on_inbox_unlock { ${$_[0]}->($_[1]) }