blib/lib/TAP/Formatter/Camelcade.pm

filter: Statementstmt 89.7% 70 / 78 Branchbran 72.2% 13 / 18 Conditioncond 66.6% 4 / 6 MC/DCmcdc 50.0% 2 / 4 Subroutinesub 92.3% 12 / 13 Podpod 75.0% 3 / 4 totaltotal 84.5% 104 / 123 CC 14 SCAR 20.6
CC
14
Cov
85%
_test_summary
14.4
summary
2.1
_should_show_count
2.0
CRAP 7.8
↑ Summary blib/lib/TAP/Formatter/Camelcade/Session.pm »
1 package TAP::Formatter::Camelcade;
2 20 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 20 ▶use warnings FATAL => 'all';
Subroutine BEGIN: called CC=1 SCAR=0.0
4 20 ▶use base 'TAP::Formatter::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
5 20 ▶use TAP::Formatter::Camelcade::Session;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 20 ▶use TAP::Formatter::Camelcade::MessageBuilder;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 20 ▶use Cwd;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 20 our $VERSION = '2021.1';
10  
11 sub open_test{
12 68 ▶ my ( $self, $test, $parser ) = @_;
Subroutine open_test: called CC=1 SCAR=0.0
Pod documented
13  
14 68 my $pwd = getcwd;
15  
16 68 my $location = "myfile://$test";
17 68 $test =~ s/^$pwd[\\\/]//;
18  
19 68 my $session = TAP::Formatter::Camelcade::Session->new({
20 name => $test,
21 formatter => $self,
22 parser => $parser,
23 location => $location
24 });
25  
26 68 $session->header;
27  
28 68 return $session;
29 }
30  
31 #@returns TAP::Formatter::Camelcade::MessageBuilder
32 sub builder{
33 60 ▶ return 'TAP::Formatter::Camelcade::MessageBuilder';
Subroutine builder: called CC=1 SCAR=0.0
Pod undocumented
34 }
35  
36 sub _should_show_count {
37 0 ▶ return 0;
Subroutine _should_show_count: not called CC=1 SCAR=6.9
38 }
39  
40 #@override
41 sub _initialize {
42 20 ▶ my ($self, $arg_for) = @_;
Subroutine _initialize: called CC=1 SCAR=0.0
43 20 builder->test_reporter_attached->print;
44 20 $self->SUPER::_initialize($arg_for);
45 }
46  
47 #@override
48 sub prepare {
49 20 ▶ my ($self, @tests) = @_;
Subroutine prepare: called CC=1 SCAR=0.0
Pod documented
50 20 $self->SUPER::prepare(@tests);
51 20 builder->testing_started;
52 }
53  
54 #@override
55 sub summary {
56 20 ▶ my ($self, $aggregate, $interrupted) = @_;
Subroutine summary: called CC=2 SCAR=7.4
Pod documented
57 20 ▶ if( $ENV{TAP_FORMATTER_CAMELCADE_TIME} ){
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{'TAP_FORMATTER_CAMELCADE_TIME'}) { } 20 0 20
58 20 $self->_test_summary($aggregate, $interrupted);
59 }
60 else{
61 0 $self->SUPER::summary($aggregate, $interrupted);
62 }
63 20 builder->testing_finished;
64 }
65  
66 20 my $MAX_ERRORS = 5;
67  
68 sub _test_summary{
69 20 ▶ my ($self,
Subroutine _test_summary: called CC=13 SCAR=26.7
70 #@type TAP::Parser::Aggregator
71 $aggregate, $interrupted) = @_;
72 20 my @t = $aggregate->descriptions;
73 20 my $tests = \@t;
74  
75 20 my $runtime = 'TEST_MODE_STATS;'; # $aggregate->elapsed_timestr;
76  
77 20 my $total = $aggregate->total;
78 20 my $passed = $aggregate->passed;
79  
80 # if ( $self->timer ) {
81 # $self->_output( $self->_format_now(), "\n" );
82 # }
83  
84 20 ▶ $self->_failure_output("Test run interrupted!\n")
Branch: 1 branch
BranchTrueFalseTotal
if $interrupted 0 20 20
85 if $interrupted;
86  
87 # TODO: Check this condition still works when all subtests pass but
88 # the exit status is nonzero
89  
90 20 ▶ if ( $aggregate->all_passed ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($aggregate->all_passed) 11 9 20
91 11 $self->_output_success("All tests successful.\n");
92 }
93  
94 # ~TODO option where $aggregate->skipped generates reports
95 20 ▶ if ( $total != $passed or $aggregate->has_problems ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($total != $passed or $aggregate->has_problems) 11 9 20
Condition100%3/3
$total != $passed or $aggregate->has_problems
l!l&&r!l&&!r
839
MC/DC100%2/2
$total != $passed or $aggregate->has_problems
$total != $passed $aggregate->has_problems
Truth table100%3/3
A or B
A= $total != $passedB= $aggregate->has_problems
ABresult
1X1
011
000
96 11 $self->_output("\nTest Summary Report");
97 11 $self->_output("\n-------------------\n");
98 11 for my $test (@$tests) {
99 59 $self->_printed_summary_header(0);
100 59 my ($parser) = $aggregate->parsers($test);
101 59 $self->_output_summary_failure(
102 'failed',
103 [ ' Failed test: ', ' Failed tests: ' ],
104 $test, $parser
105 );
106 59 $self->_output_summary_failure(
107 'todo_passed',
108 " TODO passed: ", $test, $parser
109 );
110  
111 # ~TODO this cannot be the default
112 #$self->_output_summary_failure( 'skipped', " Tests skipped: " );
113  
114 59 ▶ if ( my $exit = $parser->exit ) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $exit = $parser->exit) { } 24 35 59
elsif (my $wait = $parser->wait) { } 0 35 35
115 24 $self->_summary_test_header( $test, $parser );
116 24 $self->_failure_output(" Non-zero exit status: $exit\n");
117 }
118 elsif ( my $wait = $parser->wait ) {
119 0 $self->_summary_test_header( $test, $parser );
120 0 $self->_failure_output(" Non-zero wait status: $wait\n");
121 }
122  
123 59 ▶ if ( my @errors = $parser->parse_errors ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@errors) = $parser->parse_errors) 4 55 59
124 4 my $explain;
125 4 ▶ if ( @errors > $MAX_ERRORS && !$self->errors ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@errors > $MAX_ERRORS and not $self->errors) 0 4 4
Condition33%1/3
@errors > $MAX_ERRORS and not $self->errors
!ll&&!rl&&r
400
MC/DC0%0/2
@errors > $MAX_ERRORS and not $self->errors
@errors > $MAX_ERRORS not $self->errors
Truth table33%1/3
A and not(B)
A= @errors > $MAX_ERRORSB= not $self->errors
ABresult
0X0
100
111
126 0 $explain
127 = "Displayed the first $MAX_ERRORS of "
128 . scalar(@errors)
129 . " TAP syntax errors.\n"
130 . "Re-run prove with the -p option to see them all.\n";
131 0 splice @errors, $MAX_ERRORS;
132 }
133 4 $self->_summary_test_header( $test, $parser );
134 4 $self->_failure_output(
135 sprintf " Parse errors: %s\n",
136 shift @errors
137 );
138 4 for my $error (@errors) {
139 0 my $spaces = ' ' x 16;
140 0 $self->_failure_output("$spaces$error\n");
141 }
142 4 ▶ $self->_failure_output($explain) if $explain;
Branch: 1 branch
BranchTrueFalseTotal
if $explain 0 4 4
143 }
144 }
145 }
146 20 my $files = @$tests;
147 20 $self->_output("Files=$files, Tests=$total, $runtime\n");
148 20 my $status = $aggregate->get_status;
149 20 $self->_output("Result: $status\n");
150 }
151  
152 20 1;
153  
154 # ABSTRACT: Converts test events from TAP::Harness to the TeamCity format
↑ Summary blib/lib/TAP/Formatter/Camelcade/Session.pm »