about summary refs log tree commit homepage
path: root/t
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-12-29 12:51:18 +0000
committerEric Wong <e@80x24.org>2019-12-30 00:06:23 +0000
commit267371b1273b518215939e817e53733584b68af7 (patch)
tree565515b689baf8e7384a384fd114d8d3f44546a2 /t
parent0a65fd278cb5b4e308fc2535753a3f1a5e78cbf4 (diff)
downloadpublic-inbox-267371b1273b518215939e817e53733584b68af7.tar.gz
We can save callers the trouble of {-hold} and {-dev_null}
refs as well as the trouble of calling fileno().
Diffstat (limited to 't')
-rw-r--r--t/git.t2
-rw-r--r--t/httpd-corner.t2
-rw-r--r--t/import.t2
-rw-r--r--t/qspawn.t5
-rw-r--r--t/solver_git.t2
-rw-r--r--t/spawn.t2
6 files changed, 10 insertions, 5 deletions
diff --git a/t/git.t b/t/git.t
index 6cfadd08..89a276bf 100644
--- a/t/git.t
+++ b/t/git.t
@@ -92,7 +92,7 @@ if ('alternates reloaded') {
         my @cmd = ('git', "--git-dir=$alt", qw(hash-object -w --stdin));
         is(system(qw(git init -q --bare), $alt), 0, 'create alt directory');
         open my $fh, '<', "$alt/config" or die "open failed: $!\n";
-        my $rd = popen_rd(\@cmd, {}, { 0 => fileno($fh) } );
+        my $rd = popen_rd(\@cmd, {}, { 0 => $fh } );
         close $fh or die "close failed: $!";
         chomp(my $remote = <$rd>);
         my $gcf = PublicInbox::Git->new($dir);
diff --git a/t/httpd-corner.t b/t/httpd-corner.t
index 4ef1618a..4ed34934 100644
--- a/t/httpd-corner.t
+++ b/t/httpd-corner.t
@@ -266,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') {
diff --git a/t/import.t b/t/import.t
index 3cf7e2d2..cfbe501b 100644
--- a/t/import.t
+++ b/t/import.t
@@ -44,7 +44,7 @@ if ($v2) {
         $in->flush or die "flush failed: $!";
         $in->seek(0, SEEK_SET);
         my $out = tempfile();
-        my $pid = spawn(\@cmd, {}, { 0 => fileno($in), 1 => fileno($out)});
+        my $pid = spawn(\@cmd, {}, { 0 => $in, 1 => $out });
         is(waitpid($pid, 0), $pid, 'waitpid succeeds on hash-object');
         is($?, 0, 'hash-object');
         $out->seek(0, SEEK_SET);
diff --git a/t/qspawn.t b/t/qspawn.t
index 8bc88e0e..ab3764b8 100644
--- a/t/qspawn.t
+++ b/t/qspawn.t
@@ -10,6 +10,11 @@ use_ok 'PublicInbox::Qspawn';
         my $res;
         $qsp->psgi_qx({}, undef, sub { $res = ${$_[0]} });
         is($res, "err\nout\n", 'captured stderr and stdout');
+
+        $res = undef;
+        $qsp = PublicInbox::Qspawn->new($cmd, {}, { 2 => \*STDOUT });
+        $qsp->psgi_qx({}, undef, sub { $res = ${$_[0]} });
+        is($res, "err\nout\n", 'captured stderr and stdout');
 }
 
 sub finish_err ($) {
diff --git a/t/solver_git.t b/t/solver_git.t
index 0c272d77..55746994 100644
--- a/t/solver_git.t
+++ b/t/solver_git.t
@@ -127,7 +127,7 @@ SKIP: {
         while (my ($label, $size) = each %bin) {
                 pipe(my ($rout, $wout)) or die;
                 pipe(my ($rin, $win)) or die;
-                my $rdr = { 0 => fileno($rin), 1 => fileno($wout) };
+                my $rdr = { 0 => $rin, 1 => $wout };
                 my $pid = spawn($cmd , $env, $rdr);
                 $wout = $rin = undef;
                 print { $win } ("\0" x $size) or die;
diff --git a/t/spawn.t b/t/spawn.t
index 2e409157..c31c4f19 100644
--- a/t/spawn.t
+++ b/t/spawn.t
@@ -31,7 +31,7 @@ use PublicInbox::Spawn qw(which spawn popen_rd);
         my ($r, $w);
         pipe $r, $w or die "pipe failed: $!";
         my $pid = spawn(['sh', '-c', 'echo $HELLO'],
-                { 'HELLO' => 'world' }, { 1 => fileno($w) });
+                { 'HELLO' => 'world' }, { 1 => $w });
         close $w or die "close pipe[1] failed: $!";
         is(<$r>, "world\n", 'read stdout of spawned from pipe');
         is(waitpid($pid, 0), $pid, 'waitpid succeeds on spawned process');