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