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