BambooExtended/Session.pm

filter: Statementstmt 27.4% 14 / 51 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 50.0% 4 / 8 Podpod 100% 2 / 2 totaltotal 22.2% 20 / 90 CC 12 SCAR 38.2
CC
12
Cov
19%
_fail_reasons
90.0
close_test
12.0
_initialize
6.0
CRAP 45.5
« BambooExtended.pm ↑ Summary
1 package TAP::Formatter::BambooExtended::Session;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use parent qw(TAP::Formatter::Console::Session);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use TAP::Parser::ResultFactory ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 our $VERSION = '1.01';
11  
12 0 ▶sub _initialize {
Subroutine _initialize: not called CC=2 SCAR=17.9
13 0 my ($self, $arg_for) = @_;
14  
15 # variables that we use for ourselves
16 0 $self->{'_results'} = [];
17  
18 0 ▶ return $self->SUPER::_initialize($arg_for || {});
Condition0%0/2
$arg_for || {}
l!l
00
MC/DC0%0/1
$arg_for || {}
$arg_for
Truth table0%0/2
A
A= $arg_for
Aresult
11
00
19 }
20  
21 0 ▶sub result {
Subroutine result: not called CC=1 SCAR=6.9
Pod documented
22 0 my ($self, $result) = @_;
23 0 push(@{$self->{'_results'}}, $result);
24 0 return;
25 }
26  
27 0 ▶sub close_test {
Subroutine close_test: not called CC=3 SCAR=24.8
Pod documented
28 0 my $self = shift;
29 0 my $parser = $self->parser();
30  
31 my $results = {
32 'description' => $self->name(),
33 'start_time' => $parser->start_time(),
34 'end_time' => $parser->end_time(),
35 'tests_run' => $parser->tests_run(),
36 'failed' => scalar($parser->failed()),
37 'parse_errors' => scalar($parser->parse_errors()),
38 0 'results' => $self->{'_results'},
39 };
40  
41 0 my @fail_reasons = _fail_reasons($parser);
42 0 ▶ if (@fail_reasons) {
Branch: 1 branch
BranchTrueFalseTotal
if (@fail_reasons) { } 0 0 0
43 0 print STDERR "FAIL " . $self->name() . "\n" . join("", map { " $_\n" } @fail_reasons);
44 } else {
45 0 print { $self->formatter->stdout() } "PASS " . $self->name() . "\n";
46 }
47  
48 0 ▶ my $is_ok = (scalar(@fail_reasons) ? 'not ok' : 'ok');
Branch: 1 branch
BranchTrueFalseTotal
scalar @fail_reasons ? : 0 0 0
49 0 unshift(@{$self->{'_results'}}, TAP::Parser::ResultFactory->make_result({
50 'ok' => $is_ok,
51 0 'explanation' => join("", map { " $_\n" } @fail_reasons),
52 'directive' => '',
53 'type' => 'test',
54 0 'test_num' => scalar(@{$self->{'_results'}}),
55 'description' => $self->name(),
56 0 'raw' => "${is_ok} - ${\$self->name()}",
57 }));
58  
59 0 $self->formatter->add_test_results($results);
60 0 return;
61 }
62  
63 0 ▶sub _fail_reasons {
Subroutine _fail_reasons: not called CC=9 SCAR=45.0
64 0 my $parser = shift;
65 0 my @reasons = ();
66  
67 0 ▶ if ($parser->failed()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parser->failed) 0 0 0
68 0 push(@reasons, "failed tests (" . join(', ', $parser->failed()) . ")");
69 }
70 0 ▶ if ($parser->todo_passed()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parser->todo_passed) 0 0 0
71 0 push(@reasons, "unexpected TODO passed (" . join(', ', $parser->todo_passed()) . ")");
72 }
73 0 ▶ if ($parser->parse_errors()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parser->parse_errors) 0 0 0
74 0 push(@reasons, "parse errors (" . join(', ', $parser->parse_errors()) . ")");
75 }
76 0 ▶ if (!@reasons && $parser->exit() != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (not @reasons and $parser->exit != 0) 0 0 0
Condition0%0/3
not @reasons and $parser->exit != 0
!ll&&!rl&&r
000
MC/DC0%0/2
not @reasons and $parser->exit != 0
not @reasons $parser->exit != 0
Truth table0%0/3
not(A) and B
A= not @reasonsB= $parser->exit != 0
ABresult
0X0
100
111
77 0 push(@reasons, "non-zero exit code (" . $parser->exit(). ")");
78 }
79 0 ▶ if (!@reasons && $parser->has_problems()) {
Branch: 1 branch
BranchTrueFalseTotal
if (not @reasons and $parser->has_problems) 0 0 0
Condition0%0/3
not @reasons and $parser->has_problems
!ll&&!rl&&r
000
MC/DC0%0/2
not @reasons and $parser->has_problems
not @reasons $parser->has_problems
Truth table0%0/3
not(A) and B
A= not @reasonsB= $parser->has_problems
ABresult
0X0
100
111
80 0 push(@reasons, "unknown reason (probably some bug encountered)");
81 }
82  
83 0 ▶ return wantarray ? @reasons : \@reasons;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
84 }
85  
86 1 1;
« BambooExtended.pm ↑ Summary