line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Stream::Plugin::Intercept; |
2
|
41
|
|
|
41
|
|
146
|
use strict; |
|
41
|
|
|
|
|
58
|
|
|
41
|
|
|
|
|
953
|
|
3
|
41
|
|
|
41
|
|
133
|
use warnings; |
|
41
|
|
|
|
|
52
|
|
|
41
|
|
|
|
|
866
|
|
4
|
|
|
|
|
|
|
|
5
|
41
|
|
|
41
|
|
127
|
use Scalar::Util qw/blessed/; |
|
41
|
|
|
|
|
49
|
|
|
41
|
|
|
|
|
1687
|
|
6
|
|
|
|
|
|
|
|
7
|
41
|
|
|
41
|
|
145
|
use Test::Stream::Util qw/try/; |
|
41
|
|
|
|
|
44
|
|
|
41
|
|
|
|
|
191
|
|
8
|
41
|
|
|
41
|
|
163
|
use Test::Stream::Context qw/context/; |
|
41
|
|
|
|
|
63
|
|
|
41
|
|
|
|
|
209
|
|
9
|
|
|
|
|
|
|
|
10
|
41
|
|
|
41
|
|
13868
|
use Test::Stream::Hub::Interceptor(); |
|
41
|
|
|
|
|
67
|
|
|
41
|
|
|
|
|
582
|
|
11
|
41
|
|
|
41
|
|
167
|
use Test::Stream::Hub::Interceptor::Terminator(); |
|
41
|
|
|
|
|
56
|
|
|
41
|
|
|
|
|
585
|
|
12
|
|
|
|
|
|
|
|
13
|
41
|
|
|
41
|
|
127
|
use Test::Stream::Exporter qw/import default_exports/; |
|
41
|
|
|
|
|
53
|
|
|
41
|
|
|
|
|
211
|
|
14
|
|
|
|
|
|
|
default_exports qw/intercept/; |
15
|
41
|
|
|
41
|
|
168
|
no Test::Stream::Exporter; |
|
41
|
|
|
|
|
57
|
|
|
41
|
|
|
|
|
130
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub intercept(&) { |
18
|
134
|
|
|
134
|
1
|
670
|
my $code = shift; |
19
|
|
|
|
|
|
|
|
20
|
134
|
|
|
|
|
669
|
my $ctx = context(); |
21
|
|
|
|
|
|
|
|
22
|
134
|
|
|
|
|
137
|
my $ipc; |
23
|
134
|
100
|
|
|
|
363
|
if ($INC{'Test/Stream/IPC.pm'}) { |
24
|
130
|
|
|
|
|
712
|
my ($driver) = Test::Stream::IPC->drivers; |
25
|
130
|
|
|
|
|
656
|
$ipc = $driver->new; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
134
|
|
|
|
|
797
|
my $hub = Test::Stream::Hub::Interceptor->new( |
29
|
|
|
|
|
|
|
ipc => $ipc, |
30
|
|
|
|
|
|
|
no_ending => 1, |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
|
33
|
134
|
|
|
|
|
174
|
my @events; |
34
|
134
|
|
|
305
|
|
917
|
$hub->listen(sub { push @events => $_[1] }); |
|
305
|
|
|
|
|
739
|
|
35
|
|
|
|
|
|
|
|
36
|
134
|
|
|
|
|
433
|
$ctx->stack->top; # Make sure there is a top hub before we begin. |
37
|
134
|
|
|
|
|
959
|
$ctx->stack->push($hub); |
38
|
|
|
|
|
|
|
my ($ok, $err) = try { |
39
|
134
|
|
|
134
|
|
636
|
local $ENV{TS_TERM_SIZE} = 80; |
40
|
134
|
|
|
|
|
438
|
$code->( |
41
|
|
|
|
|
|
|
hub => $hub, |
42
|
|
|
|
|
|
|
context => $ctx->snapshot, |
43
|
|
|
|
|
|
|
); |
44
|
134
|
|
|
|
|
722
|
}; |
45
|
134
|
|
|
|
|
761
|
$hub->cull; |
46
|
134
|
|
|
|
|
415
|
$ctx->stack->pop($hub); |
47
|
|
|
|
|
|
|
|
48
|
134
|
|
|
|
|
326
|
my $dbg = $ctx->debug; |
49
|
134
|
|
|
|
|
515
|
$ctx->release; |
50
|
|
|
|
|
|
|
|
51
|
134
|
100
|
66
|
|
|
475
|
die $err unless $ok |
|
|
|
66
|
|
|
|
|
52
|
|
|
|
|
|
|
|| (blessed($err) && $err->isa('Test::Stream::Hub::Interceptor::Terminator')); |
53
|
|
|
|
|
|
|
|
54
|
133
|
100
|
100
|
|
|
645
|
$hub->finalize($dbg, 1) |
|
|
|
100
|
|
|
|
|
55
|
|
|
|
|
|
|
if $ok |
56
|
|
|
|
|
|
|
&& !$hub->no_ending |
57
|
|
|
|
|
|
|
&& !$hub->state->ended; |
58
|
|
|
|
|
|
|
|
59
|
133
|
|
|
|
|
947
|
return \@events; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
__END__ |