line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Stream::Plugin::Intercept; |
2
|
41
|
|
|
41
|
|
197
|
use strict; |
|
41
|
|
|
|
|
85
|
|
|
41
|
|
|
|
|
992
|
|
3
|
41
|
|
|
41
|
|
220
|
use warnings; |
|
41
|
|
|
|
|
74
|
|
|
41
|
|
|
|
|
1105
|
|
4
|
|
|
|
|
|
|
|
5
|
41
|
|
|
41
|
|
201
|
use Scalar::Util qw/blessed/; |
|
41
|
|
|
|
|
81
|
|
|
41
|
|
|
|
|
2108
|
|
6
|
|
|
|
|
|
|
|
7
|
41
|
|
|
41
|
|
225
|
use Test::Stream::Util qw/try/; |
|
41
|
|
|
|
|
87
|
|
|
41
|
|
|
|
|
351
|
|
8
|
41
|
|
|
41
|
|
230
|
use Test::Stream::Context qw/context/; |
|
41
|
|
|
|
|
73
|
|
|
41
|
|
|
|
|
334
|
|
9
|
|
|
|
|
|
|
|
10
|
41
|
|
|
41
|
|
21886
|
use Test::Stream::Hub::Interceptor; |
|
41
|
|
|
|
|
110
|
|
|
41
|
|
|
|
|
1016
|
|
11
|
41
|
|
|
41
|
|
206
|
use Test::Stream::Hub::Interceptor::Terminator; |
|
41
|
|
|
|
|
85
|
|
|
41
|
|
|
|
|
769
|
|
12
|
|
|
|
|
|
|
|
13
|
41
|
|
|
41
|
|
213
|
use Test::Stream::Exporter; |
|
41
|
|
|
|
|
80
|
|
|
41
|
|
|
|
|
346
|
|
14
|
|
|
|
|
|
|
default_exports qw/intercept/; |
15
|
41
|
|
|
41
|
|
235
|
no Test::Stream::Exporter; |
|
41
|
|
|
|
|
81
|
|
|
41
|
|
|
|
|
180
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub intercept(&) { |
18
|
133
|
|
|
133
|
1
|
802
|
my $code = shift; |
19
|
|
|
|
|
|
|
|
20
|
133
|
|
|
|
|
830
|
my $ctx = context(); |
21
|
|
|
|
|
|
|
|
22
|
133
|
|
|
|
|
271
|
my $ipc; |
23
|
133
|
100
|
|
|
|
463
|
if ($INC{'Test/Stream/IPC.pm'}) { |
24
|
129
|
|
|
|
|
1007
|
my ($driver) = Test::Stream::IPC->drivers; |
25
|
129
|
|
|
|
|
940
|
$ipc = $driver->new; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
133
|
|
|
|
|
1113
|
my $hub = Test::Stream::Hub::Interceptor->new( |
29
|
|
|
|
|
|
|
ipc => $ipc, |
30
|
|
|
|
|
|
|
no_ending => 1, |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
|
33
|
133
|
|
|
|
|
595
|
my @events; |
34
|
133
|
|
|
295
|
|
1192
|
$hub->listen(sub { push @events => $_[1] }); |
|
295
|
|
|
|
|
1040
|
|
35
|
|
|
|
|
|
|
|
36
|
133
|
|
|
|
|
545
|
$ctx->stack->top; # Make sure there is a top hub before we begin. |
37
|
133
|
|
|
|
|
419
|
$ctx->stack->push($hub); |
38
|
|
|
|
|
|
|
my ($ok, $err) = try { |
39
|
133
|
|
|
133
|
|
859
|
local $ENV{TS_TERM_SIZE} = 80; |
40
|
133
|
|
|
|
|
622
|
$code->( |
41
|
|
|
|
|
|
|
hub => $hub, |
42
|
|
|
|
|
|
|
context => $ctx->snapshot, |
43
|
|
|
|
|
|
|
); |
44
|
133
|
|
|
|
|
1008
|
}; |
45
|
133
|
|
|
|
|
989
|
$hub->cull; |
46
|
133
|
|
|
|
|
527
|
$ctx->stack->pop($hub); |
47
|
|
|
|
|
|
|
|
48
|
133
|
|
|
|
|
486
|
my $dbg = $ctx->debug; |
49
|
133
|
|
|
|
|
719
|
$ctx->release; |
50
|
|
|
|
|
|
|
|
51
|
133
|
100
|
66
|
|
|
663
|
die $err unless $ok |
|
|
|
66
|
|
|
|
|
52
|
|
|
|
|
|
|
|| (blessed($err) && $err->isa('Test::Stream::Hub::Interceptor::Terminator')); |
53
|
|
|
|
|
|
|
|
54
|
132
|
100
|
100
|
|
|
917
|
$hub->finalize($dbg, 1) |
|
|
|
100
|
|
|
|
|
55
|
|
|
|
|
|
|
if $ok |
56
|
|
|
|
|
|
|
&& !$hub->no_ending |
57
|
|
|
|
|
|
|
&& !$hub->state->ended; |
58
|
|
|
|
|
|
|
|
59
|
132
|
|
|
|
|
1481
|
return \@events; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
__END__ |