line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Plugin::IOEvents::Base; |
2
|
5
|
|
|
5
|
|
190050
|
use strict; |
|
5
|
|
|
|
|
18
|
|
|
5
|
|
|
|
|
168
|
|
3
|
5
|
|
|
5
|
|
38
|
use warnings; |
|
5
|
|
|
|
|
15
|
|
|
5
|
|
|
|
|
256
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.000008'; |
6
|
|
|
|
|
|
|
|
7
|
5
|
|
|
5
|
|
1460
|
use Test2::Plugin::OpenFixPerlIO; |
|
5
|
|
|
|
|
17
|
|
|
5
|
|
|
|
|
207
|
|
8
|
5
|
|
|
5
|
|
2657
|
use IO::Handle; |
|
5
|
|
|
|
|
27148
|
|
|
5
|
|
|
|
|
1503
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
0
|
10
|
sub diagnostics { 0 } |
11
|
1
|
|
|
1
|
0
|
7
|
sub stream_name { 'UNKNOWN' } |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub PUSHED { |
14
|
5
|
|
|
5
|
0
|
8204
|
my ($class, $mode, $handle) = @_; |
15
|
5
|
|
|
|
|
59
|
$handle->autoflush(1); |
16
|
5
|
|
|
|
|
367
|
bless {}, $class; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my $LOADED = 0; |
20
|
|
|
|
|
|
|
sub WRITE { |
21
|
9
|
|
|
9
|
|
15450
|
my ($self, $buffer, $handle) = @_; |
22
|
|
|
|
|
|
|
|
23
|
9
|
|
66
|
|
|
89
|
$LOADED ||= $INC{'Test2/API.pm'} && Test2::API::test2_init_done(); |
|
|
|
100
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# Test2::API not loaded (?) |
26
|
9
|
100
|
66
|
|
|
168
|
if ($self->{no_event} || !$LOADED) { |
27
|
3
|
|
|
|
|
140
|
print $handle $buffer; |
28
|
3
|
|
|
|
|
34
|
return length($buffer); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
6
|
|
|
|
|
23
|
my ($ok, $error, $sent); |
32
|
|
|
|
|
|
|
{ |
33
|
6
|
|
|
|
|
14
|
local ($@, $?, $!); |
|
6
|
|
|
|
|
46
|
|
34
|
6
|
|
|
|
|
18
|
$ok = eval { |
35
|
6
|
|
|
|
|
23
|
local $self->{no_event} = 1; |
36
|
6
|
|
|
|
|
25
|
my $ctx = Test2::API::context(level => 1); |
37
|
6
|
|
|
|
|
568
|
$ctx->send_event('Output', message => $buffer, diagnostics => $self->diagnostics, stream_name => $self->stream_name); |
38
|
6
|
|
|
|
|
545
|
$sent = 1; |
39
|
6
|
|
|
|
|
32
|
$ctx->release; |
40
|
|
|
|
|
|
|
|
41
|
6
|
|
|
|
|
195
|
1; |
42
|
|
|
|
|
|
|
}; |
43
|
6
|
|
|
|
|
76
|
$error = $@; |
44
|
|
|
|
|
|
|
} |
45
|
6
|
50
|
|
|
|
72
|
return length($buffer) if $ok; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# Make sure we see the output |
48
|
0
|
0
|
|
|
|
|
print $handle $buffer unless $sent; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# Prevent any infinite loops |
51
|
0
|
|
|
|
|
|
local $self->{no_event} = 1; |
52
|
0
|
|
|
|
|
|
die $error; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# In case of __DIE__ handler? |
55
|
0
|
|
|
|
|
|
return length($buffer); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
__END__ |