]> Sergey Matveev's repositories - public-inbox.git/blobdiff - t/perf-nntpd.t
t/common: start_script replaces spawn_listener
[public-inbox.git] / t / perf-nntpd.t
index 7abf2249ef32386ad7677fff22272b2e417d216e..c7d2eaffe9b5b1a787fe38c314fd569c1f69dd15 100644 (file)
@@ -10,18 +10,9 @@ use Net::NNTP;
 my $pi_dir = $ENV{GIANT_PI_DIR};
 plan skip_all => "GIANT_PI_DIR not defined for $0" unless $pi_dir;
 eval { require PublicInbox::Search };
-my ($host_port, $group, %opts, $s, $pid);
+my ($host_port, $group, %opts, $s, $td);
 require './t/common.perl';
 
-END {
-       if ($s) {
-               $s->print("QUIT\r\n");
-               $s->getline;
-               $s = undef;
-       }
-       kill 'TERM', $pid if defined $pid;
-};
-
 if (($ENV{NNTP_TEST_URL} || '') =~ m!\Anntp://([^/]+)/([^/]+)\z!) {
        ($host_port, $group) = ($1, $2);
        $host_port .= ":119" unless index($host_port, ':') > 0;
@@ -29,7 +20,6 @@ if (($ENV{NNTP_TEST_URL} || '') =~ m!\Anntp://([^/]+)/([^/]+)\z!) {
        $group = 'inbox.test.perf.nntpd';
        my $ibx = { inboxdir => $pi_dir, newsgroup => $group };
        $ibx = PublicInbox::Inbox->new($ibx);
-       my $nntpd = 'blib/script/public-inbox-nntpd';
        my $tmpdir = tempdir('perf-nntpd-XXXXXX', TMPDIR => 1, CLEANUP => 1);
 
        my $pi_config = "$tmpdir/config";
@@ -46,8 +36,8 @@ if (($ENV{NNTP_TEST_URL} || '') =~ m!\Anntp://([^/]+)/([^/]+)\z!) {
 
        my $sock = tcp_server();
        ok($sock, 'sock created');
-       my $cmd = [ $nntpd, '-W0' ];
-       $pid = spawn_listener({ PI_CONFIG => $pi_config }, $cmd, [$sock]);
+       my $cmd = [ '-nntpd', '-W0' ];
+       $td = start_script($cmd, { PI_CONFIG => $pi_config }, { 3 => $sock });
        $host_port = $sock->sockhost . ':' . $sock->sockport;
 }
 %opts = (
@@ -110,6 +100,12 @@ $t = timeit(1, sub {
 });
 diag 'newnews took: ' . timestr($t) . " for $n";
 
+if ($s) {
+       $s->print("QUIT\r\n");
+       $s->getline;
+}
+
+
 done_testing();
 
 1;