line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Stream::Plugin::Capture; |
2
|
3
|
|
|
3
|
|
16
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
73
|
|
3
|
3
|
|
|
3
|
|
15
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
78
|
|
4
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
14
|
use Test::Stream::Util qw/try/; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
23
|
|
6
|
3
|
|
|
3
|
|
14
|
use Carp qw/croak/; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
156
|
|
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
21
|
use Test::Stream::Exporter; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
18
|
|
9
|
|
|
|
|
|
|
default_exports qw/capture/; |
10
|
3
|
|
|
3
|
|
14
|
no Test::Stream::Exporter; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
17
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub capture(&) { |
13
|
15
|
|
|
15
|
1
|
2258
|
my $code = shift; |
14
|
|
|
|
|
|
|
|
15
|
15
|
|
|
|
|
40
|
my ($err, $out) = ("", ""); |
16
|
|
|
|
|
|
|
|
17
|
15
|
|
|
|
|
26
|
my ($ok, $e); |
18
|
|
|
|
|
|
|
{ |
19
|
15
|
|
|
|
|
22
|
local *STDOUT; |
|
15
|
|
|
|
|
47
|
|
20
|
15
|
|
|
|
|
39
|
local *STDERR; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
($ok, $e) = try { |
23
|
3
|
50
|
|
3
|
|
3209
|
open(STDOUT, '>', \$out) or die "Failed to open a temporary STDOUT: $!"; |
|
3
|
|
|
15
|
|
40
|
|
|
3
|
|
|
|
|
18
|
|
|
15
|
|
|
|
|
261
|
|
24
|
15
|
50
|
|
|
|
3463
|
open(STDERR, '>', \$err) or die "Failed to open a temporary STDERR: $!"; |
25
|
|
|
|
|
|
|
|
26
|
15
|
|
|
|
|
51
|
$code->(); |
27
|
15
|
|
|
|
|
104
|
}; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
15
|
100
|
|
|
|
115
|
die $e unless $ok; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
return { |
33
|
14
|
|
|
|
|
99
|
STDOUT => $out, |
34
|
|
|
|
|
|
|
STDERR => $err, |
35
|
|
|
|
|
|
|
}; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
1; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
__END__ |