blib/lib/Tapper/CLI/Testrun.pm

filter: Statementstmt 67.0% 270 / 403 Branchbran 51.7% 87 / 168 Conditioncond 41.6% 25 / 60 MC/DCmcdc 16.6% 6 / 36 Subroutinesub 95.8% 23 / 24 Podpod 100% 19 / 19 totaltotal 60.5% 430 / 710 CC 123 SCAR 34.2
CC
123
Cov
61%
testrun_update
71.5
b_create_testrun
56.5
b_list_testrun
31.1
CRAP 30.5
« blib/lib/Tapper/CLI/Base.pm ↑ Summary blib/lib/Tapper/CLI/Cobbler.pm »
1 package Tapper::CLI::Testrun;
2 73 our $AUTHORITY = 'cpan:TAPPER';
3 73 $Tapper::CLI::Testrun::VERSION = '5.0.8';
4  
5 73 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 73 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 73 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 73 ▶use feature qw/ say /;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 73 ▶use English qw/ -no_match_vars /;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 # list limit default value
12 73 my $i_limit_default = 50;
13  
14  
15 2 ▶sub b_print_single_testrun {
Subroutine b_print_single_testrun: called CC=10 SCAR=25.5
Pod documented
16  
17 2 my ( $or_testrun ) = @_;
18  
19 2 print "\n";
20 2 printf "%17s: %s\n", 'Id' , $or_testrun->id;
21 2 printf "%17s: %s\n", 'Topic', $or_testrun->topic_name;
22  
23 2 ▶ if ( $or_testrun->shortname ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($or_testrun->shortname) 2 0 2
24 2 printf "%17s: %s\n", 'Shortname', $or_testrun->shortname;
25 }
26 2 ▶ if ( $or_testrun->testrun_scheduling ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($or_testrun->testrun_scheduling) { } 1 1 2
27  
28 1 require Tapper::Cmd::Testrun;
29 1 my $or_cmd = Tapper::Cmd::Testrun->new();
30 1 my $hr_testrun_details = $or_cmd->status($or_testrun->id);
31 1 printf "%17s: %s\n", 'State', $hr_testrun_details->{status};
32 1 printf "%17s: %s\n", 'Queue', $or_testrun->testrun_scheduling->queue->name;
33  
34 1 ▶ if ( $or_testrun->testrun_scheduling->status eq 'schedule' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($or_testrun->testrun_scheduling->status eq 'schedule') { } 1 0 1
35 1 ▶ if ( $or_testrun->testrun_scheduling->requested_hosts->count ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($or_testrun->testrun_scheduling->requested_hosts->count) 1 0 1
36 1 printf "%17s: %s\n", q#Requested Host's#, join ",", $or_testrun->testrun_scheduling->requested_hosts->related_resultset('host')->get_column('name')->all;
37 }
38 }
39 else {
40 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($or_testrun->testrun_scheduling->host and $or_testrun->testrun_scheduling->host->name) 0 0 0
Condition0%0/3
$or_testrun->testrun_scheduling->host and $or_testrun->testrun_scheduling->host->name
!ll&&!rl&&r
000
MC/DC0%0/2
$or_testrun->testrun_scheduling->host and $or_testrun->testrun_scheduling->host->name
$or_testrun->testrun_scheduling->host $or_testrun->testrun_scheduling->host->name
Truth table0%0/3
A and B
A= $or_testrun->testrun_scheduling->hostB= $or_testrun->testrun_scheduling->host->name
ABresult
0X0
100
111
41 $or_testrun->testrun_scheduling->host &&
42 $or_testrun->testrun_scheduling->host->name
43 ) {
44 0 printf "%17s: %s\n", 'Used Host', $or_testrun->testrun_scheduling->host->name;
45 }
46 }
47  
48 1 ▶ printf "%17s: %s\n", 'Auto rerun', $or_testrun->testrun_scheduling->auto_rerun ? 'yes' : 'no';
Branch: 1 branch
BranchTrueFalseTotal
$or_testrun->testrun_scheduling->auto_rerun ? : 0 1 1
49  
50 }
51 else {
52 1 printf "%17s: %s\n", q##, 'Old testrun without scheduling information';
53 }
54  
55 2 ▶ if ( $or_testrun->notes ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($or_testrun->notes) 2 0 2
56 2 printf "%17s: %s\n", 'Notes', $or_testrun->notes;
57 }
58  
59 2 printf "%17s: ", q#Precondition Id's#;
60 2 ▶ if ( my @a_preconditions = $or_testrun->ordered_preconditions ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@a_preconditions) = $or_testrun->ordered_preconditions) { } 2 0 2
61 2 say join ", ", map {$_->id} @a_preconditions;
62 }
63 else {
64 0 say 'None';
65 }
66  
67 2 return 1;
68  
69 }
70  
71  
72 2 ▶sub b_print_testruns {
Subroutine b_print_testruns: called CC=3 SCAR=11.3
Pod documented
73  
74 2 my ( $or_testruns ) = @_;
75  
76 2 ▶ if ( $or_testruns->isa('DBIx::Class::ResultSet') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($or_testruns->isa('DBIx::Class::ResultSet')) { } 2 0 2
77 2 for my $or_testrun ( $or_testruns->all ) {
78 2 b_print_single_testrun( $or_testrun );
79 }
80 }
81 else {
82 0 b_print_single_testrun( $or_testruns );
83 }
84 2 print "\n";
85  
86 2 return 1;
87  
88 }
89  
90  
91 3 ▶sub ar_get_list_testrun_parameters {
Subroutine ar_get_list_testrun_parameters: called CC=1 SCAR=0.0
Pod documented
92 return [
93 3 [ 'id|i=i@' , 'list particular testruns', 'Can be given multiple times.', ],
94 [ 'finished|f', 'list finished testruns, OR combined with other state filters', ],
95 [ 'running|r' , 'list running testruns, OR combined with other state filters', ],
96 [ 'schedule|s', 'list scheduled testruns, OR combined with other state filters', ],
97 [ 'prepare|p' , 'list testruns not yet in any scheduling queue, OR combined with other state filters', ],
98 [ 'queue|q=s@', 'list testruns assigned to this queue, OR combined with other queues, AND combined with other filters', ],
99 [ 'host|h=s@' , 'list testruns assigned to this queue, OR combined with other hosts, AND combined with other filters', ],
100 [ 'limit|l=i' , "limit the number of testruns (default = $i_limit_default). A value smaller than 1 deactivates the limit.", ],
101 [ 'verbose|v' , 'print all output, without only print ids', ],
102 [ 'help|?' , 'Print this help message and exit.', ],
103 ];
104 }
105  
106  
107 1 ▶sub ar_get_rerun_testrun_parameters {
Subroutine ar_get_rerun_testrun_parameters: called CC=1 SCAR=0.0
Pod documented
108 return [
109 1 [ 'id|i=i@' , 'rerun particular testruns', 'Can be given multiple times.', ],
110 [ 'notes|n=s' , 'add a description for new testruns', ],
111 [ 'verbose|v' , 'print all output, without only print ids', ],
112 [ 'help|?' , 'Print this help message and exit.', ],
113 ];
114 }
115  
116  
117 1 ▶sub ar_get_delete_testrun_parameters {
Subroutine ar_get_delete_testrun_parameters: called CC=1 SCAR=0.0
Pod documented
118 return [
119 1 [ 'id|i=i@' , 'delete particular testruns', 'Can be given multiple times.', ],
120 [ 'force|f' , 'really execute the command', ],
121 [ 'verbose|v', 'print all output, without only print ids', ],
122 [ 'help|?' , 'Print this help message and exit.', ],
123 ];
124 }
125  
126  
127 10 ▶sub ar_get_create_testrun_parameters {
Subroutine ar_get_create_testrun_parameters: called CC=1 SCAR=0.0
Pod documented
128 return [
129 [
130 10 'macroprecond|m=s',
131 'use this macro precondition file',
132 ],[
133 'precondition|p=i@',
134 'assigned precondition ids',
135 ],[
136 'owner|o=s',
137 'default=$USER; user login name',
138 ],[
139 'topic|t=s',
140 'default=Misc; one of: Kernel, Xen, KVM, Hardware, Distribution, Benchmark, Software, Misc',
141 ],[
142 'queue|q=s',
143 'default=AdHoc',
144 ],[
145 'notes|n=s',
146 'notes',
147 ],[
148 'rerun_on_error=i',
149 'retry this testrun this many times if an error occurs',
150 ],[
151 'shortname|s=s',
152 'shortname',
153 ],[
154 'earliest|e=s',
155 q#default=now; don't start testrun before this time (format: YYYY-MM-DD hh:mm:ss or now)#,
156 ],[
157 'requested_host|rh=s@',
158 'String; name one possible host for this testrequest;',
159 'multiple requested hosts are OR evaluated, i.e. each is appropriate',
160 ],[
161 'requested_feature|rf=s@',
162 'description of one requested feature of a matching host for this testrequest;',
163 'multiple requested features are AND evaluated, i.e. each must fit;',
164 'not evaluated if a matching requested host is found already',
165 ],[
166 'notify:s',
167 q#create a notification for when the testrun is finished, possibly with filter for 'fail' or 'success'#,
168 ],[
169 'wait_after_tests',
170 'default=0; wait after testrun for human investigation',
171 ],[
172 'verbose|v',
173 'some more informational output',
174 ],[
175 'dryrun',
176 'default=0; only print the preconditions to stdout and then exit',
177 ],[
178 'auto_rerun',
179 'default=0; put this testrun into db again when it is chosen by scheduler',
180 ],[
181 'priority',
182 'This is a very important testrun that should bypass scheduling and not wait for others',
183 ],[
184 'D=s%',
185 'Define a key=value pair used in macro preconditions',
186 ],[
187 'help|?',
188 'Print this help message and exit',
189 ],
190 ];
191 }
192  
193  
194 1 ▶sub create_macro_preconditions {
Subroutine create_macro_preconditions: called CC=2 SCAR=7.3
Pod documented
195  
196 1 my ( $hr_options ) = @_;
197  
198 1 my $hr_d = $hr_options->{D}; # options are auto-down-cased
199 1 my $b_dryrun = $hr_options->{dryrun};
200 1 my $s_ttapplied = $hr_options->{macroprecond_evaluated};
201  
202 1 ▶ if ($b_dryrun) {
Branch: 1 branch
BranchTrueFalseTotal
if ($b_dryrun) 0 1 1
203 0 print $s_ttapplied;
204 0 exit 0;
205 }
206  
207 1 require Tapper::Cmd::Precondition;
208 1 return Tapper::Cmd::Precondition->new->add( $s_ttapplied );
209  
210 }
211  
212  
213 10 ▶sub s_create_testrun_parameter_check {
Subroutine s_create_testrun_parameter_check: called CC=18 SCAR=33.8
Pod documented
214  
215 10 my ( $hr_options ) = @_;
216  
217 10 ▶ if ( !$hr_options->{precondition} && !$hr_options->{macroprecond} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($hr_options->{"precondition"} or $hr_options->{"macroprecond"}) 1 9 10
Condition100%3/3
$hr_options->{"precondition"} or $hr_options->{"macroprecond"}
l!l&&r!l&&!r
721
MC/DC100%2/2
$hr_options->{"precondition"} or $hr_options->{"macroprecond"}
$hr_options->{"precondition"} $hr_options->{"macroprecond"}
Truth table100%3/3
A or B
A= $hr_options->{"precondition"}B= $hr_options->{"macroprecond"}
ABresult
1X1
011
000
218 1 return q#At least one of "precondition" or "macroprecond" is required#;
219 }
220 9 ▶ if ( exists $hr_options->{rerun_on_error} && $hr_options->{rerun_on_error} !~ /^\d+$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $hr_options->{"rerun_on_error"} and not $hr_options->{"rerun_on_error"} =~ /^\d+$/) 0 9 9
Condition66%2/3
exists $hr_options->{"rerun_on_error"} and not $hr_options->{"rerun_on_error"} =~ /^\d+$/
!ll&&!rl&&r
810
MC/DC0%0/2
exists $hr_options->{"rerun_on_error"} and not $hr_options->{"rerun_on_error"} =~ /^\d+$/
exists $hr_options->{"rerun_on_error"} not $hr_options->{"rerun_on_error"} =~ /^\d+$/
Truth table66%2/3
A and not(B)
A= exists $hr_options->{"rerun_on_error"}B= not $hr_options->{"rerun_on_error"} =~ /^\d+$/
ABresult
0X0
100
111
221 0 return "value for rerun_on_error ($hr_options->{rerun_on_error}) is not an integer value";
222 }
223 9 ▶ if ( $hr_options->{earliest} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hr_options->{"earliest"}) 0 9 9
224 0 require DateTime::Format::Natural;
225 0 my $or_parser = DateTime::Format::Natural->new;
226 0 $hr_options->{earliest} = $or_parser->parse_datetime( $hr_options->{earliest} );
227 0 ▶ if ( $or_parser->success ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($or_parser->success) { } 0 0 0
228 0 ▶ if ( $hr_options->{verbose} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hr_options->{"verbose"}) 0 0 0
229 0 say $hr_options->{earliest}->strftime('%d.%m.%Y %T');
230 }
231 }
232 else {
233 0 return $or_parser->error;
234 }
235 }
236  
237 9 require Tapper::Model;
238 9 ▶ if ( $hr_options->{requested_host} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hr_options->{"requested_host"}) 5 4 9
239 5 for my $i_counter ( 0..$#{$hr_options->{requested_host}} ) {
240 5 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (my $or_host = Tapper::Model::model('TestrunDB')->resultset('Host')->search({'name', $hr_options->{'requested_host'}[$i_counter]}, {'rows', 1})->first) { } 4 1 5
241 my $or_host =
242 Tapper::Model::model('TestrunDB')
243 ->resultset('Host')
244 ->search(
245 { name => $hr_options->{requested_host}[$i_counter] },
246 { rows => 1 },
247 )
248 ->first
249 ) {
250 4 $hr_options->{requested_host}[$i_counter] = $or_host->id;
251 }
252 else {
253 1 die "Host '$hr_options->{requested_host}[$i_counter]' does not exist\n";
254 }
255 }
256 }
257 8 ▶ if ( $hr_options->{notify} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hr_options->{"notify"}) 0 8 8
258 0 $hr_options->{notify} = lc $hr_options->{notify};
259 0 ▶ if (! grep { $hr_options->{notify} eq $_ } qw/ pass fail / ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (grep {$hr_options->{"notify"} eq $_;} "pass", "fail") 0 0 0
260 0 die "invalid value for 'notify': valid values 'pass', 'fail'\n";
261 }
262 }
263  
264 8 require File::Slurp;
265 8 ▶ if ( $hr_options->{macroprecond} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hr_options->{"macroprecond"}) 2 6 8
266 2 ▶ if ( -e $hr_options->{macroprecond} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $hr_options->{"macroprecond"}) 2 0 2
267  
268 2 require Tapper::Cmd;
269 2 my $or_cmd = Tapper::Cmd->new;
270 2 my $s_mpc_file = $hr_options->{macroprecond};
271 2 my $hr_d = $hr_options->{D};
272  
273 2 $hr_options->{macroprecond_evaluated} = $or_cmd->apply_macro($s_mpc_file, $hr_d);
274 2 ▶ if ( (my $s_required) = $hr_options->{macroprecond_evaluated} =~/^# (?:tapper[_-])?mandatory[_-]fields:\s*(.+)/m ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($s_required) = $hr_options->{"macroprecond_evaluated"} =~ /^# (?:tapper[_-])?mandatory[_-]fields:\s*(.+)/m) 2 0 2
275 2 my $re_delim = qr/,+\s*/;
276 2 foreach my $s_field ( split $re_delim, $s_required ) {
277 2 $s_field =~ s/\s+//g;
278 2 my ( $s_name, undef ) = split /\./, $s_field;
279 2 ▶ if (! $hr_options->{D}{$s_name} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($hr_options->{"D"}{$s_name}) 1 1 2
280 1 die "Expected macro field '$s_name' missing.\n";
281 }
282 }
283 }
284  
285 }
286  
287 }
288  
289 7 return;
290  
291 }
292  
293  
294 10 ▶sub b_create_testrun {
Subroutine b_create_testrun: called CC=30 SCAR=40.3
Pod documented
295  
296 10 my ( $or_app_rad ) = @_;
297  
298 10 my $ar_parameters = ar_get_create_testrun_parameters();
299 10 $or_app_rad->getopt( map { $_->[0] } @{$ar_parameters} );
300 10 my $hr_options = $or_app_rad->options;
301  
302 10 ▶ if ( $hr_options->{help} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hr_options->{"help"}) 0 10 10
303 0 say {*STDERR} "Usage: $PROGRAM_NAME testrun-new [options]";
304 0 require Tapper::CLI::Base;
305 0 Tapper::CLI::Base::b_print_help( $ar_parameters );
306 0 return;
307 }
308  
309 10 ▶ if ( my $s_error = s_create_testrun_parameter_check( $hr_options ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $s_error = s_create_testrun_parameter_check($hr_options)) 1 7 8
310 1 die 'error: ' . $s_error . "\n";
311 }
312  
313 7 my @a_ids;
314 7 ▶ if ( $hr_options->{macroprecond} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hr_options->{"macroprecond"}) 1 6 7
315 1 @a_ids = create_macro_preconditions( $hr_options );
316 }
317 7 ▶ if ( $hr_options->{precondition} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hr_options->{"precondition"}) 6 1 7
318 6 push @a_ids, @{$hr_options->{precondition}};
319 }
320  
321 7 ▶ if (! @a_ids ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@a_ids) 0 7 7
322 0 die "error: No valid preconditions given\n";
323 }
324  
325 7 require DateTime;
326 my $hr_testrun = {
327 wait_after_tests => $hr_options->{wait_after_tests},
328 priority => $hr_options->{priority} || 0,
329 auto_rerun => $hr_options->{auto_rerun} || 0,
330 earliest => $hr_options->{earliest} || DateTime->now,
331 notes => $hr_options->{notes} || q##,
332 owner => $hr_options->{owner} || $ENV{USER},
333 queue => $hr_options->{queue} || 'AdHoc',
334 rerun_on_error => $hr_options->{rerun_on_error} ? int( $hr_options->{rerun_on_error} ) || 0 : 0,
335 shortname => $hr_options->{shortname} || q##,
336 7 ▶ topic => $hr_options->{topic} || 'Misc',
Branch: 1 branch
BranchTrueFalseTotal
$hr_options->{'rerun_on_error'} ? : 1 6 7
Condition65%13/20
$hr_options->{'priority'} || 0
l!l
16
$hr_options->{'auto_rerun'} || 0
l!l
16
$hr_options->{'earliest'} || 'DateTime'->now
l!l&&r!l&&!r
070
$hr_options->{'notes'} || ''
l!l
07
$hr_options->{'owner'} || $ENV{'USER'}
l!l&&r!l&&!r
007
$hr_options->{'queue'} || 'AdHoc'
l!l
25
int $hr_options->{"rerun_on_error"} or 0
l!l
10
$hr_options->{'shortname'} || ''
l!l
07
$hr_options->{'topic'} || 'Misc'
l!l
52
MC/DC100%1/1
$hr_options->{'priority'} || 0
$hr_options->{'priority'}
MC/DC100%1/1
$hr_options->{'auto_rerun'} || 0
$hr_options->{'auto_rerun'}
MC/DC0%0/2
$hr_options->{'earliest'} || 'DateTime'->now
$hr_options->{'earliest'} 'DateTime'->now
MC/DC0%0/1
$hr_options->{'notes'} || ''
$hr_options->{'notes'}
MC/DC0%0/2
$hr_options->{'owner'} || $ENV{'USER'}
$hr_options->{'owner'} $ENV{'USER'}
MC/DC100%1/1
$hr_options->{'queue'} || 'AdHoc'
$hr_options->{'queue'}
MC/DC0%0/1
int $hr_options->{"rerun_on_error"} or 0
int $hr_options->{"rerun_on_error"}
MC/DC0%0/1
$hr_options->{'shortname'} || ''
$hr_options->{'shortname'}
MC/DC100%1/1
$hr_options->{'topic'} || 'Misc'
$hr_options->{'topic'}
Truth table100%2/2
A
A= $hr_options->{'priority'}
Aresult
11
00
Truth table100%2/2
A
A= $hr_options->{'auto_rerun'}
Aresult
11
00
Truth table33%1/3
A || B
A= $hr_options->{'earliest'}B= 'DateTime'->now
ABresult
1X1
011
000
Truth table50%1/2
A
A= $hr_options->{'notes'}
Aresult
11
00
Truth table33%1/3
A || B
A= $hr_options->{'owner'}B= $ENV{'USER'}
ABresult
1X1
011
000
Truth table100%2/2
A
A= $hr_options->{'queue'}
Aresult
11
00
Truth table50%1/2
A
A= int $hr_options->{"rerun_on_error"}
Aresult
11
00
Truth table50%1/2
A
A= $hr_options->{'shortname'}
Aresult
11
00
Truth table100%2/2
A
A= $hr_options->{'topic'}
Aresult
11
00
337 };
338  
339 7 ▶ if ( exists $hr_options->{notify} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $hr_options->{"notify"}) 1 6 7
340 1 $hr_testrun->{notify} = $hr_options->{notify};
341 }
342  
343 7 require Tapper::Cmd::Testrun;
344 7 my $or_cmd = Tapper::Cmd::Testrun->new();
345 7 my ( $i_testrun_id, $s_error ) = $or_cmd->add( $hr_testrun );
346  
347 7 ▶ if ( $i_testrun_id ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i_testrun_id) { } 7 0 7
348 7 ▶ if ( $s_error ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s_error) 0 7 7
349 0 say {*STDERR} "warning: $s_error";
350 }
351 }
352 else {
353 0 ▶ if ( $s_error ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s_error) { } 0 0 0
354 0 die "error: Can't create new testrun\n$s_error\n";
355 }
356 else {
357 0 die "error: Can't create new testrun because of an unknown error\n";
358 }
359 }
360  
361 7 require Tapper::Model;
362 7 my $or_testrun_search =
363 Tapper::Model::model('TestrunDB')
364 ->resultset('Testrun')
365 ->find( $i_testrun_id )
366 ;
367  
368 7 ▶ if ( my $retval = $or_cmd->assign_preconditions( $i_testrun_id, @a_ids ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $retval = $or_cmd->assign_preconditions($i_testrun_id, @a_ids)) 0 7 7
369 0 $or_testrun_search->delete();
370 0 die $retval . "\n";
371 }
372  
373 7 require Tapper::Cmd::Requested;
374  
375 7 my $or_cmd_req;
376 7 ▶ if ( $hr_options->{requested_host} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hr_options->{"requested_host"}) 3 4 7
377 3 $or_cmd_req = Tapper::Cmd::Requested->new;
378 3 foreach my $s_host ( @{$hr_options->{requested_host}} ) {
379 3 ▶ if (! $or_cmd_req->add_host( $i_testrun_id, $s_host, ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($or_cmd_req->add_host($i_testrun_id, $s_host)) 0 3 3
380 0 die "error: adding host failed\n";
381 }
382 }
383 }
384  
385 7 ▶ if ( $hr_options->{requested_feature} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hr_options->{"requested_feature"}) 1 6 7
386 1 ▶ $or_cmd_req ||= Tapper::Cmd::Requested->new;
Condition33%1/3
$or_cmd_req ||= "Tapper::Cmd::Requested"->new
l!l&&r!l&&!r
010
MC/DC0%0/2
$or_cmd_req ||= "Tapper::Cmd::Requested"->new
$or_cmd_req "Tapper::Cmd::Requested"->new
Truth table33%1/3
A ||= B
A= $or_cmd_reqB= "Tapper::Cmd::Requested"->new
ABresult
1X1
011
000
387 1 foreach my $s_feature ( @{$hr_options->{requested_feature}} ) {
388 1 ▶ if (! $or_cmd_req->add_feature( $i_testrun_id, $s_feature ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($or_cmd_req->add_feature($i_testrun_id, $s_feature)) 0 1 1
389 0 die "error: adding feature failed\n";
390 }
391 }
392 }
393  
394 7 require DateTime;
395 7 $or_testrun_search->testrun_scheduling->updated_at( DateTime->now->strftime('%F %T') );
396 7 $or_testrun_search->testrun_scheduling->status('schedule');
397 7 $or_testrun_search->testrun_scheduling->update;
398  
399 7 ▶ if ( $hr_options->{verbose} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hr_options->{'verbose'}) { } 0 7 7
400 0 say $or_testrun_search->to_string;
401 }
402 else {
403 7 ▶ if ( $ENV{TAPPER_WITH_WEB} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{'TAPPER_WITH_WEB'}) { } 0 7 7
404 0 my $s_webserver = Tapper::Config->subconfig->{webserver};
405 0 say "http://$s_webserver/tapper/testrun/id/$i_testrun_id";
406 }
407 else {
408 7 say $i_testrun_id;
409 }
410 }
411  
412 7 return;
413  
414 }
415  
416  
417 1 ▶sub b_delete {
Subroutine b_delete: called CC=6 SCAR=21.7
Pod documented
418  
419 1 my ( $or_app_rad ) = @_;
420  
421 1 my $ar_parameters = ar_get_delete_testrun_parameters();
422 1 $or_app_rad->getopt( map { $_->[0] } @{$ar_parameters} );
423 1 my $hr_options = $or_app_rad->options;
424  
425 1 ▶ if ( $hr_options->{help} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hr_options->{"help"}) 0 1 1
426 0 say {*STDERR} "Usage: $PROGRAM_NAME testrun-delete [options]";
427 0 require Tapper::CLI::Base;
428 0 Tapper::CLI::Base::b_print_help( $ar_parameters );
429 0 return;
430 }
431  
432 1 ▶ if (! $hr_options->{force} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($hr_options->{"force"}) 0 1 1
433 0 say {*STDERR} "info: Skip all testruns. Use --force.";
434 0 return;
435 }
436  
437 1 require Tapper::Cmd::Testrun;
438 1 my $or_cmd = Tapper::Cmd::Testrun->new();
439 1 for my $i_testrun_id ( @{$hr_options->{id}} ){
440 1 ▶ if ( my $s_error = $or_cmd->del( $i_testrun_id ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $s_error = $or_cmd->del($i_testrun_id)) 0 1 1
441 0 die "error: Can not delete testrun $i_testrun_id: $s_error\n";
442 }
443 1 ▶ if ( $hr_options->{verbose} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hr_options->{"verbose"}) 0 1 1
444 0 say "info: deleted testrun $i_testrun_id\n";
445 }
446 }
447  
448 1 return;
449  
450 }
451  
452  
453 1 ▶sub b_rerun {
Subroutine b_rerun: called CC=6 SCAR=21.4
Pod documented
454  
455 1 my ( $or_app_rad ) = @_;
456  
457 1 my $ar_parameters = ar_get_rerun_testrun_parameters();
458 1 $or_app_rad->getopt( map { $_->[0] } @{$ar_parameters} );
459 1 my $hr_options = $or_app_rad->options;
460  
461 1 ▶ if ( $hr_options->{help} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hr_options->{"help"}) 0 1 1
462 0 say {*STDERR} "Usage: $PROGRAM_NAME testrun-rerun [options]";
463 0 require Tapper::CLI::Base;
464 0 Tapper::CLI::Base::b_print_help( $ar_parameters );
465 0 return;
466 }
467  
468 1 require Tapper::Cmd::Testrun;
469 1 my $or_testrun = Tapper::Cmd::Testrun->new();
470  
471 1 ▶ if ( my $ar_testrun_ids = $hr_options->{id} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $ar_testrun_ids = $hr_options->{'id'}) { } 1 0 1
472 1 for my $i_testrun_id ( @{$ar_testrun_ids} ) {
473 1 ▶ if ( my $i_new_testrun_id = $or_testrun->rerun( $i_testrun_id, $hr_options ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $i_new_testrun_id = $or_testrun->rerun($i_testrun_id, $hr_options)) { } 1 0 1
474 1 ▶ if ( $hr_options->{verbose} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hr_options->{'verbose'}) { } 0 1 1
475 0 my $or_new_testrun = Tapper::Model::model->resultset('TestRun')->find($i_new_testrun_id);
476 0 b_print_testruns( $or_new_testrun );
477 0 say 'info: original id: ', $i_testrun_id;
478 }
479 else {
480 1 say $i_new_testrun_id;
481 }
482 }
483 else {
484 0 die "error: Can't restart testrun $i_testrun_id\n";
485 }
486 }
487 1 return;
488 }
489 else {
490 0 die "error: missing required parameter id\n";
491 }
492  
493 }
494  
495  
496 2 ▶sub ar_get_queue_ids {
Subroutine ar_get_queue_ids: called CC=4 SCAR=14.8
Pod documented
497  
498 2 my ( $or_schema, $ar_queue_names ) = @_;
499  
500 2 my @a_check_queues;
501 2 foreach my $s_queue ( @{$ar_queue_names} ) {
502 1 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (my $or_queue_rs = $or_schema->resultset('Queue')->search({'name', $s_queue}, {'select', ['id']})) { } 1 0 1
503 my $or_queue_rs =
504 $or_schema
505 ->resultset('Queue')
506 ->search({
507 name => $s_queue,
508 },{
509 'select' => [ 'id' ],
510 })
511 ) {
512 1 push @a_check_queues, $or_queue_rs->get_column('id')->all
513 }
514 else {
515 0 die "error: No such queue: $s_queue\n";
516 }
517 }
518  
519 2 ▶ if ( @a_check_queues ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@a_check_queues) 0 2 2
520 0 return @a_check_queues;
521 }
522 2 return;
523  
524 }
525  
526  
527 0 ▶sub ar_get_host_ids {
Subroutine ar_get_host_ids: not called CC=4 SCAR=30.0
Pod documented
528  
529 0 my ( $or_schema, $ar_host_names ) = @_;
530  
531 0 my @a_check_hosts = ();
532 0 foreach my $s_host ( @{$ar_host_names} ) {
533 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (my $or_host_rs = $or_schema->resultset('Host')->search({'name', $s_host}, {'select', ['id']})) { } 0 0 0
534 my $or_host_rs =
535 $or_schema
536 ->resultset('Host')
537 ->search({
538 name => $s_host
539 },{
540 'select' => [ 'id' ],
541 })
542 ) {
543 0 push @a_check_hosts, $or_host_rs->get_column('id')->all;
544 }
545 else {
546 0 die "error: No such host: $s_host\n";
547 }
548 }
549  
550 0 ▶ if ( @a_check_hosts ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@a_check_hosts) 0 0 0
551 0 return @a_check_hosts;
552 }
553 0 return;
554  
555 }
556  
557  
558 3 ▶sub b_list_testrun {
Subroutine b_list_testrun: called CC=16 SCAR=34.4
Pod documented
559  
560 3 my ( $or_app_rad ) = @_;
561  
562 3 my $or_querylog;
563  
564 3 require Tapper::Model;
565 3 my $or_schema = Tapper::Model::model('TestrunDB');
566  
567 3 ▶ if ( $ENV{DEBUG} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{"DEBUG"}) 0 3 3
568 0 require DBIx::Class::QueryLog;
569 0 $or_querylog = DBIx::Class::QueryLog->new();
570 0 $or_schema->storage->debugobj( $or_querylog );
571 0 $or_schema->storage->debug( 1 );
572 }
573  
574 3 my $ar_parameters = ar_get_list_testrun_parameters();
575 3 $or_app_rad->getopt( map { $_->[0] } @{$ar_parameters} );
576 3 my %h_options = %{$or_app_rad->options};
577  
578 3 ▶ if ( $h_options{help} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($h_options{"help"}) 0 3 3
579 0 say {*STDERR} "Usage: $PROGRAM_NAME testrun-rerun [options]";
580 0 require Tapper::CLI::Base;
581 0 Tapper::CLI::Base::b_print_help( $ar_parameters );
582 0 return;
583 }
584  
585 my @a_given_options = grep {
586 3 $h_options{$_}
587 } qw/ finished running schedule prepare queue host /;
588  
589 3 my $hr_search = {};
590 3 my @a_check_queues = ();
591  
592 3 ▶ if ( my $i_testrun_id = $h_options{id} ) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $i_testrun_id = $h_options{'id'}) { } 2 1 3
elsif (@a_given_options) { } 1 0 1
593  
594 2 ▶ if ( @a_given_options ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@a_given_options) 0 2 2
595 0 print {*STDERR} "error: other filters doesn't make sense with filter 'id'\n";
596 }
597  
598 # filter 'id' doesn't make sense without verbose
599 2 $h_options{verbose} = 1;
600  
601 2 $hr_search = { 'me.id' => $i_testrun_id }
602  
603 }
604 elsif ( @a_given_options ) {
605  
606 1 ▶ if ( my @a_state_selection = grep { $h_options{$_} } qw/ finished running schedule prepare / ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@a_state_selection) = grep({$h_options{$_};} "finished", "running", "schedule", "prepare")) 1 0 1
607 1 ▶ $hr_search->{'testrun_scheduling.status'} ||= \@a_state_selection;
Condition50%1/2
$hr_search->{"testrun_scheduling.status"} ||= \@a_state_selection
l!l
01
MC/DC0%0/1
$hr_search->{"testrun_scheduling.status"} ||= \@a_state_selection
$hr_search->{"testrun_scheduling.status"}
Truth table50%1/2
A
A= $hr_search->{"testrun_scheduling.status"}
Aresult
11
00
608 }
609  
610 1 ▶ if ( my $ar_queue_ids = ar_get_queue_ids( $or_schema, $h_options{queue} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $ar_queue_ids = ar_get_queue_ids($or_schema, $h_options{"queue"})) 0 1 1
611 0 $hr_search->{'testrun_scheduling.queue_id'} = { -in => $ar_queue_ids };
612 }
613  
614 1 ▶ if ( my $ar_host_ids = ar_get_queue_ids( $or_schema, $h_options{host} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $ar_host_ids = ar_get_queue_ids($or_schema, $h_options{"host"})) 0 1 1
615 $hr_search->{-or} = [
616 0 -and => [
617 -not => { 'testrun_scheduling.status' => 'schedule', },
618 'testrun_scheduling.host_id' => { -in => $ar_host_ids, },
619 ],
620 -and => [
621 'testrun_scheduling.status' => 'schedule',
622 'requested_hosts.host_id' => { -in => $ar_host_ids, },
623 ],
624 ];
625 }
626  
627 }
628  
629 3 my $hr_search_options = {
630 order_by => { -desc => 'me.id' }
631 };
632  
633 3 ▶ if ( exists $h_options{limit} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $h_options{'limit'}) { } 0 3 3
634 0 ▶ if ( $h_options{limit} > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($h_options{"limit"} > 0) 0 0 0
635 0 $hr_search_options->{rows} = $h_options{limit};
636 }
637 }
638 else {
639 3 $hr_search_options->{rows} = $i_limit_default;
640 }
641 3 ▶ if ( $h_options{verbose} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($h_options{'verbose'}) { } 2 1 3
642 2 $hr_search_options->{'prefetch'} = [
643 {
644 'testrun_scheduling' => [
645 'queue',
646 {
647 'requested_hosts' => 'host',
648 },
649 ],
650 },
651 {
652 'testrun_scheduling' => 'host',
653 },
654 ];
655 }
656 else {
657 1 $hr_search_options->{'join'} = 'testrun_scheduling';
658 1 $hr_search_options->{'select'} = ['id'];
659 }
660  
661 3 my $or_testrun_rs =
662 $or_schema
663 ->resultset('Testrun')
664 ->search( $hr_search, $hr_search_options )
665 ;
666  
667 3 ▶ if ( $h_options{verbose} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($h_options{'verbose'}) { } 2 1 3
668 2 Tapper::CLI::Testrun::b_print_testruns( $or_testrun_rs );
669 }
670 else {
671 1 foreach my $i_testrun_id ( $or_testrun_rs->get_column('id')->all ) {
672 2 say $i_testrun_id;
673 }
674 }
675  
676 3 ▶ if ( $ENV{DEBUG} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{"DEBUG"}) 0 3 3
677  
678 0 require DBIx::Class::QueryLog::Analyzer;
679 0 my $or_analyzer = DBIx::Class::QueryLog::Analyzer->new({
680 querylog => $or_querylog,
681 });
682  
683 0 require Data::Dumper;
684 0 say {*STDERR} "Query count: " . scalar( @{$or_analyzer->get_sorted_queries} );
685 0 say {*STDERR} Data::Dumper::Dumper([
686 $or_analyzer->get_sorted_queries
687 ]);
688  
689 }
690  
691 3 return;
692  
693 }
694  
695  
696 sub testrun_update
697 1 ▶{
Subroutine testrun_update: called CC=15 SCAR=42.7
Pod documented
698 1 my ($c) = @_;
699 1 $c->getopt( 'id=i@','status=s', 'topic=s', 'auto-rerun!','help|?', 'verbose|v' );
700 1 ▶ if ( $c->options->{help} or not $c->options->{id}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c->options->{"help"} or not $c->options->{"id"}) 0 1 1
Condition33%1/3
$c->options->{"help"} or not $c->options->{"id"}
l!l&&r!l&&!r
001
MC/DC0%0/2
$c->options->{"help"} or not $c->options->{"id"}
$c->options->{"help"} not $c->options->{"id"}
Truth table33%1/3
A or not(B)
A= $c->options->{"help"}B= not $c->options->{"id"}
ABresult
1X1
011
000
701 0 ▶ say STDERR "Please set at least one testrun id with --id!" unless @{$c->options->{id} || []};
Branch: 1 branch
BranchTrueFalseTotal
unless @{$c->options->{"id"} or [];} 0 0 0
Condition0%0/2
$c->options->{'id'} || []
l!l
00
MC/DC0%0/1
$c->options->{'id'} || []
$c->options->{'id'}
Truth table0%0/2
A
A= $c->options->{'id'}
Aresult
11
00
702 0 ▶ say STDERR "Please set an update action" unless ($c->options->{state} or defined $c->options->{"auto-rerun"});
Branch: 1 branch
BranchTrueFalseTotal
unless $c->options->{"state"} or defined $c->options->{"auto-rerun"} 0 0 0
Condition0%0/3
$c->options->{"state"} or defined $c->options->{"auto-rerun"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$c->options->{"state"} or defined $c->options->{"auto-rerun"}
$c->options->{"state"} defined $c->options->{"auto-rerun"}
Truth table0%0/3
A or B
A= $c->options->{"state"}B= defined $c->options->{"auto-rerun"}
ABresult
1X1
011
000
703 0 say STDERR "$PROGRAM_NAME testrun-update --id=s@ --status=s --auto_rerun --no-auto-rerun --verbose|v [--help|?]";
704 0 say STDERR " --id Id of the testrun to update, can be given multiple times";
705 0 say STDERR " --topic one of: Kernel, Xen, KVM, Hardware, Distribution, Benchmark, Software, Misc";
706 0 say STDERR " --status Set testrun to given status, can be one of 'prepare', 'schedule', 'finished'.";
707 0 say STDERR " --auto-rerun Activate auto-rerun on testrun. ";
708 0 say STDERR " --no-auto-rerun Activate auto-rerun on testrun";
709 0 say STDERR " --verbose|v Print new state of testrun (will only print id of updated testruns without)";
710 0 say STDERR " --help|? Print this help message and exit";
711 0 return;
712 }
713  
714 1 require Tapper::Model;
715 ID:
716 1 foreach my $testrun_id (@{$c->options->{id}}) {
717 1 my $testrun = Tapper::Model::model('TestrunDB')->resultset('Testrun')->find($testrun_id);
718 1 ▶ if (not $testrun) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($testrun) 0 1 1
719 0 say STDERR "Testrun with id $testrun_id not found. Skipping!";
720 0 next ID;
721 }
722  
723 1 ▶ if ( $c->options->{topic} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c->options->{"topic"}) 1 0 1
724 $testrun->update_content({
725 topic => $c->options->{topic},
726 1 });
727 }
728  
729 1 ▶ if (not ($testrun->testrun_scheduling->status eq 'prepare' or
Branch: 1 branch
BranchTrueFalseTotal
unless ($testrun->testrun_scheduling->status eq "prepare" or $testrun->testrun_scheduling->status eq "schedule") 0 1 1
Condition33%1/3
$testrun->testrun_scheduling->status eq "prepare" or $testrun->testrun_scheduling->status eq "schedule"
l!l&&r!l&&!r
010
MC/DC0%0/2
$testrun->testrun_scheduling->status eq "prepare" or $testrun->testrun_scheduling->status eq "schedule"
$testrun->testrun_scheduling->status eq "prepare" $testrun->testrun_scheduling->status eq "schedule"
Truth table33%1/3
A or B
A= $testrun->testrun_scheduling->status eq "prepare"B= $testrun->testrun_scheduling->status eq "schedule"
ABresult
1X1
011
000
730 $testrun->testrun_scheduling->status eq 'schedule')
731 )
732 {
733 0 say STDERR "Can only update testruns in state 'schedule' and 'finished'. Updating testruns in other states will break something. Please consider tapper testrun-rerun";
734 0 next ID;
735 }
736  
737 1 ▶ if ($c->options->{status}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c->options->{"status"}) 0 1 1
738 0 $testrun->testrun_scheduling->status($c->options->{status});
739 0 $testrun->testrun_scheduling->update;
740 }
741 1 ▶ if (defined($c->options->{"auto-rerun"})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $c->options->{"auto-rerun"}) 0 1 1
742 0 $testrun->testrun_scheduling->auto_rerun($c->options->{"auto-rerun"});
743 0 $testrun->testrun_scheduling->update;
744 }
745 1 ▶ if ($c->options->{verbose}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c->options->{'verbose'}) { } 0 1 1
746 0 b_print_testruns($testrun);
747 } else {
748 1 say $testrun_id;
749 }
750 }
751  
752 }
753  
754  
755 sub b_cancel
756 1 ▶{
Subroutine b_cancel: called CC=7 SCAR=27.2
Pod documented
757  
758 1 my ($c) = @_;
759 1 $c->getopt( 'id=i@','comment=s','help|?', 'verbose|v' );
760 1 ▶ if ( $c->options->{help} or not $c->options->{id}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c->options->{"help"} or not $c->options->{"id"}) 0 1 1
Condition33%1/3
$c->options->{"help"} or not $c->options->{"id"}
l!l&&r!l&&!r
001
MC/DC0%0/2
$c->options->{"help"} or not $c->options->{"id"}
$c->options->{"help"} not $c->options->{"id"}
Truth table33%1/3
A or not(B)
A= $c->options->{"help"}B= not $c->options->{"id"}
ABresult
1X1
011
000
761 0 ▶ say STDERR "Please set at least one testrun id with --id!" unless @{$c->options->{id} || []};
Branch: 1 branch
BranchTrueFalseTotal
unless @{$c->options->{"id"} or [];} 0 0 0
Condition0%0/2
$c->options->{'id'} || []
l!l
00
MC/DC0%0/1
$c->options->{'id'} || []
$c->options->{'id'}
Truth table0%0/2
A
A= $c->options->{'id'}
Aresult
11
00
762 0 say STDERR "$PROGRAM_NAME testrun-cancel --id=i@ [--comment=s] [--verbose|v] [--help|?]";
763 0 say STDERR " --id Id of the testrun to cancel, can be given multiple times";
764 0 say STDERR " --comment A comment why the testrun(s) were cancelled";
765 0 say STDERR " --verbose|v Tell user what we just did (without -v only the testrun id will be printed in the success case)";
766 0 say STDERR " --help|? Print this help message and exit";
767 0 return;
768 }
769  
770 1 require Tapper::Cmd::Testrun;
771 1 my $cmd = Tapper::Cmd::Testrun->new();
772 1 foreach my $id (@{$c->options->{id}}) {
773 1 my $retval = $cmd->cancel($id, $c->options->{comment});
774 1 ▶ warn $retval if $retval;
Branch: 1 branch
BranchTrueFalseTotal
if $retval 0 1 1
775 }
776 1 return;
777 }
778  
779  
780  
781 sub b_pause
782 1 ▶{
Subroutine b_pause: called CC=7 SCAR=26.3
Pod documented
783  
784 1 my ($c) = @_;
785 1 $c->getopt( 'id=i@','help|?', 'verbose|v' );
786 1 ▶ if ( $c->options->{help} or not $c->options->{id}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c->options->{"help"} or not $c->options->{"id"}) 0 1 1
Condition33%1/3
$c->options->{"help"} or not $c->options->{"id"}
l!l&&r!l&&!r
001
MC/DC0%0/2
$c->options->{"help"} or not $c->options->{"id"}
$c->options->{"help"} not $c->options->{"id"}
Truth table33%1/3
A or not(B)
A= $c->options->{"help"}B= not $c->options->{"id"}
ABresult
1X1
011
000
787 0 ▶ say STDERR "Please set at least one testrun id with --id!" unless @{$c->options->{id} || []};
Branch: 1 branch
BranchTrueFalseTotal
unless @{$c->options->{"id"} or [];} 0 0 0
Condition0%0/2
$c->options->{'id'} || []
l!l
00
MC/DC0%0/1
$c->options->{'id'} || []
$c->options->{'id'}
Truth table0%0/2
A
A= $c->options->{'id'}
Aresult
11
00
788 0 say STDERR "$PROGRAM_NAME testrun-pause --id=i@ [--verbose|v] [--help|?]";
789 0 say STDERR " --id Id of the testrun to pause, can be given multiple times";
790 0 say STDERR " --help|? Print this help message and exit";
791 0 return;
792 }
793  
794 1 require Tapper::Cmd::Testrun;
795 1 my $cmd = Tapper::Cmd::Testrun->new();
796 1 foreach my $id (@{$c->options->{id}}) {
797 1 my $retval = $cmd->pause($id);
798 1 ▶ say $id if $retval;
Branch: 1 branch
BranchTrueFalseTotal
if $retval 1 0 1
799 }
800 1 return;
801 }
802  
803  
804  
805 sub b_continue
806 1 ▶{
Subroutine b_continue: called CC=7 SCAR=26.3
Pod documented
807  
808 1 my ($c) = @_;
809 1 $c->getopt( 'id=i@','help|?', 'verbose|v' );
810 1 ▶ if ( $c->options->{help} or not $c->options->{id}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c->options->{"help"} or not $c->options->{"id"}) 0 1 1
Condition33%1/3
$c->options->{"help"} or not $c->options->{"id"}
l!l&&r!l&&!r
001
MC/DC0%0/2
$c->options->{"help"} or not $c->options->{"id"}
$c->options->{"help"} not $c->options->{"id"}
Truth table33%1/3
A or not(B)
A= $c->options->{"help"}B= not $c->options->{"id"}
ABresult
1X1
011
000
811 0 ▶ say STDERR "Please set at least one testrun id with --id!" unless @{$c->options->{id} || []};
Branch: 1 branch
BranchTrueFalseTotal
unless @{$c->options->{"id"} or [];} 0 0 0
Condition0%0/2
$c->options->{'id'} || []
l!l
00
MC/DC0%0/1
$c->options->{'id'} || []
$c->options->{'id'}
Truth table0%0/2
A
A= $c->options->{'id'}
Aresult
11
00
812 0 say STDERR "$PROGRAM_NAME testrun-continue --id=i@ [--verbose|v] [--help|?]";
813 0 say STDERR " --id Id of the testrun to continue, can be given multiple times";
814 0 say STDERR " --help|? Print this help message and exit";
815 0 return;
816 }
817  
818 1 require Tapper::Cmd::Testrun;
819 1 my $cmd = Tapper::Cmd::Testrun->new();
820 1 foreach my $id (@{$c->options->{id}}) {
821 1 my $retval = $cmd->continue($id);
822 1 ▶ say $id if $retval;
Branch: 1 branch
BranchTrueFalseTotal
if $retval 1 0 1
823 }
824 1 return;
825 }
826  
827  
828  
829 71 ▶sub setup {
Subroutine setup: called CC=2 SCAR=7.0
Pod documented
830  
831 71 my ( $or_apprad ) = @_;
832  
833 71 $or_apprad->register( 'testrun-list' , \&b_list_testrun , 'Show all testruns matching a given condition', );
834 71 $or_apprad->register( 'testrun-update' , \&testrun_update , 'Update an existing testrun', );
835 71 $or_apprad->register( 'testrun-rerun' , \&b_rerun , 'Rerun an existing testrun with the same preconditions', );
836 71 $or_apprad->register( 'testrun-delete' , \&b_delete , 'Delete a testrun', );
837 71 $or_apprad->register( 'testrun-pause' , \&b_pause , 'Pause a not-yet-running testrun', );
838 71 $or_apprad->register( 'testrun-continue',\&b_continue , 'Continue a paused testrun', );
839 71 $or_apprad->register( 'testrun-cancel' , \&b_cancel , 'Cancel a running testrun', );
840 71 $or_apprad->register( 'testrun-new' , \&b_create_testrun , 'Create a testrun', );
841  
842 71 ▶ if ( $or_apprad->can('group_commands') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($or_apprad->can("group_commands")) 0 71 71
843 0 $or_apprad->group_commands(
844 'Testrun commands',
845 'testrun-list',
846 'testrun-new',
847 'testrun-update',
848 'testrun-rerun',
849 'testrun-delete',
850 'testrun-pause',
851 'testrun-continue',
852 'testrun-cancel',
853 );
854 }
855  
856 71 return;
857  
858 }
859  
860 73 1; # End of Tapper::CLI
861  
862 __END__
« blib/lib/Tapper/CLI/Base.pm ↑ Summary blib/lib/Tapper/CLI/Cobbler.pm »