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