]> Sergey Matveev's repositories - public-inbox.git/commitdiff
test_common: don't attempt to seek on pipes and terminals
authorEric Wong <e@80x24.org>
Sat, 24 Apr 2021 20:09:36 +0000 (20:09 +0000)
committerEric Wong <e@80x24.org>
Sat, 24 Apr 2021 20:10:17 +0000 (16:10 -0400)
This allows proper error reporting on daemon failure
when using "check-run".

lib/PublicInbox/TestCommon.pm
t/run.perl

index 49cecacdd2e933666ffe419de8ed2ca6fd206f64..092568528dc6879a5852a37e0c48f42ca415c5de 100644 (file)
@@ -321,6 +321,7 @@ sub run_script ($;$$) {
        # slurp the redirects back into user-supplied strings
        for my $fd (1..2) {
                my $fh = $fhref->[$fd] or next;
+               next unless -f $fh;
                seek($fh, 0, SEEK_SET) or die "seek: $!";
                my $redir = $opt->{$fd};
                local $/;
index 1fb1c5f0b661c8ff1aaece7fdef105966050396a..f4e235b7fd3a800fb8c1cc4ed3c1fef81e87da11 100755 (executable)
@@ -225,6 +225,6 @@ for (my $i = $repeat; $i != 0; $i--) {
 
 print $OLDOUT "1..".($repeat * scalar(@tests))."\n" if $repeat >= 0;
 if ($lei_env && $$ == $owner_pid) {
-       my $opt = {}; # 1 => $OLDOUT, 2 => $OLDERR };
+       my $opt = { 1 => $OLDOUT, 2 => $OLDERR };
        run_script([qw(lei daemon-kill)], $lei_env, $opt);
 }