blib/lib/TAP/Formatter/Camelcade.pm

filter: Statementstmt 82.0% 64 / 78 Branchbran 55.5% 10 / 18 Conditioncond 50.0% 3 / 6 MC/DCmcdc 50.0% 2 / 4 Subroutinesub 92.3% 12 / 13 Podpod 75.0% 3 / 4 totaltotal 76.4% 94 / 123 SCAR 28.3
CC
14
Cov
75%
_test_summary
21.8
summary
2.1
_should_show_count
2.0
CRAP 16.9
« blib/lib/TAP/Formatter/Camelcade/Session.pm ↑ Summary blib/lib/TAP/Formatter/Camelcade/MessageBuilder.pm »
1 package TAP::Formatter::Camelcade;
2 19 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 19 ▶use warnings FATAL => 'all';
Subroutine BEGIN: called CC=1 SCAR=0.0
4 19 ▶use base 'TAP::Formatter::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
5 19 ▶use TAP::Formatter::Camelcade::Session;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 19 ▶use TAP::Formatter::Camelcade::MessageBuilder;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 19 ▶use Cwd;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 19 our $VERSION = '0.009';
10  
11 sub open_test{
12 64 ▶ my ( $self, $test, $parser ) = @_;
Subroutine open_test: called CC=1 SCAR=0.0
Pod documented
13  
14 64 my $pwd = getcwd;
15  
16 64 my $location = "myfile://$test";
17 64 $test =~ s/^$pwd[\\\/]//;
18  
19 64 my $session = TAP::Formatter::Camelcade::Session->new({
20 name => $test,
21 formatter => $self,
22 parser => $parser,
23 location => $location
24 });
25  
26 64 $session->header;
27  
28 64 return $session;
29 }
30  
31 #@returns TAP::Formatter::Camelcade::MessageBuilder
32 sub builder{
33 57 ▶ 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 19 ▶ my ($self, $arg_for) = @_;
Subroutine _initialize: called CC=1 SCAR=0.0
43 19 builder->test_reporter_attached->print;
44 19 $self->SUPER::_initialize($arg_for);
45 }
46  
47 #@override
48 sub prepare {
49 19 ▶ my ($self, @tests) = @_;
Subroutine prepare: called CC=1 SCAR=0.0
Pod documented
50 19 $self->SUPER::prepare(@tests);
51 19 builder->testing_started;
52 }
53  
54 #@override
55 sub summary {
56 19 ▶ my ($self, $aggregate, $interrupted) = @_;
Subroutine summary: called CC=2 SCAR=7.4
Pod documented
57 19 ▶ if( $ENV{TAP_FORMATTER_CAMELCADE_TIME} ){
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{'TAP_FORMATTER_CAMELCADE_TIME'}) { } 19 0 19
58 19 $self->_test_summary($aggregate, $interrupted);
59 }
60 else{
61 0 $self->SUPER::summary($aggregate, $interrupted);
62 }
63 19 builder->testing_finished;
64 }
65  
66 19 my $MAX_ERRORS = 5;
67  
68 sub _test_summary{
69 19 ▶ my ($self,
Subroutine _test_summary: called CC=13 SCAR=30.8
70 #@type TAP::Parser::Aggregator
71 $aggregate, $interrupted) = @_;
72 19 my @t = $aggregate->descriptions;
73 19 my $tests = \@t;
74  
75 19 my $runtime = 'TEST_MODE_STATS;'; # $aggregate->elapsed_timestr;
76  
77 19 my $total = $aggregate->total;
78 19 my $passed = $aggregate->passed;
79  
80 # if ( $self->timer ) {
81 # $self->_output( $self->_format_now(), "\n" );
82 # }
83  
84 19 ▶ $self->_failure_output("Test run interrupted!\n")
Branch: 1 branch
BranchTrueFalseTotal
if $interrupted 0 19 19
85 if $interrupted;
86  
87 # TODO: Check this condition still works when all subtests pass but
88 # the exit status is nonzero
89  
90 19 ▶ if ( $aggregate->all_passed ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($aggregate->all_passed) 11 8 19
91 11 $self->_output_success("All tests successful.\n");
92 }
93  
94 # ~TODO option where $aggregate->skipped generates reports
95 19 ▶ if ( $total != $passed or $aggregate->has_problems ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($total != $passed or $aggregate->has_problems) 10 9 19
Condition100%3/3
$total != $passed or $aggregate->has_problems
l!l&&r!l&&!r
829
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 10 $self->_output("\nTest Summary Report");
97 10 $self->_output("\n-------------------\n");
98 10 for my $test (@$tests) {
99 55 $self->_printed_summary_header(0);
100 55 my ($parser) = $aggregate->parsers($test);
101 55 $self->_output_summary_failure(
102 'failed',
103 [ ' Failed test: ', ' Failed tests: ' ],
104 $test, $parser
105 );
106 55 $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 55 ▶ if ( my $exit = $parser->exit ) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $exit = $parser->exit) { } 20 35 55
elsif (my $wait = $parser->wait) { } 0 35 35
115 20 $self->_summary_test_header( $test, $parser );
116 20 $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 55 ▶ if ( my @errors = $parser->parse_errors ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@errors) = $parser->parse_errors) 0 55 55
124 0 my $explain;
125 0 ▶ if ( @errors > $MAX_ERRORS && !$self->errors ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@errors > $MAX_ERRORS and not $self->errors) 0 0 0
Condition0%0/3
@errors > $MAX_ERRORS and not $self->errors
!ll&&!rl&&r
000
MC/DC0%0/2
@errors > $MAX_ERRORS and not $self->errors
@errors > $MAX_ERRORS not $self->errors
Truth table0%0/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 0 $self->_summary_test_header( $test, $parser );
134 0 $self->_failure_output(
135 sprintf " Parse errors: %s\n",
136 shift @errors
137 );
138 0 for my $error (@errors) {
139 0 my $spaces = ' ' x 16;
140 0 $self->_failure_output("$spaces$error\n");
141 }
142 0 ▶ $self->_failure_output($explain) if $explain;
Branch: 1 branch
BranchTrueFalseTotal
if $explain 0 0 0
143 }
144 }
145 }
146 19 my $files = @$tests;
147 19 $self->_output("Files=$files, Tests=$total, $runtime\n");
148 19 my $status = $aggregate->get_status;
149 19 $self->_output("Result: $status\n");
150 }
151  
152 19 1;
153  
154 # ABSTRACT: Converts test events from TAP::Harness to the TeamCity format
« blib/lib/TAP/Formatter/Camelcade/Session.pm ↑ Summary blib/lib/TAP/Formatter/Camelcade/MessageBuilder.pm »