]> Sergey Matveev's repositories - public-inbox.git/blobdiff - t/httpd.t
t/common: start_script replaces spawn_listener
[public-inbox.git] / t / httpd.t
index e7527ed64f2ae6815ccc87e2aec8bae5fb219621..ce8063b28672863fa97fa73f52b9f8b1d3f3d75e 100644 (file)
--- a/t/httpd.t
+++ b/t/httpd.t
@@ -21,13 +21,11 @@ my $maindir = "$tmpdir/main.git";
 my $group = 'test-httpd';
 my $addr = $group . '@example.com';
 my $cfgpfx = "publicinbox.$group";
-my $httpd = 'blib/script/public-inbox-httpd';
 my $sock = tcp_server();
-my $pid;
+my $td;
 use_ok 'PublicInbox::Git';
 use_ok 'PublicInbox::Import';
 use_ok 'Email::MIME';
-END { kill 'TERM', $pid if defined $pid };
 {
        local $ENV{HOME} = $home;
        my $cmd = [ '-init', $group, $maindir, 'http://example.com/', $addr ];
@@ -52,8 +50,8 @@ EOF
                $im->done($mime);
        }
        ok($sock, 'sock created');
-       $cmd = [ $httpd, '-W0', "--stdout=$out", "--stderr=$err" ];
-       $pid = spawn_listener(undef, $cmd, [$sock]);
+       $cmd = [ '-httpd', '-W0', "--stdout=$out", "--stderr=$err" ];
+       $td = start_script($cmd, undef, { 3 => $sock });
        my $host = $sock->sockhost;
        my $port = $sock->sockport;
        my $conn = tcp_connect($sock);
@@ -78,9 +76,8 @@ EOF
                        "http://$host:$port/$group", "$tmpdir/dumb.git"),
                0, 'clone successful');
 
-       ok(kill('TERM', $pid), 'killed httpd');
-       $pid = undef;
-       waitpid(-1, 0);
+       ok($td->kill, 'killed httpd');
+       $td->join;
 
        is(system('git', "--git-dir=$tmpdir/clone.git",
                  qw(fsck --no-verbose)), 0,