]> Sergey Matveev's repositories - public-inbox.git/blobdiff - t/httpd-corner.t
ds|http|nntp: simplify {wbuf} population
[public-inbox.git] / t / httpd-corner.t
index eca77d7fc6dd0f9e600f736d1ef6e534400f67a5..4ed34934e500649470ba411629764afbe286f044 100644 (file)
@@ -7,21 +7,15 @@ use warnings;
 use Test::More;
 use Time::HiRes qw(gettimeofday tv_interval);
 use PublicInbox::Spawn qw(which spawn);
-
-foreach my $mod (qw(Plack::Util Plack::Builder HTTP::Date HTTP::Status)) {
-       eval "require $mod";
-       plan skip_all => "$mod missing for httpd-corner.t" if $@;
-}
-
+use PublicInbox::TestCommon;
+require_mods(qw(Plack::Util Plack::Builder HTTP::Date HTTP::Status));
 use Digest::SHA qw(sha1_hex);
-use File::Temp qw/tempdir/;
 use IO::Socket;
 use IO::Socket::UNIX;
 use Fcntl qw(:seek);
 use Socket qw(IPPROTO_TCP TCP_NODELAY SOL_SOCKET);
 use POSIX qw(mkfifo);
-require './t/common.perl';
-my $tmpdir = tempdir('httpd-corner-XXXXXX', TMPDIR => 1, CLEANUP => 1);
+my ($tmpdir, $for_destroy) = tmpdir();
 my $fifo = "$tmpdir/fifo";
 ok(defined mkfifo($fifo, 0777), 'created FIFO');
 my $err = "$tmpdir/stderr.log";
@@ -272,7 +266,7 @@ SKIP: {
        my $cmd = [qw(curl --tcp-nodelay --no-buffer -T- -HExpect: -sS), $url];
        open my $cout, '+>', undef or die;
        open my $cerr, '>', undef or die;
-       my $rdr = { 0 => fileno($r), 1 => fileno($cout), 2 => fileno($cerr) };
+       my $rdr = { 0 => $r, 1 => $cout, 2 => $cerr };
        my $pid = spawn($cmd, undef, $rdr);
        close $r or die "close read pipe: $!";
        foreach my $c ('a'..'z') {
@@ -554,16 +548,16 @@ SKIP: {
        # filter out pipes inherited from the parent
        my @this = `lsof -p $$`;
        my $bad;
-       sub extract_inodes {
+       my $extract_inodes = sub {
                map {;
                        my @f = split(' ', $_);
                        my $inode = $f[-2];
                        $bad = $_ if $inode !~ /\A[0-9]+\z/;
                        $inode => 1;
                } grep (/\bpipe\b/, @_);
-       }
-       my %child = extract_inodes(@lsof);
-       my %parent = extract_inodes(@this);
+       };
+       my %child = $extract_inodes->(@lsof);
+       my %parent = $extract_inodes->(@this);
        skip("inode not in expected format: $bad", 1) if defined($bad);
        delete @child{(keys %parent)};
        is_deeply([], [keys %child], 'no extra pipes with -W0');