about summary refs log tree commit homepage
path: root/lib/PublicInbox/TestCommon.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/PublicInbox/TestCommon.pm')
-rw-r--r--lib/PublicInbox/TestCommon.pm22
1 files changed, 14 insertions, 8 deletions
diff --git a/lib/PublicInbox/TestCommon.pm b/lib/PublicInbox/TestCommon.pm
index 68785969..d6d1e939 100644
--- a/lib/PublicInbox/TestCommon.pm
+++ b/lib/PublicInbox/TestCommon.pm
@@ -195,14 +195,20 @@ sub run_script ($;$$) {
         my $spawn_opt = {};
         for my $fd (0..2) {
                 my $redir = $opt->{$fd};
-                next unless ref($redir);
-                open my $fh, '+>', undef or die "open: $!";
-                $fhref->[$fd] = $fh;
-                $spawn_opt->{$fd} = $fh;
-                next if $fd > 0;
-                $fh->autoflush(1);
-                print $fh $$redir or die "print: $!";
-                seek($fh, 0, SEEK_SET) or die "seek: $!";
+                my $ref = ref($redir);
+                if ($ref eq 'SCALAR') {
+                        open my $fh, '+>', undef or die "open: $!";
+                        $fhref->[$fd] = $fh;
+                        $spawn_opt->{$fd} = $fh;
+                        next if $fd > 0;
+                        $fh->autoflush(1);
+                        print $fh $$redir or die "print: $!";
+                        seek($fh, 0, SEEK_SET) or die "seek: $!";
+                } elsif ($ref eq 'GLOB') {
+                        $spawn_opt->{$fd} = $fhref->[$fd] = $redir;
+                } elsif ($ref) {
+                        die "unable to deal with $ref $redir";
+                }
         }
         if ($run_mode == 0) {
                 # spawn an independent new process, like real-world use cases: