From c5c709dcef1b5904467ff2aea3943f00a891dade Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 11 Jan 2020 22:35:03 +0000 Subject: use popen_rd for bidirectional pipes 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. --- t/solver_git.t | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 't') 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: -- cgit v1.2.3-24-ge0c7