line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Plugin::IOMuxer; |
2
|
2
|
|
|
2
|
|
146868
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
48
|
|
3
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
61
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.000007'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
340
|
use Test2::Plugin::OpenFixPerlIO; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
37
|
|
9
|
2
|
|
|
2
|
|
673
|
use Test2::Plugin::IOMuxer::Layer; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
55
|
|
10
|
2
|
|
|
2
|
|
12
|
use IO::Handle; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
66
|
|
11
|
|
|
|
|
|
|
|
12
|
2
|
|
|
|
|
88
|
use Test2::API qw{ |
13
|
|
|
|
|
|
|
test2_add_callback_post_load |
14
|
|
|
|
|
|
|
test2_stack |
15
|
2
|
|
|
2
|
|
10
|
}; |
|
2
|
|
|
|
|
5
|
|
16
|
|
|
|
|
|
|
|
17
|
2
|
|
|
2
|
|
10
|
use Carp qw/confess/; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
151
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our @EXPORT_OK = qw/mux_handle/; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub import { |
22
|
1
|
|
|
1
|
|
7658
|
my $class = shift; |
23
|
1
|
|
|
|
|
6
|
my ($in) = @_; |
24
|
|
|
|
|
|
|
|
25
|
1
|
50
|
|
|
|
7
|
return unless $in; |
26
|
1
|
50
|
|
|
|
7
|
if ($in eq 'mux_handle') { |
27
|
1
|
|
|
|
|
4
|
my $caller = caller; |
28
|
2
|
|
|
2
|
|
12
|
no strict 'refs'; |
|
2
|
|
|
|
|
62
|
|
|
2
|
|
|
|
|
731
|
|
29
|
1
|
|
|
|
|
5
|
*{"$caller\::mux_handle"} = \&mux_handle; |
|
1
|
|
|
|
|
9
|
|
30
|
1
|
|
|
|
|
6
|
return 1; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
0
|
my $file = $in; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
test2_add_callback_post_load(sub { |
36
|
0
|
|
|
0
|
|
0
|
my @handles; |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
0
|
my $hub = test2_stack()->top; |
39
|
0
|
0
|
|
|
|
0
|
my $formatter = $hub->format or next; |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
0
|
for my $meth (qw/handles io/) { |
42
|
0
|
0
|
|
|
|
0
|
if ($formatter->can($meth)) { |
43
|
0
|
|
|
|
|
0
|
my @list = $formatter->$meth; |
44
|
0
|
0
|
0
|
|
|
0
|
@list = @{$list[0]} if @list == 1 && ref($list[0]) eq 'ARRAY'; |
|
0
|
|
|
|
|
0
|
|
45
|
0
|
|
|
|
|
0
|
push @handles => @list; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
0
|
mux_handle($_, $file) for @handles; |
50
|
0
|
|
|
|
|
0
|
}); |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
0
|
mux_handle(\*STDOUT, $file); |
53
|
0
|
|
|
|
|
0
|
mux_handle(\*STDERR, $file); |
54
|
|
|
|
|
|
|
|
55
|
0
|
0
|
|
|
|
0
|
mux_handle(Test2::API::test2_stdout(), $file) if Test2::API->can('test2_stdout'); |
56
|
0
|
0
|
|
|
|
0
|
mux_handle(Test2::API::test2_stderr(), $file) if Test2::API->can('test2_stderr'); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub mux_handle(*$) { |
60
|
1
|
|
|
1
|
0
|
1506
|
my ($fh, $file) = @_; |
61
|
|
|
|
|
|
|
|
62
|
1
|
|
|
|
|
5
|
my $fileno = fileno($_[0]); |
63
|
1
|
50
|
|
|
|
6
|
die "Could not get fileno for handle" unless defined $fileno; |
64
|
|
|
|
|
|
|
|
65
|
1
|
50
|
|
|
|
7
|
if (my $set = $Test2::Plugin::IOMuxer::Layer::MUXED{$fileno}) { |
66
|
0
|
0
|
|
|
|
0
|
return if $set eq $file; |
67
|
0
|
|
|
|
|
0
|
confess "Handle (fileno: $fileno) already muxed to '$set', cannot mux to '$file'"; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
1
|
|
|
|
|
5
|
$Test2::Plugin::IOMuxer::Layer::MUXED{$fileno} = $file; |
71
|
|
|
|
|
|
|
|
72
|
1
|
50
|
|
|
|
5
|
unless($Test2::Plugin::IOMuxer::Layer::MUX_FILES{$file}) { |
73
|
1
|
50
|
|
|
|
8
|
open(my $mh, '>', $file) or die "Could not open mux file '$file': $!"; |
74
|
1
|
|
|
|
|
18
|
$mh->autoflush(1); |
75
|
1
|
|
|
|
|
84
|
$Test2::Plugin::IOMuxer::Layer::MUX_FILES{$file} = $mh; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
1
|
|
|
1
|
|
9
|
binmode($_[0], ":via(Test2::Plugin::IOMuxer::Layer)"); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
11
|
|
|
1
|
|
|
|
|
31
|
|
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
1; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
__END__ |