about summary refs log tree commit homepage
path: root/t/solver_git.t
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-01-11 22:35:03 +0000
committerEric Wong <e@yhbt.net>2020-01-13 04:36:48 +0000
commitc5c709dcef1b5904467ff2aea3943f00a891dade (patch)
treee02f9d1e216c3beacc51d2ca43e5333c4dbd9f4f /t/solver_git.t
parenta208d17ed99577faa8b52d46107fad5516b346b0 (diff)
downloadpublic-inbox-c5c709dcef1b5904467ff2aea3943f00a891dade.tar.gz
popen_rd accepts arbitrary redirects, so we can reuse its
code to setup the pipe end we want to read, saving each
caller a few lines of code compared to calling pipe+spawn.
Diffstat (limited to 't/solver_git.t')
-rw-r--r--t/solver_git.t9
1 files changed, 4 insertions, 5 deletions
diff --git a/t/solver_git.t b/t/solver_git.t
index 98317fae..92402c3a 100644
--- a/t/solver_git.t
+++ b/t/solver_git.t
@@ -6,7 +6,7 @@ use Test::More;
 use Cwd qw(abs_path);
 use PublicInbox::TestCommon;
 require_git(2.6);
-use PublicInbox::Spawn qw(spawn);
+use PublicInbox::Spawn qw(popen_rd);
 require_mods(qw(DBD::SQLite Search::Xapian Plack::Util));
 chomp(my $git_dir = `git rev-parse --git-dir 2>/dev/null`);
 plan skip_all => "$0 must be run from a git working tree" if $?;
@@ -120,14 +120,13 @@ SKIP: {
         my $cmd = [ qw(git hash-object -w --stdin) ];
         my $env = { GIT_DIR => $binfoo };
         while (my ($label, $size) = each %bin) {
-                pipe(my ($rout, $wout)) or die;
                 pipe(my ($rin, $win)) or die;
-                my $rdr = { 0 => $rin, 1 => $wout };
-                my $pid = spawn($cmd , $env, $rdr);
-                $wout = $rin = undef;
+                my $rout = popen_rd($cmd , $env, { 0 => $rin });
+                $rin = undef;
                 print { $win } ("\0" x $size) or die;
                 close $win or die;
                 chomp($oid{$label} = <$rout>);
+                close $rout or die "$?";
         }
 
         # ensure the PSGI frontend (ViewVCS) works: