use strict;
use warnings;
use Test::More;
-use File::Temp qw/tempdir/;
use POSIX qw(setsid);
+require './t/common.perl';
my $git_dir = $ENV{GIANT_GIT_DIR};
plan 'skip_all' => 'GIANT_GIT_DIR not defined' unless $git_dir;
eval "require $mod";
plan skip_all => "$mod missing for git-http-backend.t" if $@;
}
-require './t/common.perl';
my $psgi = "./t/git-http-backend.psgi";
-my $tmpdir = tempdir('pi-git-http-backend-XXXXXX', TMPDIR => 1, CLEANUP => 1);
+my ($tmpdir, $for_destroy) = tmpdir();
my $err = "$tmpdir/stderr.log";
my $out = "$tmpdir/stdout.log";
-my $httpd = 'blib/script/public-inbox-httpd';
my $sock = tcp_server();
my $host = $sock->sockhost;
my $port = $sock->sockport;
-my $pid;
-END { kill 'TERM', $pid if defined $pid };
+my $td;
my $get_maxrss = sub {
my $http = Net::HTTP->new(Host => "$host:$port");
{
ok($sock, 'sock created');
- my $cmd = [ $httpd, '-W0', "--stdout=$out", "--stderr=$err", $psgi ];
- ok(defined($pid = spawn_listener(undef, $cmd, [$sock])),
- 'forked httpd process successfully');
+ my $cmd = [ '-httpd', '-W0', "--stdout=$out", "--stderr=$err", $psgi ];
+ $td = start_script($cmd, undef, { 3 => $sock });
}
my $mem_a = $get_maxrss->();
}
{
- ok(kill('TERM', $pid), 'killed httpd');
- $pid = undef;
- waitpid(-1, 0);
+ ok($td->kill, 'killed httpd');
+ $td->join;
}
done_testing();