blib/lib/TAP/Formatter/Console/Session.pm

filter: Statementstmt 86.6% 78 / 90 Branchbran 82.3% 28 / 34 Conditioncond 74.2% 26 / 35 MC/DCmcdc 37.5% 6 / 16 Subroutinesub 94.1% 16 / 17 Podpod n/a totaltotal 80.2% 154 / 192 CC 32 SCAR 23.9
CC
32
Cov
83%
__ANON__
24.1
__ANON__
7.2
__ANON__
3.0
CRAP 10.9
« blib/lib/TAP/Parser/SourceHandler/Executable.pm ↑ Summary blib/lib/TAP/Parser/IteratorFactory.pm »
1 package TAP::Formatter::Console::Session;
2  
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 ▶use base 'TAP::Formatter::Session';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 3 my @ACCESSOR;
9  
10 3 ▶BEGIN {
Subroutine BEGIN: called CC=2 SCAR=6.9
11 3 my @CLOSURE_BINDING = qw( header result clear_for_close close_test );
12  
13 3 for my $method (@CLOSURE_BINDING) {
14 3 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
15 84 ▶ *$method = sub {
Subroutine __ANON__: called CC=2 SCAR=7.1
16 84 my $self = shift;
17 84 ▶ return ( $self->{_closures} ||= $self->_closures )->{$method}
Condition66%2/3
$self->{"_closures"} ||= $self->_closures
l!l&&r!l&&!r
69150
MC/DC0%0/2
$self->{"_closures"} ||= $self->_closures
$self->{"_closures"} $self->_closures
Truth table66%2/3
A ||= B
A= $self->{"_closures"}B= $self->_closures
ABresult
1X1
011
000
18 ->(@_);
19 12 };
20 }
21 }
22  
23 =head1 NAME
24  
25 TAP::Formatter::Console::Session - Harness output delegate for default console output
26  
27 =head1 VERSION
28  
29 Version 3.52
30  
31 =cut
32  
33 3 our $VERSION = '3.52';
34  
35 =head1 DESCRIPTION
36  
37 This provides console orientated output formatting for TAP::Harness.
38  
39 =cut
40  
41 15 ▶sub _get_output_result {
Subroutine _get_output_result: called CC=2 SCAR=6.9
42 15 my $self = shift;
43  
44 my @color_map = (
45 19 ▶ { test => sub { $_->is_test && !$_->is_ok },
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$_->is_test and not $_->is_ok 8 11 19
46 colors => ['red'],
47 },
48 17 ▶ { test => sub { $_->is_test && $_->has_skip },
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$_->is_test and $_->has_skip 6 11 17
49 colors => [
50 'white',
51 'on_blue'
52 ],
53 },
54 17 ▶ { test => sub { $_->is_test && $_->has_todo },
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$_->is_test and $_->has_todo 6 11 17
55 15 colors => ['yellow'],
56 },
57 );
58  
59 15 my $formatter = $self->formatter;
60 15 my $parser = $self->parser;
61  
62 return $formatter->_colorizer
63 19 ▶ ? sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
64 19 my $result = shift;
65 19 for my $col (@color_map) {
66 53 local $_ = $result;
67 53 ▶ if ( $col->{test}->() ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($col->{"test"}->()) 2 51 53
68 2 $formatter->_set_colors( @{ $col->{colors} } );
69 2 last;
70 }
71 }
72 19 $formatter->_output( $self->_format_for_output($result) );
73 19 $formatter->_set_colors('reset');
74 }
75 3 ▶ : sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
76 3 $formatter->_output( $self->_format_for_output(shift) );
77 15 ▶ };
Branch: 1 branch
BranchTrueFalseTotal
$formatter->_colorizer ? : 6 9 15
78 }
79  
80 15 ▶sub _closures {
Subroutine _closures: called CC=1 SCAR=0.1
81 15 my $self = shift;
82  
83 15 my $parser = $self->parser;
84 15 my $formatter = $self->formatter;
85 15 my $pretty = $formatter->_format_name( $self->name );
86 15 my $show_count = $self->show_count;
87  
88 15 my $really_quiet = $formatter->really_quiet;
89 15 my $quiet = $formatter->quiet;
90 15 my $verbose = $formatter->verbose;
91 15 my $directives = $formatter->directives;
92 15 my $failures = $formatter->failures;
93 15 my $comments = $formatter->comments;
94  
95 15 my $output_result = $self->_get_output_result;
96  
97 15 my $output = '_output';
98 15 my $plan = '';
99 15 my $newline_printed = 0;
100  
101 15 my $last_status_printed = 0;
102  
103 return {
104 15 ▶ header => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
105 15 ▶ $formatter->_output($pretty)
Branch: 1 branch
BranchTrueFalseTotal
unless $really_quiet 12 3 15
106 unless $really_quiet;
107 },
108  
109 54 ▶ result => sub {
Subroutine __ANON__: called CC=18 SCAR=31.8
110 54 my $result = shift;
111  
112 54 ▶ if ( $result->is_bailout ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($result->is_bailout) 0 54 54
113 0 $formatter->_failure_output(
114 "Bailout called. Further testing stopped: "
115 . $result->explanation
116 . "\n" );
117 }
118  
119 54 ▶ return if $really_quiet;
Branch: 1 branch
BranchTrueFalseTotal
if $really_quiet 15 39 54
120  
121 39 my $is_test = $result->is_test;
122  
123 # These are used in close_test - but only if $really_quiet
124 # is false - so it's safe to only set them here unless that
125 # relationship changes.
126  
127 39 ▶ if ( !$plan ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($plan) 10 29 39
128 10 ▶ my $planned = $parser->tests_planned || '?';
Condition50%1/2
$parser->tests_planned || '?'
l!l
100
MC/DC0%0/1
$parser->tests_planned || '?'
$parser->tests_planned
Truth table50%1/2
A
A= $parser->tests_planned
Aresult
11
00
129 10 $plan = "/$planned ";
130 }
131  
132 39 ▶ if ( $show_count and $is_test ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($show_count and $is_test) 0 39 39
Condition33%1/3
$show_count and $is_test
!ll&&!rl&&r
3900
MC/DC0%0/2
$show_count and $is_test
$show_count $is_test
Truth table33%1/3
A and B
A= $show_countB= $is_test
ABresult
0X0
100
111
133 0 my $now = CORE::time;
134  
135 # Print status roughly once per second.
136 # We will always get the first number as a side effect of
137 # $last_status_printed starting with the value 0, which $now
138 # will never be. (Unless someone sets their clock to 1970)
139 0 ▶ if ( $last_status_printed != $now ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($last_status_printed != $now) 0 0 0
140 0 my $number = $result->number;
141 0 $output = $formatter->_get_output_method($parser);
142 0 $formatter->$output("\r$pretty$number$plan");
143 0 $last_status_printed = $now;
144 }
145 }
146  
147 39 ▶ if (!$quiet
Branch: 1 branch
BranchTrueFalseTotal
if (not $quiet and $verbose || $is_test && $failures && !$result->is_ok || $comments && $result->is_comment || $directives && $result->has_directive) 22 17 39
Condition87%21/24
not $quiet and $verbose || $is_test && $failures && !$result->is_ok || $comments && $result->is_comment || $directives && $result->has_directive
!ll&&!rl&&r
9822
$verbose or $is_test and $failures and not $result->is_ok or $comments and $result->is_comment or $directives and $result->has_directive
l!l&&r!l&&!r
2028
$verbose or $is_test and $failures and not $result->is_ok or $comments and $result->is_comment
l!l&&r!l&&!r
20010
$verbose or $is_test and $failures and not $result->is_ok
l!l&&r!l&&!r
19110
$is_test and $failures and not $result->is_ok
!ll&&!rl&&r
911
$is_test and $failures
!ll&&!rl&&r
632
$comments and $result->is_comment
!ll&&!rl&&r
1000
$directives and $result->has_directive
!ll&&!rl&&r
622
MC/DC66%6/9
not $quiet and $verbose || $is_test && $failures && !$result->is_ok || $comments && $result->is_comment || $directives && $result->has_directive
not $quiet $verbose $is_test $failures not $result->is_ok $comments $result->is_comment $directives $result->has_directive
Truth table33%8/24
not(A) and B or C and D and not(E) or F and G or H and I
A= not $quietB= $verboseC= $is_testD= $failuresE= not $result->is_okF= $commentsG= $result->is_commentH= $directivesI= $result->has_directive
ABCDEFGHIresult
0XXXXXXXX0
100XX0X0X0
100XX0X100
100XX100X0
100XX10100
1010X0X0X0
1010X0X100
1010X100X0
1010X10100
101100X0X0
101100X100
10110100X0
1011010100
11XXXXXXX1
10111XXXX1
100XX11XX1
1010X11XX1
1011011XX1
100XX0X111
100XX10111
1010X0X111
1010X10111
101100X111
1011010111
148 && ( $verbose
149 || ( $is_test && $failures && !$result->is_ok )
150 || ( $comments && $result->is_comment )
151 || ( $directives && $result->has_directive ) )
152 )
153 {
154 22 ▶ unless ($newline_printed) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($newline_printed) 8 14 22
155 8 $formatter->_output("\n");
156 8 $newline_printed = 1;
157 }
158 22 $output_result->($result);
159 22 $formatter->_output("\n");
160 }
161 },
162  
163 0 ▶ clear_for_close => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
164 0 my $spaces
165 = ' ' x length( '.' . $pretty . $plan . $parser->tests_run );
166 0 $formatter->$output("\r$spaces");
167 },
168  
169 15 ▶ close_test => sub {
Subroutine __ANON__: called CC=6 SCAR=19.7
170 15 ▶ if ( $show_count && !$really_quiet ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($show_count and not $really_quiet) 0 15 15
Condition33%1/3
$show_count and not $really_quiet
!ll&&!rl&&r
1500
MC/DC0%0/2
$show_count and not $really_quiet
$show_count not $really_quiet
Truth table33%1/3
A and not(B)
A= $show_countB= not $really_quiet
ABresult
0X0
100
111
171 0 $self->clear_for_close;
172 0 $formatter->$output("\r$pretty");
173 }
174  
175 # Avoid circular references
176 15 $self->parser(undef);
177 15 $self->{_closures} = {};
178  
179 15 ▶ return if $really_quiet;
Branch: 1 branch
BranchTrueFalseTotal
if $really_quiet 3 12 15
180  
181 12 ▶ if ( my $skip_all = $parser->skip_all ) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $skip_all = $parser->skip_all) { } 0 12 12
elsif ($parser->has_problems) { } 6 6 12
182 0 $formatter->_output("skipped: $skip_all\n");
183 }
184 elsif ( $parser->has_problems ) {
185 6 $self->_output_test_failure($parser);
186 }
187 else {
188 6 my $time_report = $self->time_report($formatter, $parser);
189 6 $formatter->_output_success( $self->_make_ok_line($time_report) );
190 }
191 },
192 15 };
193 }
194  
195 =head2 C<< clear_for_close >>
196  
197 =head2 C<< close_test >>
198  
199 =head2 C<< header >>
200  
201 =head2 C<< result >>
202  
203 =cut
204  
205 3 1;
« blib/lib/TAP/Parser/SourceHandler/Executable.pm ↑ Summary blib/lib/TAP/Parser/IteratorFactory.pm »