line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Plugin::IOEvents::Base; |
2
|
5
|
|
|
5
|
|
177300
|
use strict; |
|
5
|
|
|
|
|
14
|
|
|
5
|
|
|
|
|
133
|
|
3
|
5
|
|
|
5
|
|
24
|
use warnings; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
284
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.000007'; |
6
|
|
|
|
|
|
|
|
7
|
5
|
|
|
5
|
|
1261
|
use Test2::Plugin::OpenFixPerlIO; |
|
5
|
|
|
|
|
14
|
|
|
5
|
|
|
|
|
114
|
|
8
|
5
|
|
|
5
|
|
2404
|
use IO::Handle; |
|
5
|
|
|
|
|
24739
|
|
|
5
|
|
|
|
|
1346
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
0
|
5
|
sub diagnostics { 0 } |
11
|
1
|
|
|
1
|
0
|
6
|
sub stream_name { 'UNKNOWN' } |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub PUSHED { |
14
|
5
|
|
|
5
|
0
|
5714
|
my ($class, $mode, $handle) = @_; |
15
|
5
|
|
|
|
|
58
|
$handle->autoflush(1); |
16
|
5
|
|
|
|
|
321
|
bless {}, $class; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my $LOADED = 0; |
20
|
|
|
|
|
|
|
sub WRITE { |
21
|
9
|
|
|
9
|
|
14217
|
my ($self, $buffer, $handle) = @_; |
22
|
|
|
|
|
|
|
|
23
|
9
|
|
66
|
|
|
82
|
$LOADED ||= $INC{'Test2/API.pm'} && Test2::API::test2_init_done(); |
|
|
|
100
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# Test2::API not loaded (?) |
26
|
9
|
100
|
66
|
|
|
153
|
if ($self->{no_event} || !$LOADED) { |
27
|
3
|
|
|
|
|
132
|
print $handle $buffer; |
28
|
3
|
|
|
|
|
27
|
return length($buffer); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
6
|
|
|
|
|
21
|
my ($ok, $error, $sent); |
32
|
|
|
|
|
|
|
{ |
33
|
6
|
|
|
|
|
15
|
local ($@, $?, $!); |
|
6
|
|
|
|
|
43
|
|
34
|
6
|
|
|
|
|
18
|
$ok = eval { |
35
|
6
|
|
|
|
|
20
|
local $self->{no_event} = 1; |
36
|
6
|
|
|
|
|
25
|
my $ctx = Test2::API::context(level => 1); |
37
|
6
|
|
|
|
|
478
|
$ctx->send_event('Output', message => $buffer, diagnostics => $self->diagnostics, stream_name => $self->stream_name); |
38
|
6
|
|
|
|
|
484
|
$sent = 1; |
39
|
6
|
|
|
|
|
25
|
$ctx->release; |
40
|
|
|
|
|
|
|
|
41
|
6
|
|
|
|
|
164
|
1; |
42
|
|
|
|
|
|
|
}; |
43
|
6
|
|
|
|
|
64
|
$error = $@; |
44
|
|
|
|
|
|
|
} |
45
|
6
|
50
|
|
|
|
58
|
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__ |