line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Stream::Plugin::Intercept; |
2
|
41
|
|
|
41
|
|
211
|
use strict; |
|
41
|
|
|
|
|
84
|
|
|
41
|
|
|
|
|
1086
|
|
3
|
41
|
|
|
41
|
|
207
|
use warnings; |
|
41
|
|
|
|
|
77
|
|
|
41
|
|
|
|
|
1137
|
|
4
|
|
|
|
|
|
|
|
5
|
41
|
|
|
41
|
|
205
|
use Scalar::Util qw/blessed/; |
|
41
|
|
|
|
|
84
|
|
|
41
|
|
|
|
|
2113
|
|
6
|
|
|
|
|
|
|
|
7
|
41
|
|
|
41
|
|
229
|
use Test::Stream::Util qw/try/; |
|
41
|
|
|
|
|
84
|
|
|
41
|
|
|
|
|
289
|
|
8
|
41
|
|
|
41
|
|
228
|
use Test::Stream::Context qw/context/; |
|
41
|
|
|
|
|
86
|
|
|
41
|
|
|
|
|
383
|
|
9
|
|
|
|
|
|
|
|
10
|
41
|
|
|
41
|
|
22049
|
use Test::Stream::Hub::Interceptor; |
|
41
|
|
|
|
|
112
|
|
|
41
|
|
|
|
|
1067
|
|
11
|
41
|
|
|
41
|
|
215
|
use Test::Stream::Hub::Interceptor::Terminator; |
|
41
|
|
|
|
|
80
|
|
|
41
|
|
|
|
|
780
|
|
12
|
|
|
|
|
|
|
|
13
|
41
|
|
|
41
|
|
212
|
use Test::Stream::Exporter; |
|
41
|
|
|
|
|
80
|
|
|
41
|
|
|
|
|
299
|
|
14
|
|
|
|
|
|
|
default_exports qw/intercept/; |
15
|
41
|
|
|
41
|
|
233
|
no Test::Stream::Exporter; |
|
41
|
|
|
|
|
88
|
|
|
41
|
|
|
|
|
182
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub intercept(&) { |
18
|
133
|
|
|
133
|
1
|
805
|
my $code = shift; |
19
|
|
|
|
|
|
|
|
20
|
133
|
|
|
|
|
857
|
my $ctx = context(); |
21
|
|
|
|
|
|
|
|
22
|
133
|
|
|
|
|
291
|
my $ipc; |
23
|
133
|
100
|
|
|
|
552
|
if ($INC{'Test/Stream/IPC.pm'}) { |
24
|
129
|
|
|
|
|
959
|
my ($driver) = Test::Stream::IPC->drivers; |
25
|
129
|
|
|
|
|
861
|
$ipc = $driver->new; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
133
|
|
|
|
|
1123
|
my $hub = Test::Stream::Hub::Interceptor->new( |
29
|
|
|
|
|
|
|
ipc => $ipc, |
30
|
|
|
|
|
|
|
no_ending => 1, |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
|
33
|
133
|
|
|
|
|
684
|
my @events; |
34
|
133
|
|
|
295
|
|
1124
|
$hub->listen(sub { push @events => $_[1] }); |
|
295
|
|
|
|
|
1011
|
|
35
|
|
|
|
|
|
|
|
36
|
133
|
|
|
|
|
591
|
$ctx->stack->top; # Make sure there is a top hub before we begin. |
37
|
133
|
|
|
|
|
440
|
$ctx->stack->push($hub); |
38
|
|
|
|
|
|
|
my ($ok, $err) = try { |
39
|
133
|
|
|
133
|
|
865
|
local $ENV{TS_TERM_SIZE} = 80; |
40
|
133
|
|
|
|
|
764
|
$code->( |
41
|
|
|
|
|
|
|
hub => $hub, |
42
|
|
|
|
|
|
|
context => $ctx->snapshot, |
43
|
|
|
|
|
|
|
); |
44
|
133
|
|
|
|
|
938
|
}; |
45
|
133
|
|
|
|
|
980
|
$hub->cull; |
46
|
133
|
|
|
|
|
506
|
$ctx->stack->pop($hub); |
47
|
|
|
|
|
|
|
|
48
|
133
|
|
|
|
|
485
|
my $dbg = $ctx->debug; |
49
|
133
|
|
|
|
|
735
|
$ctx->release; |
50
|
|
|
|
|
|
|
|
51
|
133
|
100
|
66
|
|
|
587
|
die $err unless $ok |
|
|
|
66
|
|
|
|
|
52
|
|
|
|
|
|
|
|| (blessed($err) && $err->isa('Test::Stream::Hub::Interceptor::Terminator')); |
53
|
|
|
|
|
|
|
|
54
|
132
|
100
|
100
|
|
|
860
|
$hub->finalize($dbg, 1) |
|
|
|
100
|
|
|
|
|
55
|
|
|
|
|
|
|
if $ok |
56
|
|
|
|
|
|
|
&& !$hub->no_ending |
57
|
|
|
|
|
|
|
&& !$hub->state->ended; |
58
|
|
|
|
|
|
|
|
59
|
132
|
|
|
|
|
1303
|
return \@events; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
__END__ |