| 1 | package Tapper::CLI::Testplan; | ||||||||||||||||||||||||||||
| 2 | 73 | our $AUTHORITY = 'cpan:TAPPER'; | |||||||||||||||||||||||||||
| 3 | # ABSTRACT: Handle testplans | ||||||||||||||||||||||||||||
| 4 | 73 | $Tapper::CLI::Testplan::VERSION = '5.0.8'; | |||||||||||||||||||||||||||
| 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 Perl6::Junction qw/all/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 73 | ▶ | use English '-no_match_vars'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 73 | ▶ | no if $] >= 5.018, warnings => "experimental"; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 73 | ▶ | use JSON::XS; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 73 | ▶ | use YAML::XS; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | sub testplanlist | ||||||||||||||||||||||||||||
| 18 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
testplanlist: not called CC=29 SCAR=67.1
Pod
documented
| |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 0 | my ($c) = @_; | |||||||||||||||||||||||||||
| 21 | 0 | $c->getopt( 'name|n=s@', 'path|p=s@', 'testrun|t=s@', 'id|i=i@','active|a','verbose|v','result|r', 'format=s', 'help|?' ); | |||||||||||||||||||||||||||
| 22 | 0 | ▶ | if ( $c->options->{help} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 23 | 0 | say STDERR "Usage: $0 testplan-list [--path=path|-p=path]* [--name|-n=name]* [--testrun=id|-t=id]* [--id=number|-i=number] [--active|-a] [ --format=JSON|YAML ] [--verbose|-v]"; | |||||||||||||||||||||||||||
| 24 | 0 | say STDERR ""; | |||||||||||||||||||||||||||
| 25 | 0 | say STDERR " --path|-p Path name of testplans to list."; | |||||||||||||||||||||||||||
| 26 | 0 | say STDERR " Only slashes(/) are allowed as separators."; | |||||||||||||||||||||||||||
| 27 | 0 | say STDERR " Can be an SQL like condition (i.e. '\%name\%'). Make sure your shell does not break it."; | |||||||||||||||||||||||||||
| 28 | 0 | say STDERR " Can be given multiple times"; | |||||||||||||||||||||||||||
| 29 | 0 | say STDERR " Will reduce number of testplans when given with --testrun or --name, can't go with --id"; | |||||||||||||||||||||||||||
| 30 | 0 | say STDERR " --name|-n name of testplans to list."; | |||||||||||||||||||||||||||
| 31 | 0 | say STDERR " Can be an SQL like condition (i.e. '\%name\%'). Make sure your shell does not break it."; | |||||||||||||||||||||||||||
| 32 | 0 | say STDERR " Can be given multiple times"; | |||||||||||||||||||||||||||
| 33 | 0 | say STDERR " Will reduce number of testplans when given with --testrun or --path, can't go with --id"; | |||||||||||||||||||||||||||
| 34 | 0 | say STDERR " --testrun|-t Show testplan containing this testrun id"; | |||||||||||||||||||||||||||
| 35 | 0 | say STDERR " Can be given multiple times"; | |||||||||||||||||||||||||||
| 36 | 0 | say STDERR " Will reduce number of testplans when given with --name or --path, can't go with --id"; | |||||||||||||||||||||||||||
| 37 | 0 | say STDERR " --id|-i Show testplan of given id"; | |||||||||||||||||||||||||||
| 38 | 0 | say STDERR " Can be given multiple times. Implies -v"; | |||||||||||||||||||||||||||
| 39 | 0 | say STDERR " Will override --testrun, --path and --name"; | |||||||||||||||||||||||||||
| 40 | 0 | say STDERR " --active|-a Only show testplan with testruns that are not finished yet."; | |||||||||||||||||||||||||||
| 41 | 0 | say STDERR " Will reduce number of testplans when given with any other filter."; | |||||||||||||||||||||||||||
| 42 | 0 | say STDERR " --result|-r Determine failure or success of testplan. Expensive operation."; | |||||||||||||||||||||||||||
| 43 | 0 | say STDERR " --format Give output in this format. Valid values are YAML, JSON. Case insensitive. Always verbose."; | |||||||||||||||||||||||||||
| 44 | 0 | say STDERR " --verbose|-v Show testplan with id, name and associated testruns. Without only testplan id is shown."; | |||||||||||||||||||||||||||
| 45 | 0 | say STDERR " --help Print this help message and exit."; | |||||||||||||||||||||||||||
| 46 | 0 | exit -1; | |||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | 0 | my @ids; | |||||||||||||||||||||||||||
| 49 | my $filtered; | ||||||||||||||||||||||||||||
| 50 | 0 | my $format = $c->options->{format}; | |||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 0 | require Tapper::Model; | |||||||||||||||||||||||||||
| 53 | 0 | ▶ | if (@{$c->options->{id} || []}) { | ||||||||||||||||||||||||||
|
Branch: 3 branches
Condition0%0/2
$c->options->{'id'} || []
MC/DC0%0/1
$c->options->{'id'} || []
$c->options->{'id'}
Truth table0%0/2
A
A= $c->options->{'id'}
| |||||||||||||||||||||||||||||
| 54 | 0 | @ids = @{$c->options->{id}}; | |||||||||||||||||||||||||||
| 55 | 0 | ▶ | } elsif (@{$c->options->{testrun} || []}) { | ||||||||||||||||||||||||||
|
Condition0%0/2
$c->options->{'testrun'} || []
MC/DC0%0/1
$c->options->{'testrun'} || []
$c->options->{'testrun'}
Truth table0%0/2
A
A= $c->options->{'testrun'}
| |||||||||||||||||||||||||||||
| 56 | 0 | my $testruns = Tapper::Model::model('TestrunDB')->resultset('Testrun')->search({id => $c->options->{testrun}}); | |||||||||||||||||||||||||||
| 57 | 0 | ▶ | while (my $testrun = $testruns->next) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 58 | 0 | ▶ | push @ids, $testrun->testplan_id if $testrun->testplan_id; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | 0 | ▶ | } elsif ( @{$c->options->{name} || []}) { | ||||||||||||||||||||||||||
|
Condition0%0/2
$c->options->{'name'} || []
MC/DC0%0/1
$c->options->{'name'} || []
$c->options->{'name'}
Truth table0%0/2
A
A= $c->options->{'name'}
| |||||||||||||||||||||||||||||
| 61 | 0 | my $regex = join("|", map { "($_)" } @{$c->options->{name}}); | |||||||||||||||||||||||||||
| 62 | 0 | my $instances = Tapper::Model::model('TestrunDB')->resultset('TestplanInstance'); | |||||||||||||||||||||||||||
| 63 | 0 | ▶ | while (my $instance = $instances->next) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 64 | 0 | ▶ | push @ids, $instance->id if $instance->path and $instance->path =~ /$regex/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$instance->path and $instance->path =~ /$regex/
MC/DC0%0/2
$instance->path and $instance->path =~ /$regex/
$instance->path
$instance->path =~ /$regex/
Truth table0%0/3
A and B
A= $instance->pathB= $instance->path =~ /$regex/
| |||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | } else { | ||||||||||||||||||||||||||||
| 67 | 0 | my $instances = Tapper::Model::model('TestrunDB')->resultset('TestplanInstance'); | |||||||||||||||||||||||||||
| 68 | 0 | ▶ | while (my $instance = $instances->next) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 69 | 0 | push @ids, $instance->id; | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | 0 | $c->options->{verbose} = 1; | |||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | # a join would be faster and maybe cleaner | ||||||||||||||||||||||||||||
| 75 | 0 | ▶ | if ($c->options->{active}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 76 | 0 | my @local_ids = @ids; | |||||||||||||||||||||||||||
| 77 | 0 | my $instances = Tapper::Model::model('TestrunDB')->resultset('TestplanInstance')->search({id => \@local_ids}); | |||||||||||||||||||||||||||
| 78 | 0 | @ids = (); | |||||||||||||||||||||||||||
| 79 | 0 | ▶ | while (my $instance = $instances->next) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 80 | 0 | ▶ | if ($instance->testruns and grep {$_->testrun_scheduling->status ne 'finished'} $instance->testruns->all) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$instance->testruns and grep {$_->testrun_scheduling->status ne "finished";} $instance->testruns->all
MC/DC0%0/2
$instance->testruns and grep {$_->testrun_scheduling->status ne "finished";} $instance->testruns->all
$instance->testruns
grep {$_->testrun_scheduling->status ne "finished";} $instance->testruns->all
Truth table0%0/3
A and B
A= $instance->testrunsB= grep {$_->testrun_scheduling->status ne "finished";} $instance->testruns->all
| |||||||||||||||||||||||||||||
| 81 | 0 | push @ids, $instance->id; | |||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | 0 | $instances = Tapper::Model::model('TestrunDB')->resultset('TestplanInstance')->search({id => [ @ids ]}); | |||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 0 | ▶ | if ($c->options->{quiet}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 88 | 0 | return join ("\n",@ids); | |||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 0 | my %inst_data; | |||||||||||||||||||||||||||
| 92 | 0 | my $instances = Tapper::Model::model('TestrunDB')->resultset('TestplanInstance')->search({id => \@ids}); | |||||||||||||||||||||||||||
| 93 | 0 | ▶ | while (my $instance = $instances->next) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 94 | my $current_inst_data = $inst_data{$instance->id} = | ||||||||||||||||||||||||||||
| 95 | { | ||||||||||||||||||||||||||||
| 96 | path => $instance->path ? $instance->path : '', | ||||||||||||||||||||||||||||
| 97 | name => $instance->path ? $instance->path : '', | ||||||||||||||||||||||||||||
| 98 | 0 | ▶ | testruns => [ map { {id => $_->id, status => ''.$_->testrun_scheduling->status} } $instance->testruns ], # stringify enum object | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 99 | }; | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | 0 | ▶ | if ($c->options->{result}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 102 | 0 | my %testrunrefs = map { $_->{id} => $_ } @{$current_inst_data->{testruns}}; | |||||||||||||||||||||||||||
| 103 | 0 | my $iter = Tapper::Model::model('TestrunDB')->resultset('ReportgroupTestrunStats')->search({testrun_id => [ keys %testrunrefs ]}); | |||||||||||||||||||||||||||
| 104 | 0 | ▶ | while (my $stat = $iter->next) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 105 | 0 | $testrunrefs{$stat->testrun_id}->{success} = !($stat->success_ratio < 100); | |||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||
| 109 | 0 | ▶ | if ($c->options->{format}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 110 | 73 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 111 | 0 | ▶ | if (lc($c->options->{format}) eq 'yaml') { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 112 | 0 | return YAML::XS::Dump(\%inst_data); | |||||||||||||||||||||||||||
| 113 | } elsif (lc($c->options->{format}) eq 'json') { | ||||||||||||||||||||||||||||
| 114 | 0 | return encode_json(\%inst_data); | |||||||||||||||||||||||||||
| 115 | } else { | ||||||||||||||||||||||||||||
| 116 | 0 | die "unknown format: ",$c->options->{format}; | |||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||
| 118 | } else { | ||||||||||||||||||||||||||||
| 119 | 0 | ▶ | if ($c->options->{verbose}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 120 | 0 | my @testplan_info; | |||||||||||||||||||||||||||
| 121 | 0 | foreach my $id (keys %inst_data) { | |||||||||||||||||||||||||||
| 122 | my $line = join(" - ", | ||||||||||||||||||||||||||||
| 123 | $id, | ||||||||||||||||||||||||||||
| 124 | $inst_data{$id}->{path}, | ||||||||||||||||||||||||||||
| 125 | 0 | "testruns: ".join(", ", map{$_->{id}} @{$inst_data{$id}->{testruns}}) | |||||||||||||||||||||||||||
| 126 | ); | ||||||||||||||||||||||||||||
| 127 | 0 | push @testplan_info, $line; | |||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||
| 129 | 0 | return join "\n", @testplan_info; | |||||||||||||||||||||||||||
| 130 | } else { | ||||||||||||||||||||||||||||
| 131 | 0 | return join "\n", map { $_->id} $instances->all; | |||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | sub testplannew | ||||||||||||||||||||||||||||
| 139 | 1 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
testplannew: called CC=10 SCAR=31.4
Pod
documented
| |||||||||||||||||||||||||||||
| 140 | 1 | my ($c) = @_; | |||||||||||||||||||||||||||
| 141 | 1 | $c->getopt( 'include|I=s@', 'name=s', 'path=s', 'file=s', 'D=s%', 'dryrun|n', 'guide|g', 'quiet|q', 'subst_json=s','verbose|v', 'help|?' ); | |||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | 1 | my $opt = $c->options; | |||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | 1 | ▶ | if ( $opt->{help} or not $opt->{file}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$opt->{"help"} or not $opt->{"file"}
MC/DC0%0/2
$opt->{"help"} or not $opt->{"file"}
$opt->{"help"}
not $opt->{"file"}
Truth table33%1/3
A or not(B)
A= $opt->{"help"}B= not $opt->{"file"}
| |||||||||||||||||||||||||||||
| 146 | 0 | say STDERR "Usage: $0 testplan-new --file=s [ -dry-run|n ] [ -v ] [ -Dkey=value ] [ --path=s ] [ --name=s ] [ --include=s ]*"; | |||||||||||||||||||||||||||
| 147 | 0 | say STDERR ""; | |||||||||||||||||||||||||||
| 148 | 0 | say STDERR " -D Define a key=value pair used for macro expansion"; | |||||||||||||||||||||||||||
| 149 | 0 | say STDERR " --dryrun Just print evaluated testplan without submit to DB"; | |||||||||||||||||||||||||||
| 150 | 0 | say STDERR " --file Use (macro) testplan file"; | |||||||||||||||||||||||||||
| 151 | 0 | say STDERR " --guide Just print self-documentation"; | |||||||||||||||||||||||||||
| 152 | 0 | say STDERR " --include Add include directory (multiple allowed)"; | |||||||||||||||||||||||||||
| 153 | 0 | say STDERR " --name Provide a name for this testplan instance"; | |||||||||||||||||||||||||||
| 154 | 0 | say STDERR " --path Put this path into db instead of file path"; | |||||||||||||||||||||||||||
| 155 | 0 | say STDERR " --subst_json File name that contains macro expansion values in JSON formaxt"; | |||||||||||||||||||||||||||
| 156 | 0 | say STDERR " --verbose Show more progress output."; | |||||||||||||||||||||||||||
| 157 | 0 | say STDERR " --quiet Only show testplan ids, suppress path, name and testrun ids."; | |||||||||||||||||||||||||||
| 158 | 0 | say STDERR " --help Print this help message and exit."; | |||||||||||||||||||||||||||
| 159 | 0 | exit -1; | |||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | 1 | ▶ | die "Testplan file needed\n" if not $opt->{file}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 163 | 0 | ▶ | die "Testplan file @{[ $opt->{file} ]} does not exist" if not -e $opt->{file}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 164 | 0 | ▶ | die "Testplan file @{[ $opt->{file} ]} is not readable" if not -r $opt->{file}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | 1 | require Tapper::Cmd::Testplan; | |||||||||||||||||||||||||||
| 167 | 1 | ▶ | if ($opt->{subst_json}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 168 | 73 | ▶ | use File::Slurp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 169 | 0 | my $data = File::Slurp::read_file($opt->{subst_json}); | |||||||||||||||||||||||||||
| 170 | 0 | $opt->{substitutes} = JSON::XS::decode_json($data); | |||||||||||||||||||||||||||
| 171 | } else { | ||||||||||||||||||||||||||||
| 172 | 1 | $opt->{substitutes} = $opt->{D}; | |||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||
| 174 | 1 | my $cmd = Tapper::Cmd::Testplan->new; | |||||||||||||||||||||||||||
| 175 | 1 | ▶ | if ($opt->{guide}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 176 | 0 | return $cmd->guide($opt->{file}, $opt->{substitutes}, $opt->{include}); | |||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||
| 178 | 1 | ▶ | if ($opt->{dryrun}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 179 | 0 | return $cmd->apply_macro($opt->{file}, $opt->{substitutes}, $opt->{include}); | |||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | 1 | my $answer = $cmd->testplannew($opt); | |||||||||||||||||||||||||||
| 183 | # Format: | ||||||||||||||||||||||||||||
| 184 | # TESTPLANID: TESTRUNID TESTRUNID TESTRUNID | ||||||||||||||||||||||||||||
| 185 | my $output = | ||||||||||||||||||||||||||||
| 186 | $answer->{testplan_id} | ||||||||||||||||||||||||||||
| 187 | . ': ' | ||||||||||||||||||||||||||||
| 188 | 1 | ▶ | . join(' ', @{$answer->{testrun_ids} || []}); | ||||||||||||||||||||||||||
|
Condition50%1/2
$answer->{'testrun_ids'} || []
MC/DC0%0/1
$answer->{'testrun_ids'} || []
$answer->{'testrun_ids'}
Truth table50%1/2
A
A= $answer->{'testrun_ids'}
| |||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||
| 190 | 1 | return $output; | |||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | sub testplancancel | ||||||||||||||||||||||||||||
| 195 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
testplancancel: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 196 | 0 | my ($c) = @_; | |||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | 0 | $c->getopt( 'id|i=i@', 'comment=s', 'help|?' ); | |||||||||||||||||||||||||||
| 199 | 0 | my $opt = $c->options; | |||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | 0 | ▶ | if ( $opt->{help} or not $opt->{id}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$opt->{"help"} or not $opt->{"id"}
MC/DC0%0/2
$opt->{"help"} or not $opt->{"id"}
$opt->{"help"}
not $opt->{"id"}
Truth table0%0/3
A or not(B)
A= $opt->{"help"}B= not $opt->{"id"}
| |||||||||||||||||||||||||||||
| 202 | 0 | say STDERR "Usage: $0 testplan-cancel --id=number [ --comment=comment ]"; | |||||||||||||||||||||||||||
| 203 | 0 | say STDERR ""; | |||||||||||||||||||||||||||
| 204 | 0 | say STDERR " --id=number Cancel the testplan with this id. Can be specified multiple times. Required at least once."; | |||||||||||||||||||||||||||
| 205 | 0 | say STDERR " --comment=comment Specify a comment to add to the cancelled testruns."; | |||||||||||||||||||||||||||
| 206 | 0 | say STDERR " --help Print this help message and exit."; | |||||||||||||||||||||||||||
| 207 | 0 | exit -1; | |||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | 0 | require Tapper::Cmd::Testplan; | |||||||||||||||||||||||||||
| 211 | 0 | my $cmd = Tapper::Cmd::Testplan->new(); | |||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | 0 | ▶ | my $comment = $opt->{comment} || "Cancelled from Tapper CLI"; | ||||||||||||||||||||||||||
|
Condition0%0/2
$opt->{'comment'} || 'Cancelled from Tapper CLI'
MC/DC0%0/1
$opt->{'comment'} || 'Cancelled from Tapper CLI'
$opt->{'comment'}
Truth table0%0/2
A
A= $opt->{'comment'}
| |||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | 0 | foreach my $testplan (@{$opt->{id}}) { | |||||||||||||||||||||||||||
| 216 | 0 | print "Cancelling testplan $testplan\n"; | |||||||||||||||||||||||||||
| 217 | 0 | $cmd->cancel( $testplan, $comment ); | |||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||
| 219 | 0 | return; | |||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||
| 224 | sub setup | ||||||||||||||||||||||||||||
| 225 | 71 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
setup: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 226 | 71 | my ($c) = @_; | |||||||||||||||||||||||||||
| 227 | 71 | $c->register('testplan-send', \&testplansend, 'Send choosen testplan reports'); | |||||||||||||||||||||||||||
| 228 | 71 | $c->register('testplan-list', \&testplanlist, 'List testplans matching a given pattern'); | |||||||||||||||||||||||||||
| 229 | 71 | $c->register('testplan-cancel', \&testplancancel, 'Cancel testplans with given IDs'); | |||||||||||||||||||||||||||
| 230 | 71 | $c->register('testplan-tj-send', \&testplan_tj_send, 'Send all testplan reports that are due according to taskjuggler plan'); | |||||||||||||||||||||||||||
| 231 | 71 | $c->register('testplan-tj-generate', \&testplan_tj_generate, 'Apply all testplans that are due according to taskjuggler plan'); | |||||||||||||||||||||||||||
| 232 | 71 | $c->register('testplan-new', \&testplannew, 'Create new testplan instance from file'); | |||||||||||||||||||||||||||
| 233 | 71 | ▶ | if ($c->can('group_commands')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 234 | 0 | $c->group_commands('Testplan commands', 'testplan-send', 'testplan-list', 'testplan-tj-send', 'testplan-tj-generate', 'testplan-new'); | |||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||
| 236 | 71 | return; | |||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | 73 | 1; # End of Tapper::CLI | |||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||
| 241 | __END__ | ||||||||||||||||||||||||||||