line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Stream::Formatter::TAP; |
2
|
109
|
|
|
109
|
|
716
|
use strict; |
|
109
|
|
|
|
|
114
|
|
|
109
|
|
|
|
|
2497
|
|
3
|
109
|
|
|
109
|
|
315
|
use warnings; |
|
109
|
|
|
|
|
107
|
|
|
109
|
|
|
|
|
2238
|
|
4
|
|
|
|
|
|
|
|
5
|
109
|
|
|
109
|
|
324
|
use Test::Stream::Util qw/protect/; |
|
109
|
|
|
|
|
124
|
|
|
109
|
|
|
|
|
511
|
|
6
|
|
|
|
|
|
|
use Test::Stream::HashBase( |
7
|
109
|
|
|
|
|
612
|
accessors => [qw/no_numbers no_header no_diag handles _encoding/], |
8
|
109
|
|
|
109
|
|
425
|
); |
|
109
|
|
|
|
|
140
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub OUT_STD() { 0 } |
11
|
|
|
|
|
|
|
sub OUT_ERR() { 1 } |
12
|
|
|
|
|
|
|
sub OUT_TODO() { 2 } |
13
|
|
|
|
|
|
|
|
14
|
109
|
|
|
109
|
|
521
|
use Test::Stream::Exporter qw/import exports/; |
|
109
|
|
|
|
|
400
|
|
|
109
|
|
|
|
|
519
|
|
15
|
|
|
|
|
|
|
exports qw/OUT_STD OUT_ERR OUT_TODO/; |
16
|
109
|
|
|
109
|
|
415
|
no Test::Stream::Exporter; |
|
109
|
|
|
|
|
129
|
|
|
109
|
|
|
|
|
336
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
_autoflush(\*STDOUT); |
19
|
|
|
|
|
|
|
_autoflush(\*STDERR); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub init { |
22
|
131
|
|
|
131
|
0
|
213
|
my $self = shift; |
23
|
|
|
|
|
|
|
|
24
|
131
|
|
66
|
|
|
1606
|
$self->{+HANDLES} ||= $self->_open_handles; |
25
|
131
|
100
|
|
|
|
528
|
if(my $enc = delete $self->{encoding}) { |
26
|
1
|
|
|
|
|
3
|
$self->encoding($enc); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub encoding { |
31
|
117
|
|
|
117
|
1
|
161
|
my $self = shift; |
32
|
|
|
|
|
|
|
|
33
|
117
|
100
|
|
|
|
315
|
if (@_) { |
34
|
116
|
|
|
|
|
186
|
my ($enc) = @_; |
35
|
116
|
|
|
|
|
196
|
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
|
116
|
50
|
|
|
|
944
|
if ($enc =~ m/^utf-?8$/i) { |
41
|
116
|
|
|
|
|
814
|
binmode($_, ":utf8") for @$handles; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
else { |
44
|
0
|
|
|
|
|
0
|
binmode($_, ":encoding($enc)") for @$handles; |
45
|
|
|
|
|
|
|
} |
46
|
116
|
|
|
|
|
273
|
$self->{+_ENCODING} = $enc; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
117
|
|
|
|
|
517
|
return $self->{+_ENCODING}; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
if ($^C) { |
53
|
109
|
|
|
109
|
|
475
|
no warnings 'redefine'; |
|
109
|
|
|
|
|
140
|
|
|
109
|
|
|
|
|
15528
|
|
54
|
|
|
|
|
|
|
*write = sub {}; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
sub write { |
57
|
1737
|
|
|
1737
|
1
|
2003
|
my ($self, $e, $num) = @_; |
58
|
|
|
|
|
|
|
|
59
|
1737
|
100
|
100
|
|
|
3860
|
return if $self->{+NO_DIAG} && $e->isa('Test::Stream::Event::Diag'); |
60
|
1736
|
100
|
100
|
|
|
3629
|
return if $self->{+NO_HEADER} && $e->isa('Test::Stream::Event::Plan'); |
61
|
|
|
|
|
|
|
|
62
|
1735
|
100
|
|
|
|
2575
|
$num = undef if $self->{+NO_NUMBERS}; |
63
|
1735
|
|
|
|
|
3433
|
my @tap = $e->to_tap($num); |
64
|
|
|
|
|
|
|
|
65
|
1735
|
|
|
|
|
1861
|
my $handles = $self->{+HANDLES}; |
66
|
1735
|
|
100
|
|
|
4218
|
my $nesting = $e->nested || 0; |
67
|
1735
|
|
|
|
|
7650
|
my $indent = ' ' x $nesting; |
68
|
|
|
|
|
|
|
|
69
|
1735
|
100
|
100
|
|
|
3314
|
return if $nesting && $e->isa('Test::Stream::Event::Bail'); |
70
|
|
|
|
|
|
|
|
71
|
1734
|
|
|
|
|
5204
|
local($\, $", $,) = (undef, ' ', ''); |
72
|
1734
|
|
|
|
|
2381
|
for my $set (@tap) { |
73
|
109
|
|
|
109
|
|
402
|
no warnings 'uninitialized'; |
|
109
|
|
|
|
|
127
|
|
|
109
|
|
|
|
|
20607
|
|
74
|
3422
|
|
|
|
|
5811
|
my ($hid, $msg) = @$set; |
75
|
3422
|
50
|
|
|
|
5824
|
next unless $msg; |
76
|
3422
|
50
|
|
|
|
6031
|
my $io = $handles->[$hid] or next; |
77
|
|
|
|
|
|
|
|
78
|
3422
|
100
|
|
|
|
4700
|
$msg =~ s/^/$indent/mg if $nesting; |
79
|
3422
|
|
|
|
|
322343
|
print $io $msg; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub _open_handles { |
84
|
128
|
|
|
128
|
|
170
|
my $self = shift; |
85
|
|
|
|
|
|
|
|
86
|
128
|
50
|
|
|
|
3006
|
open( my $out, ">&STDOUT" ) or die "Can't dup STDOUT: $!"; |
87
|
128
|
50
|
|
|
|
1533
|
open( my $err, ">&STDERR" ) or die "Can't dup STDERR: $!"; |
88
|
|
|
|
|
|
|
|
89
|
128
|
|
|
|
|
377
|
_autoflush($out); |
90
|
128
|
|
|
|
|
269
|
_autoflush($err); |
91
|
|
|
|
|
|
|
|
92
|
128
|
|
|
|
|
484
|
return [$out, $err, $out]; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub _autoflush { |
96
|
474
|
|
|
474
|
|
568
|
my($fh) = pop; |
97
|
474
|
|
|
|
|
1019
|
my $old_fh = select $fh; |
98
|
474
|
|
|
|
|
790
|
$| = 1; |
99
|
474
|
|
|
|
|
1043
|
select $old_fh; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
1; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
__END__ |