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

filter: Statementstmt 98.4% 64 / 65 Branchbran 75.0% 15 / 20 Conditioncond 60.0% 3 / 5 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 100% 13 / 13 Podpod 0.0% 0 / 2 totaltotal 88.8% 96 / 108 CC 13 SCAR 14.9
CC
13
Cov
91%
index
7.2
prepare_navi
7.1
BEGIN
1.0
CRAP 4.4
« blib/lib/Tapper/Reports/Web/Controller/Tapper/Preconditions.pm ↑ Summary blib/lib/Tapper/Reports/Web/Util/Filter/Testplan.pm »
1 package Tapper::Reports::Web::Controller::Tapper::Testruns::Id;
2 13 our $AUTHORITY = 'cpan:TAPPER';
3 13 $Tapper::Reports::Web::Controller::Tapper::Testruns::Id::VERSION = '5.0.17';
4 13 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 13 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 13 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 13 ▶use Tapper::Model 'model';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 13 ▶use Tapper::Reports::Web::Util::Report;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 13 ▶use YAML::Syck;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 13 ▶use parent 'Tapper::Reports::Web::Controller::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14  
15 2 ▶sub auto :Private
Subroutine auto: called CC=1 SCAR=0.0
16 {
17 2 my ( $self, $c ) = @_;
18  
19 2 $c->forward('/tapper/testruns/id/prepare_navi');
20 13 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22  
23 2 ▶sub index :Path :Args(1)
Subroutine index: called CC=7 SCAR=19.8
Pod undocumented
24 {
25 2 my ( $self, $c, $testrun_id ) = @_;
26  
27 2 $c->stash->{reportlist_rgt} = {};
28  
29 2 eval {
30 2 $c->stash->{testrun} = $c->model('TestrunDB')->resultset('Testrun')->find($testrun_id);
31 };
32 2 ▶ if ($@ or not $c->stash->{testrun}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@ or not $c->stash->{"testrun"}) 1 1 2
Condition66%2/3
$@ or not $c->stash->{"testrun"}
l!l&&r!l&&!r
011
MC/DC50%1/2
$@ or not $c->stash->{"testrun"}
$@ not $c->stash->{"testrun"}
Truth table66%2/3
A or not(B)
A= $@B= not $c->stash->{"testrun"}
ABresult
1X1
011
000
33 1 $c->response->body(qq(No testrun with id "$testrun_id" found in the database!));
34 1 return;
35 }
36  
37 1 ▶ return unless $c->stash->{testrun}->testrun_scheduling;
Branch: 1 branch
BranchTrueFalseTotal
unless $c->stash->{"testrun"}->testrun_scheduling 0 1 1
38  
39 1 ▶ $c->stash->{time} = $c->stash->{testrun}->starttime_testrun ? "started at ".$c->stash->{testrun}->starttime_testrun : $c->stash->{testrun}->testrun_scheduling->status." // ".($c->stash->{testrun}->starttime_earliest || '');
Branch: 1 branch
BranchTrueFalseTotal
$c->stash->{'testrun'}->starttime_testrun ? : 0 1 1
Condition50%1/2
$c->stash->{'testrun'}->starttime_earliest || ''
l!l
01
MC/DC0%0/1
$c->stash->{'testrun'}->starttime_earliest || ''
$c->stash->{'testrun'}->starttime_earliest
Truth table50%1/2
A
A= $c->stash->{'testrun'}->starttime_earliest
Aresult
11
00
40 1 ▶ $c->stash->{hostname} = $c->stash->{testrun}->testrun_scheduling->host ? $c->stash->{testrun}->testrun_scheduling->host->name : "unknown";
Branch: 1 branch
BranchTrueFalseTotal
$c->stash->{'testrun'}->testrun_scheduling->host ? : 1 0 1
41  
42 1 $c->stash->{title} = "Testrun $testrun_id: ". $c->stash->{testrun}->topic_name . " @ ".$c->stash->{hostname};
43 1 $c->stash->{overview} = $c->forward('/tapper/testruns/get_testrun_overview', [ $c->stash->{testrun} ]);
44  
45 1 my @preconditions_hash = map { $_->precondition_as_hash } $c->stash->{testrun}->ordered_preconditions;
46 1 $YAML::Syck::SortKeys = 1;
47 1 $c->stash->{precondition_string} = YAML::Syck::Dump(@preconditions_hash);
48  
49 1 my $rgt_reports = $c->model('TestrunDB')->resultset('Report')->search
50 (
51 {
52 "reportgrouptestrun.testrun_id" => $testrun_id
53 },
54 { order_by => 'me.id desc',
55 join => [ 'reportgrouptestrun', 'suite'],
56 '+select' => [ 'reportgrouptestrun.testrun_id', 'reportgrouptestrun.primaryreport', 'suite.name', 'suite.type', 'suite.description' ],
57 '+as' => [ 'rgt_id', 'rgt_primary', 'suite_name', 'suite_type', 'suite_description' ],
58 }
59 );
60 1 my $util_report = Tapper::Reports::Web::Util::Report->new();
61  
62 1 $c->stash->{reportlist_rgt} = $util_report->prepare_simple_reportlist($c, $rgt_reports);
63 1 $c->stash->{report} = $c->model('TestrunDB')->resultset('Report')->search
64 (
65 {
66 "reportgrouptestrun.primaryreport" => 1,
67 },
68 {
69 join => [ 'reportgrouptestrun', ]
70 }
71 );
72  
73 1 my @resource_requests = $c->model('TestrunDB')
74 ->resultset('TestrunRequestedResource')
75 ->search({ testrun_id => $testrun_id, selected_resource_id => { '!=', undef } },
76 { 'prefetch' => 'selected_resource' })
77 ->all();
78  
79 0 $c->stash->{resources} = [ map { $_->selected_resource } @resource_requests ];
80  
81 1 $c->stash->{dependencies} = [ $c->stash->{testrun}->depending_testruns->all ];
82 13 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
83  
84 2 ▶sub prepare_navi : Private
Subroutine prepare_navi: called CC=7 SCAR=19.5
Pod undocumented
85 {
86 2 my ( $self, $c, $testrun_id ) = @_;
87  
88 2 my $tr;
89 my $job;
90 2 my $status = 'undefined';
91 2 $tr = $c->model('TestrunDB')->resultset('Testrun')->find($testrun_id);
92 2 ▶ $job = $tr->testrun_scheduling if $tr;
Branch: 1 branch
BranchTrueFalseTotal
if $tr 1 1 2
93 2 ▶ $status = $job->status if $job;
Branch: 1 branch
BranchTrueFalseTotal
if $job 1 1 2
94  
95 $c->stash->{navi} =[
96 {
97 2 ▶ title => "Testruns by date",
Branch: 4 branches
BranchTrueFalseTotal
$status eq 'finished' ? : 0 2 2
$status =~ /^(running|schedule|prepare)$/ ? : 1 1 2
$status eq 'schedule' ? : 1 1 2
$status eq 'prepare' ? : 0 2 2
98 href => "/tapper/testruns/days/2",
99 active => 0,
100 subnavi => [
101 {
102 title => "today",
103 href => "/tapper/testruns/days/1",
104 },
105 {
106 title => "1 week",
107 href => "/tapper/testruns/days/7",
108 },
109 {
110 title => "2 weeks",
111 href => "/tapper/testruns/days/14",
112 },
113 {
114 title => "3 weeks",
115 href => "/tapper/testruns/days/21",
116 },
117 {
118 title => "1 month",
119 href => "/tapper/testruns/days/30",
120 },
121 {
122 title => "2 months",
123 href => "/tapper/testruns/days/60",
124 },
125 ],
126 },
127 {
128 title => "Control",
129 href => "",
130 active => 0,
131 subnavi => [
132 ($status eq 'finished'
133 ? {
134 title => "Rerun",
135 href => "/tapper/testruns/$testrun_id/rerun",
136 confirm => 'Do you really want to RERUN this testrun?',
137 }
138 : ()),
139 ($status =~ /^(running|schedule|prepare)$/
140 ? {
141 title => "Cancel",
142 href => "/tapper/testruns/$testrun_id/cancel",
143 confirm => 'Do you really want to CANCEL this testrun?',
144 }
145 : ()),
146 ($status eq 'schedule'
147 ? {
148 title => "Unschedule",
149 href => "/tapper/testruns/$testrun_id/pause",
150 confirm => 'Do you really want to UNSCHEDULE this testrun?',
151 }
152 : ()),
153 ($status eq 'prepare'
154 ? {
155 title => "Reschedule",
156 href => "/tapper/testruns/$testrun_id/continue",
157 confirm => 'Do you really want to RESCHEDULE this testrun?',
158 }
159 : ()),
160 {
161 title => "Create new testrun",
162 href => "/tapper/testruns/create",
163 },
164 ],
165 },
166 ];
167 13 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
168  
169 13 1;
170  
171 __END__
« blib/lib/Tapper/Reports/Web/Controller/Tapper/Preconditions.pm ↑ Summary blib/lib/Tapper/Reports/Web/Util/Filter/Testplan.pm »