use
Utils
qw/next_fd sig_num/
;
plan
tests
=> 5;
local
$ENV
{PERL_CAPTURE_TINY_TIMEOUT} = 0;
my
$builder
= Test::More->builder;
binmode
(
$builder
->failure_output,
':utf8'
)
if
$] >= 5.008;
my
$fd
= next_fd;
$@ =
"initial error"
;
my
(
$out
,
$err
) = capture {
print
"foo\n"
};
is( $@,
'initial error'
,
"Initial \$\@ not lost during capture"
);
(
$out
,
$err
) = capture {
eval
{
tee {
local
$|=1;
print
STDOUT
"foo\n"
;
print
STDERR
"bar\n"
;
die
"Fatal error in capture\n"
;
}
};
};
my
$error
= $@;
is(
$error
,
"Fatal error in capture\n"
,
"\$\@ preserved after capture"
);
is(
$out
,
"foo\n"
,
"STDOUT still captured"
);
is(
$err
,
"bar\n"
,
"STDOUT still captured"
);
is( next_fd,
$fd
,
"no file descriptors leaked"
);
exit
0;