line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Plugin::IOEvents::Base; |
2
|
5
|
|
|
5
|
|
164506
|
use strict; |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
137
|
|
3
|
5
|
|
|
5
|
|
29
|
use warnings; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
196
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.000009'; |
6
|
|
|
|
|
|
|
|
7
|
5
|
|
|
5
|
|
1172
|
use Test2::Plugin::OpenFixPerlIO; |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
122
|
|
8
|
5
|
|
|
5
|
|
2032
|
use IO::Handle; |
|
5
|
|
|
|
|
21374
|
|
|
5
|
|
|
|
|
1649
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
0
|
6
|
sub diagnostics { 0 } |
11
|
1
|
|
|
1
|
0
|
8
|
sub stream_name { 'UNKNOWN' } |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub PUSHED { |
14
|
5
|
|
|
5
|
0
|
5620
|
my ($class, $mode, $handle) = @_; |
15
|
5
|
|
|
|
|
55
|
$handle->autoflush(1); |
16
|
5
|
|
|
|
|
362
|
bless {}, $class; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub FLUSH { |
20
|
5
|
|
|
5
|
0
|
382
|
my $self = shift; |
21
|
5
|
|
|
|
|
15
|
my ($handle) = @_; |
22
|
5
|
|
|
|
|
118
|
$handle->flush; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
my $LOADED = 0; |
26
|
|
|
|
|
|
|
sub WRITE { |
27
|
9
|
|
|
9
|
|
16482
|
my ($self, $buffer, $handle) = @_; |
28
|
|
|
|
|
|
|
|
29
|
9
|
|
66
|
|
|
83
|
$LOADED ||= $INC{'Test2/API.pm'} && Test2::API::test2_init_done(); |
|
|
|
100
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
9
|
|
|
|
|
125
|
my $caller = caller; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# Test2::API not loaded (?) |
34
|
9
|
50
|
66
|
|
|
197
|
if ($self->{no_event} || !$LOADED || $caller->isa('Test2::Formatter') || $caller->isa('Test2::Plugin::IOMuxer::Layer')) { |
|
|
|
66
|
|
|
|
|
|
|
|
66
|
|
|
|
|
35
|
3
|
|
|
|
|
138
|
print $handle $buffer; |
36
|
3
|
|
|
|
|
32
|
return length($buffer); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
6
|
|
|
|
|
22
|
my ($ok, $error, $sent); |
40
|
|
|
|
|
|
|
{ |
41
|
6
|
|
|
|
|
12
|
local ($@, $?, $!); |
|
6
|
|
|
|
|
43
|
|
42
|
6
|
|
|
|
|
20
|
$ok = eval { |
43
|
6
|
|
|
|
|
24
|
local $self->{no_event} = 1; |
44
|
6
|
|
|
|
|
28
|
my $ctx = Test2::API::context(level => 1); |
45
|
6
|
|
|
|
|
513
|
$ctx->send_event('Output', message => $buffer, diagnostics => $self->diagnostics, stream_name => $self->stream_name); |
46
|
6
|
|
|
|
|
479
|
$sent = 1; |
47
|
6
|
|
|
|
|
29
|
$ctx->release; |
48
|
|
|
|
|
|
|
|
49
|
6
|
|
|
|
|
166
|
1; |
50
|
|
|
|
|
|
|
}; |
51
|
6
|
|
|
|
|
66
|
$error = $@; |
52
|
|
|
|
|
|
|
} |
53
|
6
|
50
|
|
|
|
50
|
return length($buffer) if $ok; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# Make sure we see the output |
56
|
0
|
0
|
|
|
|
|
print $handle $buffer unless $sent; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# Prevent any infinite loops |
59
|
0
|
|
|
|
|
|
local $self->{no_event} = 1; |
60
|
0
|
|
|
|
|
|
die $error; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# In case of __DIE__ handler? |
63
|
0
|
|
|
|
|
|
return length($buffer); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
__END__ |