line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Stream::Formatter::TAP; |
2
|
109
|
|
|
109
|
|
1108
|
use strict; |
|
109
|
|
|
|
|
201
|
|
|
109
|
|
|
|
|
2617
|
|
3
|
109
|
|
|
109
|
|
518
|
use warnings; |
|
109
|
|
|
|
|
181
|
|
|
109
|
|
|
|
|
2774
|
|
4
|
|
|
|
|
|
|
|
5
|
109
|
|
|
109
|
|
537
|
use Test::Stream::Util qw/protect/; |
|
109
|
|
|
|
|
197
|
|
|
109
|
|
|
|
|
736
|
|
6
|
|
|
|
|
|
|
use Test::Stream::HashBase( |
7
|
109
|
|
|
|
|
881
|
accessors => [qw/no_numbers no_header no_diag handles _encoding/], |
8
|
109
|
|
|
109
|
|
561
|
); |
|
109
|
|
|
|
|
195
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub OUT_STD() { 0 } |
11
|
|
|
|
|
|
|
sub OUT_ERR() { 1 } |
12
|
|
|
|
|
|
|
sub OUT_TODO() { 2 } |
13
|
|
|
|
|
|
|
|
14
|
109
|
|
|
109
|
|
604
|
use Test::Stream::Exporter; |
|
109
|
|
|
|
|
194
|
|
|
109
|
|
|
|
|
706
|
|
15
|
|
|
|
|
|
|
exports qw/OUT_STD OUT_ERR OUT_TODO/; |
16
|
109
|
|
|
109
|
|
571
|
no Test::Stream::Exporter; |
|
109
|
|
|
|
|
232
|
|
|
109
|
|
|
|
|
462
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
_autoflush(\*STDOUT); |
19
|
|
|
|
|
|
|
_autoflush(\*STDERR); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub init { |
22
|
131
|
|
|
131
|
0
|
302
|
my $self = shift; |
23
|
|
|
|
|
|
|
|
24
|
131
|
|
66
|
|
|
1451
|
$self->{+HANDLES} ||= $self->_open_handles; |
25
|
131
|
100
|
|
|
|
690
|
if(my $enc = delete $self->{encoding}) { |
26
|
1
|
|
|
|
|
4
|
$self->encoding($enc); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub encoding { |
31
|
116
|
|
|
116
|
1
|
263
|
my $self = shift; |
32
|
|
|
|
|
|
|
|
33
|
116
|
100
|
|
|
|
457
|
if (@_) { |
34
|
115
|
|
|
|
|
695
|
my ($enc) = @_; |
35
|
115
|
|
|
|
|
377
|
my $handles = $self->{+HANDLES}; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# https://rt.perl.org/Public/Bug/Display.html?id=31923 |
38
|
|
|
|
|
|
|
# If utf8 is requested we use ':utf8' instead of ':encoding(utf8)' in |
39
|
|
|
|
|
|
|
# order to avoid the thread segfault. |
40
|
115
|
50
|
|
|
|
1146
|
if ($enc =~ m/^utf-?8$/i) { |
41
|
115
|
|
|
|
|
1151
|
binmode($_, ":utf8") for @$handles; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
else { |
44
|
0
|
|
|
|
|
0
|
binmode($_, ":encoding($enc)") for @$handles; |
45
|
|
|
|
|
|
|
} |
46
|
115
|
|
|
|
|
442
|
$self->{+_ENCODING} = $enc; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
116
|
|
|
|
|
851
|
return $self->{+_ENCODING}; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
if ($^C) { |
53
|
109
|
|
|
109
|
|
617
|
no warnings 'redefine'; |
|
109
|
|
|
|
|
222
|
|
|
109
|
|
|
|
|
23110
|
|
54
|
|
|
|
|
|
|
*write = sub {}; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
sub write { |
57
|
1726
|
|
|
1726
|
1
|
3035
|
my ($self, $e, $num) = @_; |
58
|
|
|
|
|
|
|
|
59
|
1726
|
100
|
100
|
|
|
6531
|
return if $self->{+NO_DIAG} && $e->isa('Test::Stream::Event::Diag'); |
60
|
1725
|
100
|
100
|
|
|
4989
|
return if $self->{+NO_HEADER} && $e->isa('Test::Stream::Event::Plan'); |
61
|
|
|
|
|
|
|
|
62
|
1724
|
100
|
|
|
|
3994
|
$num = undef if $self->{+NO_NUMBERS}; |
63
|
1724
|
|
|
|
|
5476
|
my @tap = $e->to_tap($num); |
64
|
|
|
|
|
|
|
|
65
|
1724
|
|
|
|
|
3169
|
my $handles = $self->{+HANDLES}; |
66
|
1724
|
|
100
|
|
|
6706
|
my $nesting = $e->nested || 0; |
67
|
1724
|
|
|
|
|
10877
|
my $indent = ' ' x $nesting; |
68
|
|
|
|
|
|
|
|
69
|
1724
|
100
|
100
|
|
|
4714
|
return if $nesting && $e->isa('Test::Stream::Event::Bail'); |
70
|
|
|
|
|
|
|
|
71
|
1723
|
|
|
|
|
6800
|
local($\, $", $,) = (undef, ' ', ''); |
72
|
1723
|
|
|
|
|
3358
|
for my $set (@tap) { |
73
|
109
|
|
|
109
|
|
560
|
no warnings 'uninitialized'; |
|
109
|
|
|
|
|
208
|
|
|
109
|
|
|
|
|
29198
|
|
74
|
3400
|
|
|
|
|
8171
|
my ($hid, $msg) = @$set; |
75
|
3400
|
50
|
|
|
|
8587
|
next unless $msg; |
76
|
3400
|
50
|
|
|
|
8552
|
my $io = $handles->[$hid] or next; |
77
|
|
|
|
|
|
|
|
78
|
3400
|
100
|
|
|
|
7479
|
$msg =~ s/^/$indent/mg if $nesting; |
79
|
3400
|
|
|
|
|
382952
|
print $io $msg; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub _open_handles { |
84
|
128
|
|
|
128
|
|
281
|
my $self = shift; |
85
|
|
|
|
|
|
|
|
86
|
128
|
50
|
|
|
|
3472
|
open( my $out, ">&STDOUT" ) or die "Can't dup STDOUT: $!"; |
87
|
128
|
50
|
|
|
|
1614
|
open( my $err, ">&STDERR" ) or die "Can't dup STDERR: $!"; |
88
|
|
|
|
|
|
|
|
89
|
128
|
|
|
|
|
503
|
_autoflush($out); |
90
|
128
|
|
|
|
|
384
|
_autoflush($err); |
91
|
|
|
|
|
|
|
|
92
|
128
|
|
|
|
|
642
|
return [$out, $err, $out]; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub _autoflush { |
96
|
474
|
|
|
474
|
|
914
|
my($fh) = pop; |
97
|
474
|
|
|
|
|
1426
|
my $old_fh = select $fh; |
98
|
474
|
|
|
|
|
1210
|
$| = 1; |
99
|
474
|
|
|
|
|
1340
|
select $old_fh; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
1; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
__END__ |