line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Stream::Plugin::Grab; |
2
|
37
|
|
|
37
|
|
137
|
use strict; |
|
37
|
|
|
|
|
48
|
|
|
37
|
|
|
|
|
836
|
|
3
|
37
|
|
|
37
|
|
919
|
use warnings; |
|
37
|
|
|
|
|
46
|
|
|
37
|
|
|
|
|
651
|
|
4
|
|
|
|
|
|
|
|
5
|
37
|
|
|
37
|
|
115
|
use Test::Stream::Sync(); |
|
37
|
|
|
|
|
41
|
|
|
37
|
|
|
|
|
421
|
|
6
|
37
|
|
|
37
|
|
121
|
use Test::Stream::DebugInfo(); |
|
37
|
|
|
|
|
37
|
|
|
37
|
|
|
|
|
360
|
|
7
|
37
|
|
|
37
|
|
450
|
use Test::Stream::Hub::Interceptor(); |
|
37
|
|
|
|
|
45
|
|
|
37
|
|
|
|
|
534
|
|
8
|
|
|
|
|
|
|
|
9
|
37
|
|
|
37
|
|
118
|
use Test::Stream::Exporter qw/import default_export/; |
|
37
|
|
|
|
|
45
|
|
|
37
|
|
|
|
|
170
|
|
10
|
5
|
|
|
5
|
|
61
|
default_export grab => sub { __PACKAGE__->new }; |
11
|
37
|
|
|
37
|
|
159
|
no Test::Stream::Exporter; |
|
37
|
|
|
|
|
51
|
|
|
37
|
|
|
|
|
406
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $STACK = Test::Stream::Sync->stack; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
use Test::Stream::HashBase( |
16
|
37
|
|
|
|
|
235
|
accessors => [qw/hub finished _events term_size/], |
17
|
37
|
|
|
37
|
|
150
|
); |
|
37
|
|
|
|
|
47
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub init { |
20
|
5
|
|
|
5
|
0
|
7
|
my $self = shift; |
21
|
|
|
|
|
|
|
|
22
|
5
|
|
|
|
|
5
|
my $ipc; |
23
|
5
|
50
|
|
|
|
13
|
if ($INC{'Test/Stream/IPC.pm'}) { |
24
|
5
|
|
|
|
|
18
|
my ($driver) = Test::Stream::IPC->drivers; |
25
|
5
|
|
|
|
|
20
|
$ipc = $driver->new; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
5
|
|
|
|
|
29
|
$self->{+HUB} = Test::Stream::Hub::Interceptor->new( |
29
|
|
|
|
|
|
|
ipc => $ipc, |
30
|
|
|
|
|
|
|
no_ending => 1, |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
|
33
|
5
|
|
|
|
|
6
|
my @events; |
34
|
5
|
|
|
6
|
|
33
|
$self->{+HUB}->listen(sub { push @events => $_[1] }); |
|
6
|
|
|
|
|
15
|
|
35
|
|
|
|
|
|
|
|
36
|
5
|
|
|
|
|
6
|
$self->{+_EVENTS} = \@events; |
37
|
|
|
|
|
|
|
|
38
|
5
|
|
|
|
|
16
|
$STACK->top(); # Make sure there is a top hub before we begin. |
39
|
5
|
|
|
|
|
14
|
$STACK->push($self->{+HUB}); |
40
|
|
|
|
|
|
|
|
41
|
5
|
|
|
|
|
6
|
$self->{+TERM_SIZE} = $ENV{TS_TERM_SIZE}; |
42
|
5
|
|
|
|
|
28
|
$ENV{TS_TERM_SIZE} = 80; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub flush { |
46
|
5
|
|
|
5
|
1
|
8
|
my $self = shift; |
47
|
5
|
|
|
|
|
6
|
my $out = [@{$self->{+_EVENTS}}]; |
|
5
|
|
|
|
|
10
|
|
48
|
5
|
|
|
|
|
3
|
@{$self->{+_EVENTS}} = (); |
|
5
|
|
|
|
|
11
|
|
49
|
5
|
|
|
|
|
20
|
return $out; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub events { |
53
|
1
|
|
|
1
|
1
|
3
|
my $self = shift; |
54
|
|
|
|
|
|
|
# Copy |
55
|
1
|
|
|
|
|
1
|
return [@{$self->{+_EVENTS}}]; |
|
1
|
|
|
|
|
3
|
|
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub finish { |
59
|
5
|
|
|
5
|
1
|
9
|
my ($self) = @_; # Do not shift; |
60
|
5
|
|
|
|
|
8
|
$_[0] = undef; |
61
|
|
|
|
|
|
|
|
62
|
5
|
50
|
|
|
|
9
|
if (defined $self->{+TERM_SIZE}) { |
63
|
0
|
|
|
|
|
0
|
$ENV{TS_TERM_SIZE} = $self->{+TERM_SIZE}; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
else { |
66
|
5
|
|
|
|
|
18
|
delete $ENV{TS_TERM_SIZE}; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
5
|
|
|
|
|
7
|
my $hub = $self->{+HUB}; |
70
|
|
|
|
|
|
|
|
71
|
5
|
|
|
|
|
7
|
$self->{+FINISHED} = 1; |
72
|
5
|
|
|
|
|
13
|
$STACK->pop($hub); |
73
|
|
|
|
|
|
|
|
74
|
5
|
|
|
|
|
43
|
my $dbg = Test::Stream::DebugInfo->new( |
75
|
|
|
|
|
|
|
frame => [caller(0)], |
76
|
|
|
|
|
|
|
); |
77
|
5
|
0
|
33
|
|
|
16
|
$hub->finalize($dbg, 1) |
78
|
|
|
|
|
|
|
if !$hub->no_ending |
79
|
|
|
|
|
|
|
&& !$hub->state->ended; |
80
|
|
|
|
|
|
|
|
81
|
5
|
|
|
|
|
27
|
return $self->flush; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub DESTROY { |
85
|
5
|
|
|
5
|
|
5
|
my $self = shift; |
86
|
5
|
50
|
|
|
|
21
|
return if $self->{+FINISHED}; |
87
|
0
|
|
|
|
|
|
$STACK->pop($self->{+HUB}); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
1; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
__END__ |