blib/lib/Tapper/Reports/Web/Controller/Tapper/Testplan/Id.pm

filter: Statementstmt 34.4% 30 / 87 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 64.2% 9 / 14 Podpod 75.0% 3 / 4 totaltotal 36.2% 42 / 116 CC 7 SCAR 19.5
CC
7
Cov
31%
gen_testplan_overview
20.0
index
12.0
parse_testrun
6.0
CRAP 7.0
« blib/lib/Tapper/Reports/Web/Util/Filter/Report.pm ↑ Summary blib/lib/Tapper/Reports/Web/Controller/Tapper/Reports.pm »
1 package Tapper::Reports::Web::Controller::Tapper::Testplan::Id;
2 13 our $AUTHORITY = 'cpan:TAPPER';
3 13 $Tapper::Reports::Web::Controller::Tapper::Testplan::Id::VERSION = '5.0.17';
4 13 ▶use parent 'Tapper::Reports::Web::Controller::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 ## no critic (RequireUseStrict)
7 13 ▶use Tapper::Model 'model';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 13 ▶use Tapper::Reports::Web::Util::Testrun;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 13 ▶use Data::DPath 'dpath';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 13 ▶use File::Basename 'basename';
Subroutine BEGIN: called CC=1 SCAR=0.0
12 13 ▶use YAML::Syck 'Load';
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 0 ▶sub auto :Private
Subroutine auto: not called CC=1 SCAR=6.9
15 {
16 0 my ( $self, $c ) = @_;
17 0 $c->forward('/tapper/testplan/id/prepare_navi');
18 13 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20  
21  
22  
23 sub parse_testrun
24 0 ▶{
Subroutine parse_testrun: not called CC=2 SCAR=17.9
Pod documented
25 0 my ($self, $testrun) = @_;
26 0 my $description = $testrun->{description};
27 0 my %testrun;
28  
29 # several places for the root system
30 0 push @{$testrun{image}}, dpath('/preconditions/*/mount[value eq "/"]/../image')->match($description);
31 0 push @{$testrun{image}}, dpath('//root/precondition_type[value eq "autoinstall"]/../name')->match($description);
32 0 push @{$testrun{image}}, dpath('//precondition_type[value eq "autoinstall"]/../name')->match($description);
33  
34 0 push @{$testrun{kernel}}, dpath('/preconditions/*/filename[ value =~ /linux-.*\d+.\d+/]')->match($description);
35 0 push @{$testrun{test}},
36 0 ▶ map { $? ? basename($_) : () }
Branch: 1 branch
BranchTrueFalseTotal
$? ? : 0 0 0
37 dpath('/preconditions/*/precondition_type[ value eq "testprogram"]/../program')->match($description);
38 0 $testrun{shortname} = $description->{shortname};
39 0 return \%testrun;
40 }
41  
42  
43  
44 sub gen_testplan_overview
45 0 ▶{
Subroutine gen_testplan_overview: not called CC=4 SCAR=30.0
Pod documented
46 0 my ($self, $c, $yaml) = @_;
47  
48 0 my @plans;
49 0 eval {
50 0 @plans = Load($yaml);
51 };
52 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
53 0 $c->stash->{error} = "Broken YAML in testplan: $@";
54 0 return [];
55 }
56 0 my @testplan_elements;
57  
58 0 foreach my $plan (@plans) {
59 0 my $type = $plan->{type};
60 0 ▶ if ($type =~ /^(multitest|testrun)$/) { push @testplan_elements, $self->parse_testrun($plan) }
Branch: 1 branch
BranchTrueFalseTotal
if ($type =~ /^(multitest|testrun)$/) 0 0 0
61 }
62 0 return \@testplan_elements;
63 }
64  
65  
66  
67 0 ▶sub index :Path :Args(1)
Subroutine index: not called CC=3 SCAR=24.8
Pod documented
68 {
69 0 my ( $self, $c, $instance_id ) = @_;
70  
71 0 $c->stash->{title} = "Testplan id $instance_id";
72  
73 0 my $inst_res = model('TestrunDB')->resultset('TestplanInstance')->find($instance_id);
74 0 ▶ if (not $inst_res) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($inst_res) 0 0 0
75 0 $c->stash->{error} = "No testplan with id $instance_id";
76 0 return;
77 }
78 0 my $util = Tapper::Reports::Web::Util::Testrun->new();
79 0 my $testruns = $inst_res->testruns;
80 0 my $testrunlist = $util->prepare_testrunlist($testruns);
81  
82 0 $c->stash->{instance}{id} = $inst_res->id;
83 0 ▶ $c->stash->{instance}{name} = $inst_res->name || '[no name]';
Condition0%0/2
$inst_res->name || '[no name]'
l!l
00
MC/DC0%0/1
$inst_res->name || '[no name]'
$inst_res->name
Truth table0%0/2
A
A= $inst_res->name
Aresult
11
00
84 0 $c->stash->{instance}{testruns} = $testrunlist;
85 0 $c->stash->{instance}{plan} = $inst_res->evaluated_testplan;
86 0 $c->stash->{instance}{plan} =~ s/^\n+//m;
87 0 $c->stash->{instance}{plan} =~ s/\n+/\n/m;
88 #$c->stash->{instance}{path} = $inst_res->path;
89 #$c->stash->{instance}{overview} = $self->gen_testplan_overview($c, $c->stash->{instance}{plan});
90 0 $c->stash->{title} = "Testplan id $instance_id, ".$c->stash->{instance}{name};
91 0 return;
92 13 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
93  
94 0 ▶sub prepare_navi :Private
Subroutine prepare_navi: not called CC=1 SCAR=6.9
Pod undocumented
95 {
96 0 my ( $self, $c, $id ) = @_;
97  
98 # When showing testplans by ID no filters are active so we
99 # remove the wrong filters Testplan::prepare_navi already added
100 0 my @navi = grep {$_->{title} ne "Active Filters"} @{$c->stash->{navi}};
101 0 $c->stash->{navi} = \@navi;
102  
103 0 push @{$c->stash->{navi}}, { title => 'Rerun this testplan',
104 href => "/tapper/testplan/$id/rerun",
105 confirm => 'Do you really want to RERUN this test plan?',
106 };
107 0 push @{$c->stash->{navi}}, { title => 'Cancel this testplan',
108 href => "/tapper/testplan/$id/cancel",
109 confirm => 'Do you really want to CANCEL this testplan?',
110 };
111 13 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
112  
113  
114  
115 13 1;
116  
117 __END__
« blib/lib/Tapper/Reports/Web/Util/Filter/Report.pm ↑ Summary blib/lib/Tapper/Reports/Web/Controller/Tapper/Reports.pm »