line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package TAP::Formatter::Session; |
2
|
|
|
|
|
|
|
|
3
|
16
|
|
|
308
|
|
74
|
use strict; |
|
16
|
|
|
|
|
19
|
|
|
16
|
|
|
|
|
365
|
|
4
|
16
|
|
|
16
|
|
52
|
use warnings; |
|
16
|
|
|
|
|
20
|
|
|
16
|
|
|
|
|
359
|
|
5
|
|
|
|
|
|
|
|
6
|
16
|
|
|
16
|
|
51
|
use base 'TAP::Base'; |
|
16
|
|
|
|
|
17
|
|
|
16
|
|
|
|
|
1798
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
my @ACCESSOR; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
BEGIN { |
11
|
|
|
|
|
|
|
|
12
|
16
|
|
|
16
|
|
73
|
@ACCESSOR = qw( name formatter parser show_count ); |
13
|
|
|
|
|
|
|
|
14
|
16
|
|
|
|
|
30
|
for my $method (@ACCESSOR) { |
15
|
16
|
|
|
16
|
|
69
|
no strict 'refs'; |
|
16
|
|
|
|
|
29
|
|
|
16
|
|
|
|
|
1026
|
|
16
|
64
|
|
|
1740
|
|
12254
|
*$method = sub { shift->{$method} }; |
|
1740
|
|
|
303
|
|
3876
|
|
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 NAME |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
TAP::Formatter::Session - Abstract base class for harness output delegate |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 VERSION |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Version 3.39 |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=cut |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
our $VERSION = '3.39'; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 METHODS |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head2 Class Methods |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head3 C |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my %args = ( |
39
|
|
|
|
|
|
|
formatter => $self, |
40
|
|
|
|
|
|
|
) |
41
|
|
|
|
|
|
|
my $harness = TAP::Formatter::Console::Session->new( \%args ); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
The constructor returns a new C object. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=over 4 |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=item * C |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=item * C |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=item * C |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=item * C |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=back |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=cut |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub _initialize { |
60
|
107
|
|
|
107
|
|
192
|
my ( $self, $arg_for ) = @_; |
61
|
107
|
|
50
|
|
|
282
|
$arg_for ||= {}; |
62
|
|
|
|
|
|
|
|
63
|
107
|
|
|
|
|
689
|
$self->SUPER::_initialize($arg_for); |
64
|
107
|
|
|
|
|
541
|
my %arg_for = %$arg_for; # force a shallow copy |
65
|
|
|
|
|
|
|
|
66
|
107
|
|
|
|
|
426
|
for my $name (@ACCESSOR) { |
67
|
428
|
|
|
|
|
794
|
$self->{$name} = delete $arg_for{$name}; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
107
|
50
|
|
|
|
410
|
if ( !defined $self->show_count ) { |
71
|
107
|
|
|
|
|
179
|
$self->{show_count} = 1; # defaults to true |
72
|
|
|
|
|
|
|
} |
73
|
107
|
50
|
|
|
|
189
|
if ( $self->show_count ) { # but may be a damned lie! |
74
|
107
|
|
|
|
|
475
|
$self->{show_count} = $self->_should_show_count; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
107
|
50
|
|
|
|
448
|
if ( my @props = sort keys %arg_for ) { |
78
|
0
|
|
|
|
|
0
|
$self->_croak( |
79
|
|
|
|
|
|
|
"Unknown arguments to " . __PACKAGE__ . "::new (@props)" ); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
107
|
|
|
|
|
280
|
return $self; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head3 C |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Output test preamble |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head3 C |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Called by the harness for each line of TAP it receives. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head3 C |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Called to close a test session. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head3 C |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Called by C to clear the line showing test progress, or the parallel |
100
|
|
|
|
|
|
|
test ruler, prior to printing the final test result. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head3 C |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Return a formatted string about the elapsed (wall-clock) time |
105
|
|
|
|
|
|
|
and about the consumed CPU time. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=cut |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
93
|
1
|
|
sub header { } |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
0
|
1
|
|
sub result { } |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
0
|
1
|
|
sub close_test { } |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
0
|
1
|
|
sub clear_for_close { } |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub _should_show_count { |
118
|
107
|
|
|
107
|
|
151
|
my $self = shift; |
119
|
|
|
|
|
|
|
return |
120
|
|
|
|
|
|
|
!$self->formatter->verbose |
121
|
|
|
|
|
|
|
&& -t $self->formatter->stdout |
122
|
107
|
|
33
|
|
|
341
|
&& !$ENV{HARNESS_NOTTY}; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub _format_for_output { |
126
|
53
|
|
|
53
|
|
61
|
my ( $self, $result ) = @_; |
127
|
53
|
50
|
|
|
|
68
|
return $self->formatter->normalize ? $result->as_string : $result->raw; |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub _output_test_failure { |
131
|
37
|
|
|
37
|
|
64
|
my ( $self, $parser ) = @_; |
132
|
37
|
|
|
|
|
104
|
my $formatter = $self->formatter; |
133
|
37
|
50
|
|
|
|
99
|
return if $formatter->really_quiet; |
134
|
|
|
|
|
|
|
|
135
|
37
|
|
|
|
|
94
|
my $tests_run = $parser->tests_run; |
136
|
37
|
|
|
|
|
81
|
my $tests_planned = $parser->tests_planned; |
137
|
|
|
|
|
|
|
|
138
|
37
|
100
|
|
|
|
98
|
my $total |
139
|
|
|
|
|
|
|
= defined $tests_planned |
140
|
|
|
|
|
|
|
? $tests_planned |
141
|
|
|
|
|
|
|
: $tests_run; |
142
|
|
|
|
|
|
|
|
143
|
37
|
|
|
|
|
92
|
my $passed = $parser->passed; |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
# The total number of fails includes any tests that were planned but |
146
|
|
|
|
|
|
|
# didn't run |
147
|
37
|
|
|
|
|
90
|
my $failed = $parser->failed + $total - $tests_run; |
148
|
37
|
|
|
|
|
91
|
my $exit = $parser->exit; |
149
|
|
|
|
|
|
|
|
150
|
37
|
100
|
|
|
|
77
|
if ( my $exit = $parser->exit ) { |
151
|
10
|
|
|
|
|
26
|
my $wstat = $parser->wait; |
152
|
10
|
|
|
|
|
70
|
my $status = sprintf( "%d (wstat %d, 0x%x)", $exit, $wstat, $wstat ); |
153
|
10
|
|
|
|
|
45
|
$formatter->_failure_output("Dubious, test returned $status\n"); |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
|
156
|
37
|
100
|
|
|
|
92
|
if ( $failed == 0 ) { |
157
|
14
|
100
|
|
|
|
63
|
$formatter->_failure_output( |
158
|
|
|
|
|
|
|
$total |
159
|
|
|
|
|
|
|
? "All $total subtests passed " |
160
|
|
|
|
|
|
|
: 'No subtests run ' |
161
|
|
|
|
|
|
|
); |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
else { |
164
|
23
|
|
|
|
|
141
|
$formatter->_failure_output("Failed $failed/$total subtests "); |
165
|
23
|
50
|
|
|
|
153
|
if ( !$total ) { |
166
|
0
|
|
|
|
|
0
|
$formatter->_failure_output("\nNo tests run!"); |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
|
170
|
37
|
50
|
|
|
|
116
|
if ( my $skipped = $parser->skipped ) { |
171
|
0
|
|
|
|
|
0
|
$passed -= $skipped; |
172
|
0
|
0
|
|
|
|
0
|
my $test = 'subtest' . ( $skipped != 1 ? 's' : '' ); |
173
|
0
|
|
|
|
|
0
|
$formatter->_output( |
174
|
|
|
|
|
|
|
"\n\t(less $skipped skipped $test: $passed okay)"); |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
37
|
50
|
|
|
|
104
|
if ( my $failed = $parser->todo_passed ) { |
178
|
0
|
0
|
|
|
|
0
|
my $test = $failed > 1 ? 'tests' : 'test'; |
179
|
0
|
|
|
|
|
0
|
$formatter->_output( |
180
|
|
|
|
|
|
|
"\n\t($failed TODO $test unexpectedly succeeded)"); |
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
|
183
|
37
|
|
|
|
|
99
|
$formatter->_output("\n"); |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
sub _make_ok_line { |
187
|
42
|
|
|
42
|
|
62
|
my ( $self, $suffix ) = @_; |
188
|
42
|
|
|
|
|
245
|
return "ok$suffix\n"; |
189
|
|
|
|
|
|
|
} |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
sub time_report { |
192
|
42
|
|
|
42
|
1
|
56
|
my ( $self, $formatter, $parser ) = @_; |
193
|
|
|
|
|
|
|
|
194
|
42
|
|
|
|
|
47
|
my @time_report; |
195
|
42
|
50
|
|
|
|
84
|
if ( $formatter->timer ) { |
196
|
0
|
|
|
|
|
0
|
my $start_time = $parser->start_time; |
197
|
0
|
|
|
|
|
0
|
my $end_time = $parser->end_time; |
198
|
0
|
0
|
0
|
|
|
0
|
if ( defined $start_time and defined $end_time ) { |
199
|
0
|
|
|
|
|
0
|
my $elapsed = $end_time - $start_time; |
200
|
0
|
0
|
0
|
|
|
0
|
push @time_report, |
201
|
|
|
|
|
|
|
$self->time_is_hires |
202
|
|
|
|
|
|
|
? sprintf( ' %8d ms', $elapsed * 1000 ) |
203
|
|
|
|
|
|
|
: sprintf( ' %8s s', $elapsed || '<1' ); |
204
|
|
|
|
|
|
|
} |
205
|
0
|
|
|
|
|
0
|
my $start_times = $parser->start_times(); |
206
|
0
|
|
|
|
|
0
|
my $end_times = $parser->end_times(); |
207
|
0
|
|
|
|
|
0
|
my $usr = $end_times->[0] - $start_times->[0]; |
208
|
0
|
|
|
|
|
0
|
my $sys = $end_times->[1] - $start_times->[1]; |
209
|
0
|
|
|
|
|
0
|
my $cusr = $end_times->[2] - $start_times->[2]; |
210
|
0
|
|
|
|
|
0
|
my $csys = $end_times->[3] - $start_times->[3]; |
211
|
0
|
|
|
|
|
0
|
push @time_report, |
212
|
|
|
|
|
|
|
sprintf('(%5.2f usr %5.2f sys + %5.2f cusr %5.2f csys = %5.2f CPU)', |
213
|
|
|
|
|
|
|
$usr, $sys, $cusr, $csys, |
214
|
|
|
|
|
|
|
$usr + $sys + $cusr + $csys); |
215
|
|
|
|
|
|
|
} |
216
|
|
|
|
|
|
|
|
217
|
42
|
|
|
|
|
308
|
return "@time_report"; |
218
|
|
|
|
|
|
|
} |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
1; |