mirror of
https://codeberg.org/h3xx/simplify_static_dir
synced 2024-08-14 23:57:24 +00:00
CI: Improve method of capturing output
This commit is contained in:
parent
d13f8ff83c
commit
76da187807
1 changed files with 8 additions and 7 deletions
|
@ -12,6 +12,8 @@ use File::Basename qw/
|
|||
dirname
|
||||
/;
|
||||
require File::Temp;
|
||||
use IPC::Open3 qw/ open3 /;
|
||||
use Symbol qw/ gensym /;
|
||||
|
||||
use Exporter;
|
||||
use parent 'Exporter';
|
||||
|
@ -102,7 +104,6 @@ sub run_script_capture {
|
|||
my @args = @_;
|
||||
my @cmd = (SCRIPT, @args);
|
||||
|
||||
use IPC::Open3 qw/ open3 /;
|
||||
my $stderr = File::Temp->new(
|
||||
TMPDIR => 1,
|
||||
CLEANUP => 1,
|
||||
|
@ -112,20 +113,20 @@ sub run_script_capture {
|
|||
CLEANUP => 1,
|
||||
);
|
||||
my $in = '';
|
||||
local *CATCHOUT = $stdout;
|
||||
local *CATCHERR = $stderr;
|
||||
my $child_out = gensym();
|
||||
my $child_err = gensym();
|
||||
print STDERR "+ @cmd\n";
|
||||
my $pid = open3 $in, '>&CATCHOUT', '>&CATCHERR', @cmd;
|
||||
my $pid = open3 $in, $child_out, $child_err, @cmd;
|
||||
waitpid $pid, 0;
|
||||
foreach my $handle (\*CATCHOUT, \*CATCHERR) {
|
||||
foreach my $handle ($child_out, $child_err) {
|
||||
seek $handle, 0, 0;
|
||||
}
|
||||
|
||||
local $/;
|
||||
return (
|
||||
$?,
|
||||
scalar <CATCHOUT>, # slurp!
|
||||
scalar <CATCHERR>, # slurp!
|
||||
scalar <$child_out>, # slurp!
|
||||
scalar <$child_err>, # slurp!
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue