| 1 | # PODNAME: TestRail::Utils::Find | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Find runs and tests according to user specifications. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||
| 4 | package TestRail::Utils::Find; | ||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 20 | $TestRail::Utils::Find::VERSION = '0.052'; | |||||||||||||||||||||||||||||||||||||||||||||
| 6 | 20 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 20 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 20 | ▶ | use Carp qw{confess cluck}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 20 | ▶ | use Scalar::Util qw{blessed}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 20 | ▶ | use List::Util qw{any first}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 20 | ▶ | use List::MoreUtils qw{uniq}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 20 | ▶ | use File::Find; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 20 | ▶ | use Cwd qw{abs_path}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 20 | ▶ | use File::Basename qw{basename}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 20 | ▶ | use Hash::Merge qw{merge}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 20 | ▶ | use MCE::Loop; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 20 | ▶ | use TestRail::Utils; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 13 | ▶ | sub findRuns { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
findRuns: called CC=20 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 13 | my ( $opts, $tr ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 25 | 13 | ▶ | confess("TestRail handle must be provided as argument 2") | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 26 | unless blessed($tr) eq 'TestRail::API'; | ||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 13 | my ($status_labels); | |||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||
| 30 | #Process statuses | ||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 13 | ▶ | if ( $opts->{'statuses'} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 3 | @$status_labels = $tr->statusNamesToLabels( @{ $opts->{'statuses'} } ); | |||||||||||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 13 | my $project = $tr->getProjectByName( $opts->{'project'} ); | |||||||||||||||||||||||||||||||||||||||||||||
| 36 | 13 | ▶ | confess("No such project '$opts->{project}'.\n") if !$project; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 13 | my $pconfigs = []; | |||||||||||||||||||||||||||||||||||||||||||||
| 39 | @$pconfigs = | ||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 3 | $tr->translateConfigNamesToIds( $project->{'id'}, @{ $opts->{configs} } ) | |||||||||||||||||||||||||||||||||||||||||||||
| 41 | 13 | ▶ | if $opts->{'configs'}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 13 | my ( $runs, $plans, $planRuns, $cruns, $found ) = ( [], [], [], [], 0 ); | |||||||||||||||||||||||||||||||||||||||||||||
| 44 | $runs = $tr->getRuns( $project->{'id'} ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 13 | ▶ | if ( !$opts->{'configs'} ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 46 | ; # If configs are passed, global runs are not in consideration. | ||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 13 | $plans = $tr->getPlans( $project->{'id'} ); | |||||||||||||||||||||||||||||||||||||||||||||
| 48 | 13 | @$plans = map { $tr->getPlanByID( $_->{'id'} ) } @$plans; | |||||||||||||||||||||||||||||||||||||||||||||
| 49 | 13 | foreach my $plan (@$plans) { | |||||||||||||||||||||||||||||||||||||||||||||
| 50 | 65 | $cruns = $tr->getChildRuns($plan); | |||||||||||||||||||||||||||||||||||||||||||||
| 51 | 65 | ▶ | next if !$cruns; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 65 | foreach my $run (@$cruns) { | |||||||||||||||||||||||||||||||||||||||||||||
| 53 | 143 | ▶ | next if scalar(@$pconfigs) != scalar( @{ $run->{'config_ids'} } ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||
| 55 | #Compare run config IDs against desired, invalidate run if all conditions not satisfied | ||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 11 | $found = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 57 | 11 | foreach my $cid ( @{ $run->{'config_ids'} } ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 58 | 11 | ▶ | $found++ if grep { $_ == $cid } @$pconfigs; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 11 | $run->{'created_on'} = $plan->{'created_on'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 61 | 11 | $run->{'milestone_id'} = $plan->{'milestone_id'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 62 | push( @$planRuns, $run ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 11 | ▶ | if $found == scalar( @{ $run->{'config_ids'} } ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 13 | push( @$runs, @$planRuns ); | |||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 13 | ▶ | if ( $opts->{'statuses'} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 3 | @$runs = $tr->getRunSummary(@$runs); | |||||||||||||||||||||||||||||||||||||||||||||
| 71 | 3 | @$runs = grep { defined( $_->{'run_status'} ) } | |||||||||||||||||||||||||||||||||||||||||||||
| 72 | @$runs; #Filter stuff with no results | ||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 3 | foreach my $status (@$status_labels) { | |||||||||||||||||||||||||||||||||||||||||||||
| 74 | 3 | @$runs = grep { $_->{'run_status'}->{$status} } | |||||||||||||||||||||||||||||||||||||||||||||
| 75 | @$runs; #If it's positive, keep it. Otherwise forget it. | ||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||
| 79 | #Sort FIFO/LIFO by milestone or creation date of run | ||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 13 | my $sortkey = 'created_on'; | |||||||||||||||||||||||||||||||||||||||||||||
| 81 | 13 | ▶ | if ( $opts->{'milesort'} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 82 | @$runs = map { | ||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 3 | my $run = $_; | |||||||||||||||||||||||||||||||||||||||||||||
| 84 | $run->{'milestone'} = | ||||||||||||||||||||||||||||||||||||||||||||||
| 85 | $tr->getMilestoneByID( $run->{'milestone_id'} ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 15 | ▶ | if $run->{'milestone_id'}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 87 | my $milestone = | ||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 15 | ▶ | $run->{'milestone'} ? $run->{'milestone'}->{'due_on'} : 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 15 | $run->{'due_on'} = $milestone; | |||||||||||||||||||||||||||||||||||||||||||||
| 90 | 15 | $run | |||||||||||||||||||||||||||||||||||||||||||||
| 91 | } @$runs; | ||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 3 | $sortkey = 'due_on'; | |||||||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||
| 95 | #Suppress 'no such option' warnings | ||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 13 | ▶ | @$runs = map { $_->{$sortkey} //= ''; $_ } @$runs; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$_->{$sortkey} //= ""
MC/DC100%1/1
$_->{$sortkey} //= ""
$_->{$sortkey}
Truth table100%2/2
A
A= $_->{$sortkey}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 13 | ▶ | if ( $opts->{'lifo'} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 3 | @$runs = sort { $b->{$sortkey} cmp $a->{$sortkey} } @$runs; | |||||||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 100 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 10 | @$runs = sort { $a->{$sortkey} cmp $b->{$sortkey} } @$runs; | |||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 13 | return $runs; | |||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 27 | ▶ | sub getTests { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getTests: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 27 | my ( $opts, $tr ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 109 | 27 | ▶ | confess("TestRail handle must be provided as argument 2") | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 110 | unless blessed($tr) eq 'TestRail::API'; | ||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 27 | my ( undef, undef, $run ) = | |||||||||||||||||||||||||||||||||||||||||||||
| 113 | TestRail::Utils::getRunInformation( $tr, $opts ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 25 | my ( $status_ids, $user_ids ); | |||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||
| 116 | #Process statuses | ||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 4 | @$status_ids = $tr->statusNamesToIds( @{ $opts->{'statuses'} } ) | |||||||||||||||||||||||||||||||||||||||||||||
| 118 | 25 | ▶ | if $opts->{'statuses'}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||
| 120 | #Process assignedto ids | ||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 4 | @$user_ids = $tr->userNamesToIds( @{ $opts->{'users'} } ) | |||||||||||||||||||||||||||||||||||||||||||||
| 122 | 25 | ▶ | if $opts->{'users'}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 25 | my $cases = $tr->getTests( $run->{'id'}, $status_ids, $user_ids ); | |||||||||||||||||||||||||||||||||||||||||||||
| 125 | 25 | return ( $cases, $run ); | |||||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 46 | ▶ | sub findTests { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
findTests: called CC=29 SCAR=33.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 46 | my ( $opts, @cases ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||
| 131 | confess "Error! match and no-match options are mutually exclusive.\n" | ||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 46 | ▶ | if ( $opts->{'match'} && $opts->{'no-match'} ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$opts->{"match"} and $opts->{"no-match"}
MC/DC100%2/2
$opts->{"match"} and $opts->{"no-match"}
$opts->{"match"}
$opts->{"no-match"}
Truth table100%3/3
A and B
A= $opts->{"match"}B= $opts->{"no-match"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 133 | confess "Error! match and orphans options are mutually exclusive.\n" | ||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 45 | ▶ | if ( $opts->{'match'} && $opts->{'orphans'} ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$opts->{"match"} and $opts->{"orphans"}
MC/DC100%2/2
$opts->{"match"} and $opts->{"orphans"}
$opts->{"match"}
$opts->{"orphans"}
Truth table100%3/3
A and B
A= $opts->{"match"}B= $opts->{"orphans"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 135 | confess "Error! no-match and orphans options are mutually exclusive.\n" | ||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 44 | ▶ | if ( $opts->{'orphans'} && $opts->{'no-match'} ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$opts->{"orphans"} and $opts->{"no-match"}
MC/DC100%2/2
$opts->{"orphans"} and $opts->{"no-match"}
$opts->{"orphans"}
$opts->{"no-match"}
Truth table100%3/3
A and B
A= $opts->{"orphans"}B= $opts->{"no-match"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 43 | my @tests = @cases; | |||||||||||||||||||||||||||||||||||||||||||||
| 138 | 43 | my (@realtests); | |||||||||||||||||||||||||||||||||||||||||||||
| 139 | 43 | ▶ | my $ext = $opts->{'extension'} // ''; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$opts->{"extension"} // ""
MC/DC100%1/1
$opts->{"extension"} // ""
$opts->{"extension"}
Truth table100%2/2
A
A= $opts->{"extension"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 43 | ▶ | if ( $opts->{'match'} || $opts->{'no-match'} || $opts->{'orphans'} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$opts->{"match"} or $opts->{"no-match"} or $opts->{"orphans"}
$opts->{"match"} or $opts->{"no-match"}
MC/DC100%3/3
$opts->{"match"} or $opts->{"no-match"} or $opts->{"orphans"}
$opts->{"match"}
$opts->{"no-match"}
$opts->{"orphans"}
Truth table100%4/4
A or B or C
A= $opts->{"match"}B= $opts->{"no-match"}C= $opts->{"orphans"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 32 | my @tmpArr = (); | |||||||||||||||||||||||||||||||||||||||||||||
| 143 | my $dir = | ||||||||||||||||||||||||||||||||||||||||||||||
| 144 | ( $opts->{'match'} || $opts->{'orphans'} ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 145 | ? ( $opts->{'match'} || $opts->{'orphans'} ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 32 | ▶ | : $opts->{'no-match'}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$opts->{"match"} or $opts->{"orphans"}
$opts->{"match"} or $opts->{"orphans"}
MC/DC100%2/2
$opts->{"match"} or $opts->{"orphans"}
$opts->{"match"}
$opts->{"orphans"}
MC/DC0%0/2
$opts->{"match"} or $opts->{"orphans"}
$opts->{"match"}
$opts->{"orphans"}
Truth table100%3/3
A or B
A= $opts->{"match"}B= $opts->{"orphans"}
Truth table66%2/3
A or B
A= $opts->{"match"}B= $opts->{"orphans"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 32 | ▶ | confess "No such directory '$dir'" if !-d $dir; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 32 | ▶ | if ( ref( $opts->{finder} ) eq 'CODE' ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 1 | @realtests = $opts->{finder}->( $dir, $ext ); | |||||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 152 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 31 | ▶ | if ( !$opts->{'no-recurse'} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 154 | File::Find::find( | ||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 1449 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 1449 | ▶ | push( @realtests, $File::Find::name ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
-f $_ and /\Q$ext\E$/
MC/DC100%2/2
-f $_ and /\Q$ext\E$/
-f $_
/\Q$ext\E$/
Truth table100%3/3
A and B
A= -f $_B= /\Q$ext\E$/
| |||||||||||||||||||||||||||||||||||||||||||||||
| 157 | if -f && m/\Q$ext\E$/; | ||||||||||||||||||||||||||||||||||||||||||||||
| 158 | }, | ||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 23 | $dir | |||||||||||||||||||||||||||||||||||||||||||||
| 160 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 162 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 20 | ▶ | @realtests = glob("$dir/*$ext"); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 31 | foreach my $case (@cases) { | |||||||||||||||||||||||||||||||||||||||||||||
| 167 | 105 | foreach my $path (@realtests) { | |||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||
| 169 | #Filter obviously bogus stuff first to not incur basename() cost except for when we're right, or have a name that contains this name | ||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 2761 | ▶ | next unless index( $path, $case->{'title'} ) > 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 59 | ▶ | next unless basename($path) eq $case->{title}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 57 | $case->{'path'} = $path; | |||||||||||||||||||||||||||||||||||||||||||||
| 173 | 57 | push( @tmpArr, $case ); | |||||||||||||||||||||||||||||||||||||||||||||
| 174 | 57 | last; | |||||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 177 | @tmpArr = grep { | ||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 11 | my $otest = $_; | |||||||||||||||||||||||||||||||||||||||||||||
| 179 | 11 | !( grep { $otest->{'title'} eq $_->{'title'} } @tmpArr ) | |||||||||||||||||||||||||||||||||||||||||||||
| 180 | 31 | ▶ | } @tests if $opts->{'orphans'}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 31 | @tests = @tmpArr; | |||||||||||||||||||||||||||||||||||||||||||||
| 182 | 154 | @tests = map { { 'title' => $_ } } grep { | |||||||||||||||||||||||||||||||||||||||||||||
| 183 | 172 | my $otest = basename($_); | |||||||||||||||||||||||||||||||||||||||||||||
| 184 | 172 | scalar( grep { basename( $_->{'title'} ) eq $otest } @tests ) == 0 | |||||||||||||||||||||||||||||||||||||||||||||
| 185 | 31 | ▶ | } @realtests if $opts->{'no-match'}; #invert the list in this case. | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 21 | @tests = map { abs_path( $_->{'path'} ) } @tests | |||||||||||||||||||||||||||||||||||||||||||||
| 189 | 42 | ▶ | if $opts->{'match'} && $opts->{'names-only'}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$opts->{"match"} and $opts->{"names-only"}
MC/DC100%2/2
$opts->{"match"} and $opts->{"names-only"}
$opts->{"match"}
$opts->{"names-only"}
Truth table100%3/3
A and B
A= $opts->{"match"}B= $opts->{"names-only"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 12 | @tests = map { $_->{'full_title'} = abs_path( $_->{'path'} ); $_ } @tests | |||||||||||||||||||||||||||||||||||||||||||||
| 191 | 42 | ▶ | if $opts->{'match'} && !$opts->{'names-only'}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$opts->{"match"} and not $opts->{"names-only"}
MC/DC100%2/2
$opts->{"match"} and not $opts->{"names-only"}
$opts->{"match"}
not $opts->{"names-only"}
Truth table100%3/3
A and not(B)
A= $opts->{"match"}B= not $opts->{"names-only"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 158 | @tests = map { $_->{'title'} } @tests | |||||||||||||||||||||||||||||||||||||||||||||
| 193 | 42 | ▶ | if !$opts->{'match'} && $opts->{'names-only'}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $opts->{"match"} and $opts->{"names-only"}
MC/DC100%2/2
not $opts->{"match"} and $opts->{"names-only"}
not $opts->{"match"}
$opts->{"names-only"}
Truth table100%3/3
not(A) and B
A= not $opts->{"match"}B= $opts->{"names-only"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 42 | return @tests; | |||||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 4 | ▶ | sub getCases { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getCases: called CC=9 SCAR=24.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 4 | my ( $opts, $tr ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 200 | 4 | ▶ | confess("First argument must be instance of TestRail::API") | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 201 | unless blessed($tr) eq 'TestRail::API'; | ||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 4 | my $project = $tr->getProjectByName( $opts->{'project'} ); | |||||||||||||||||||||||||||||||||||||||||||||
| 204 | 4 | ▶ | confess "No such project '$opts->{project}'.\n" if !$project; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||
| 206 | my $suite = | ||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 4 | $tr->getTestSuiteByName( $project->{'id'}, $opts->{'testsuite'} ); | |||||||||||||||||||||||||||||||||||||||||||||
| 208 | 4 | ▶ | confess "No such testsuite '$opts->{testsuite}'.\n" if !$suite; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 4 | $opts->{'testsuite_id'} = $suite->{'id'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 4 | my $section; | |||||||||||||||||||||||||||||||||||||||||||||
| 212 | $section = | ||||||||||||||||||||||||||||||||||||||||||||||
| 213 | $tr->getSectionByName( $project->{'id'}, $suite->{'id'}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 214 | $opts->{'section'} ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 4 | ▶ | if $opts->{'section'}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 216 | confess "No such section '$opts->{section}.\n" | ||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 4 | ▶ | if $opts->{'section'} && !$section; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$opts->{"section"} and not $section
MC/DC0%0/2
$opts->{"section"} and not $section
$opts->{"section"}
not $section
Truth table33%1/3
A and not(B)
A= $opts->{"section"}B= not $section
| |||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 4 | my $section_id; | |||||||||||||||||||||||||||||||||||||||||||||
| 220 | 4 | ▶ | $section_id = $section->{'id'} if ref $section eq "HASH"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 4 | my $type_ids; | |||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | @$type_ids = $tr->typeNamesToIds( @{ $opts->{'types'} } ) | |||||||||||||||||||||||||||||||||||||||||||||
| 224 | 4 | ▶ | if ref $opts->{'types'} eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||||||
| 226 | #Above will confess if anything's the matter | ||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||
| 228 | #TODO Translate opts into filters | ||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 4 | my $filters = { | |||||||||||||||||||||||||||||||||||||||||||||
| 230 | 'section_id' => $section_id, | ||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 'type_id' => $type_ids | ||||||||||||||||||||||||||||||||||||||||||||||
| 232 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 4 | return $tr->getCases( $project->{'id'}, $suite->{'id'}, $filters ); | |||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 11 | ▶ | sub findCases { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
findCases: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 11 | my ( $opts, @cases ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||
| 240 | confess('testsuite_id parameter mandatory in options HASHREF') | ||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 11 | ▶ | unless defined $opts->{'testsuite_id'}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 242 | confess('Directory parameter mandatory in options HASHREF.') | ||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 10 | ▶ | unless defined $opts->{'directory'}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 244 | confess( 'No such directory "' . $opts->{'directory'} . "\"\n" ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 9 | ▶ | unless -d $opts->{'directory'}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 8 | my $ret = { 'testsuite_id' => $opts->{'testsuite_id'} }; | |||||||||||||||||||||||||||||||||||||||||||||
| 248 | 8 | ▶ | if ( !$opts->{'no-missing'} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 249 | my $mopts = { | ||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 'no-match' => $opts->{'directory'}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 'names-only' => 1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 3 | 'extension' => $opts->{'extension'} | |||||||||||||||||||||||||||||||||||||||||||||
| 253 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 3 | my @missing = findTests( $mopts, @cases ); | |||||||||||||||||||||||||||||||||||||||||||||
| 255 | 3 | $ret->{'missing'} = \@missing; | |||||||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 8 | ▶ | if ( $opts->{'orphans'} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 258 | my $oopts = { | ||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 'orphans' => $opts->{'directory'}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 3 | 'extension' => $opts->{'extension'} | |||||||||||||||||||||||||||||||||||||||||||||
| 261 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 3 | my @orphans = findTests( $oopts, @cases ); | |||||||||||||||||||||||||||||||||||||||||||||
| 263 | 3 | $ret->{'orphans'} = \@orphans; | |||||||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 8 | ▶ | if ( $opts->{'update'} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 266 | my $uopts = { | ||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 'match' => $opts->{'directory'}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 3 | 'extension' => $opts->{'extension'} | |||||||||||||||||||||||||||||||||||||||||||||
| 269 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 3 | my @updates = findTests( $uopts, @cases ); | |||||||||||||||||||||||||||||||||||||||||||||
| 271 | 3 | $ret->{'update'} = \@updates; | |||||||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 8 | return $ret; | |||||||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 13 | ▶ | sub getResults { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getResults: called CC=14 SCAR=36.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 13 | my ( $tr, $opts, @cases ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 278 | 13 | my $res = {}; | |||||||||||||||||||||||||||||||||||||||||||||
| 279 | 13 | my $projects = $tr->getProjects(); | |||||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 13 | my ( @seenRunIds, @seenPlanIds ); | |||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 13 | my @results; | |||||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||||||
| 285 | #TODO obey status filtering | ||||||||||||||||||||||||||||||||||||||||||||||
| 286 | #TODO obey result notes text grepping | ||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 13 | foreach my $project (@$projects) { | |||||||||||||||||||||||||||||||||||||||||||||
| 288 | next | ||||||||||||||||||||||||||||||||||||||||||||||
| 289 | if $opts->{projects} | ||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 39 | ▶ | && !( grep { $_ eq $project->{'name'} } @{ $opts->{'projects'} } ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$opts->{"projects"} and not grep({$_ eq $project->{"name"};} @{$$opts{"projects"};})
MC/DC100%2/2
$opts->{"projects"} and not grep({$_ eq $project->{"name"};} @{$$opts{"projects"};})
$opts->{"projects"}
not grep({$_ eq $project->{"name"};} @{$$opts{"projects"};})
Truth table100%3/3
A and not(B)
A= $opts->{"projects"}B= not grep({$_ eq $project->{"name"};} @{$$opts{"projects"};})
| |||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 37 | my $runs = $tr->getRuns( $project->{'id'} ); | |||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||
| 293 | #XXX No runs, or temporary error to ignore | ||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 37 | ▶ | next unless ref($runs) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 37 | push( @seenRunIds, map { $_->{id} } @$runs ); | |||||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||||||
| 298 | #Translate plan names to ids | ||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 37 | ▶ | my $plans = $tr->getPlans( $project->{'id'} ) || []; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$tr->getPlans($project->{'id'}) || []
MC/DC0%0/1
$tr->getPlans($project->{'id'}) || []
$tr->getPlans($project->{'id'})
Truth table50%1/2
A
A= $tr->getPlans($project->{'id'})
| |||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 37 | push( @seenPlanIds, map { $_->{id} } @$plans ); | |||||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||||||
| 302 | #Filter out plans which do not match our filters to prevent a call to getPlanByID | ||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 37 | ▶ | if ( $opts->{'plans'} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 304 | @$plans = grep { | ||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 3 | my $p = $_; | |||||||||||||||||||||||||||||||||||||||||||||
| 306 | 257 | ▶ | any { $p->{'name'} eq $_ } @{ $opts->{'plans'} } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 307 | } @$plans; | ||||||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||
| 310 | #Filter out runs which do not match our filters | ||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 37 | ▶ | if ( $opts->{'runs'} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 312 | @$runs = grep { | ||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 25 | my $r = $_; | |||||||||||||||||||||||||||||||||||||||||||||
| 314 | 324 | ▶ | any { $r->{'name'} eq $_ } @{ $opts->{'runs'} } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 315 | } @$runs; | ||||||||||||||||||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||||||
| 318 | #Filter out prior plans | ||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 37 | ▶ | if ( $opts->{'plan_ids'} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 320 | @$plans = grep { | ||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 6 | my $p = $_; | |||||||||||||||||||||||||||||||||||||||||||||
| 322 | 514 | ▶ | !any { $p->{'id'} eq $_ } @{ $opts->{'plan_ids'} } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 323 | } @$plans; | ||||||||||||||||||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||||||
| 326 | #Filter out prior runs | ||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 37 | ▶ | if ( $opts->{'run_ids'} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 328 | @$runs = grep { | ||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 6 | my $r = $_; | |||||||||||||||||||||||||||||||||||||||||||||
| 330 | 504 | ▶ | !any { $r->{'id'} eq $_ } @{ $opts->{'run_ids'} } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 331 | } @$runs; | ||||||||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 37 | ▶ | $opts->{'runs'} //= []; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$opts->{"runs"} //= []
MC/DC100%1/1
$opts->{"runs"} //= []
$opts->{"runs"}
Truth table100%2/2
A
A= $opts->{"runs"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 37 | foreach my $plan (@$plans) { | |||||||||||||||||||||||||||||||||||||||||||||
| 336 | 2319 | $plan = $tr->getPlanByID( $plan->{'id'} ); | |||||||||||||||||||||||||||||||||||||||||||||
| 337 | 2319 | my $plan_runs = $tr->getChildRuns($plan); | |||||||||||||||||||||||||||||||||||||||||||||
| 338 | 2319 | ▶ | push( @$runs, @$plan_runs ) if $plan_runs; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 37 | my $configs = $tr->getConfigurations( $project->{id} ); | |||||||||||||||||||||||||||||||||||||||||||||
| 342 | 37 | my %config_map; | |||||||||||||||||||||||||||||||||||||||||||||
| 343 | 136 | @config_map{ map { $_->{'id'} } @$configs } = | |||||||||||||||||||||||||||||||||||||||||||||
| 344 | 37 | map { $_->{'name'} } @$configs; | |||||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 37 | MCE::Loop::init { | |||||||||||||||||||||||||||||||||||||||||||||
| 347 | max_workers => 'auto', | ||||||||||||||||||||||||||||||||||||||||||||||
| 348 | chunk_size => 'auto' | ||||||||||||||||||||||||||||||||||||||||||||||
| 349 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||||||
| 351 | push( | ||||||||||||||||||||||||||||||||||||||||||||||
| 352 | @results, | ||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | ▶ | mce_loop { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=17 SCAR=57.2
| |||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | my $runz = $_; | |||||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||||||
| 356 | #XXX it appears as though some versions of MCE do not have uniform passing convention | ||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | ▶ | $runz = [$runz] if ref($runz) ne 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | my $res = {}; | |||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | foreach my $run (@$runz) { | |||||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||||||
| 362 | #XXX super bad bug in some versions of MCE, apparently causes data loss, or is duping jobs with incomplete info! | ||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | ▶ | next if !$run->{id}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||||||
| 365 | #Translate config ids to names, also remove any gone configs | ||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | my @run_configs = grep { defined $_ } | |||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | map { $config_map{$_} } @{ $run->{config_ids} }; | |||||||||||||||||||||||||||||||||||||||||||||
| 368 | next | ||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | if scalar( @{ $opts->{runs} } ) | |||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | && !( grep { $_ eq $run->{'name'} } | |||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | ▶ | @{ $opts->{'runs'} } ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
scalar @{$opts->{"runs"};} and not grep({$_ eq $run->{"name"};} @{$$opts{"runs"};})
MC/DC0%0/2
scalar @{$opts->{"runs"};} and not grep({$_ eq $run->{"name"};} @{$$opts{"runs"};})
scalar @{$opts->{"runs"};}
not grep({$_ eq $run->{"name"};} @{$$opts{"runs"};})
Truth table0%0/3
A and not(B)
A= scalar @{$opts->{"runs"};}B= not grep({$_ eq $run->{"name"};} @{$$opts{"runs"};})
| |||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | ▶ | if ( $opts->{fast} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | my @csz = @cases; | |||||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | @csz = grep { ref($_) eq 'HASH' } map { | |||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | my $cname = basename($_); | |||||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | my $c = $tr->getTestByName( $run->{id}, $cname ); | |||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | $c->{config_ids} = \@run_configs; | |||||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | ▶ | $c->{name} = $cname if $c; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | $c | |||||||||||||||||||||||||||||||||||||||||||||
| 380 | } @csz; | ||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | ▶ | next unless scalar(@csz); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | my $results = $tr->getRunResults( $run->{id} ); | |||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | foreach my $c (@csz) { | |||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | ▶ | $res->{ $c->{name} } //= []; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$$res{$c->{"name"}} //= []
MC/DC0%0/1
$$res{$c->{"name"}} //= []
$$res{$c->{"name"}}
Truth table0%0/2
A
A= $$res{$c->{"name"}}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 386 | my $cres = | ||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | ▶ | first { $c->{id} == $_->{test_id} } @$results; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | ▶ | return unless $cres; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | $c->{results} = [$cres]; | |||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | $c = _filterResults( $opts, $c ); | |||||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | push( @{ $res->{ $c->{name} } }, $c ) | |||||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | ▶ | if scalar( @{ $c->{results} } ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | foreach my $case (@cases) { | |||||||||||||||||||||||||||||||||||||||||||||
| 400 | my $c = | ||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | $tr->getTestByName( $run->{'id'}, basename($case) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | ▶ | next unless ref $c eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | ▶ | $res->{$case} //= []; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$res->{$case} //= []
MC/DC0%0/1
$res->{$case} //= []
$res->{$case}
Truth table0%0/2
A
A= $res->{$case}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 405 | $c->{results} = $tr->getTestResults( $c->{'id'}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | $tr->{'global_limit'}, 0 ); | |||||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | $c->{config_ids} = \@run_configs; | |||||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | $c = _filterResults( $opts, $c ); | |||||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | push( @{ $res->{$case} }, $c ) | |||||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | ▶ | if scalar( @{ $c->{results} } ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 412 | ; #Make sure they weren't filtered out | ||||||||||||||||||||||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | return MCE->gather( MCE->chunk_id, $res ); | |||||||||||||||||||||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 37 | $runs | |||||||||||||||||||||||||||||||||||||||||||||
| 418 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 13 | foreach my $result (@results) { | |||||||||||||||||||||||||||||||||||||||||||||
| 423 | 3258 | $res = merge( $res, $result ); | |||||||||||||||||||||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 13 | return ( $res, \@seenPlanIds, \@seenRunIds ); | |||||||||||||||||||||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | ▶ | sub _filterResults { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_filterResults: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | my ( $opts, $c ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||||||
| 432 | #Filter by provided pattern, if any | ||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | ▶ | if ( $opts->{'pattern'} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | my $pattern = $opts->{pattern}; | |||||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | @{ $c->{results} } = | |||||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | ▶ | grep { my $comment = $_->{comment} || ''; $comment =~ m/$pattern/i } | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$_->{'comment'} || ''
MC/DC0%0/1
$_->{'comment'} || ''
$_->{'comment'}
Truth table0%0/2
A
A= $_->{'comment'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | @{ $c->{results} }; | |||||||||||||||||||||||||||||||||||||||||||||
| 438 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||||||||||||||
| 440 | #Filter by the provided case IDs, if any | ||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | ▶ | if ( ref( $opts->{'defects'} ) eq 'ARRAY' | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
ref $opts->{"defects"} eq "ARRAY" and scalar @{$opts->{"defects"};}
MC/DC0%0/1
ref $opts->{"defects"} eq "ARRAY" and scalar @{$opts->{"defects"};}
ref $opts->{"defects"} eq "ARRAY"
Truth table0%0/2
A
A= ref $opts->{"defects"} eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | && scalar( @{ $opts->{defects} } ) ) | |||||||||||||||||||||||||||||||||||||||||||||
| 443 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | @{ $c->{results} } = grep { | |||||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | my $defects = $_->{defects}; | |||||||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | ▶ | any { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | my $df_case = $_; | |||||||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | ▶ | any { $df_case eq $_ } @{ $opts->{defects} }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | } @$defects | |||||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | } @{ $c->{results} }; | |||||||||||||||||||||||||||||||||||||||||||||
| 451 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||||||
| 453 | #Filter by the provided versions, if any | ||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | ▶ | if ( ref( $opts->{'versions'} ) eq 'ARRAY' | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
ref $opts->{"versions"} eq "ARRAY" and scalar @{$opts->{"versions"};}
MC/DC0%0/1
ref $opts->{"versions"} eq "ARRAY" and scalar @{$opts->{"versions"};}
ref $opts->{"versions"} eq "ARRAY"
Truth table0%0/2
A
A= ref $opts->{"versions"} eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | && scalar( @{ $opts->{versions} } ) ) | |||||||||||||||||||||||||||||||||||||||||||||
| 456 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | @{ $c->{results} } = grep { | |||||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | my $version = $_->{version}; | |||||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | ▶ | any { $version eq $_ } @{ $opts->{versions} }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | } @{ $c->{results} }; | |||||||||||||||||||||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | return $c; | |||||||||||||||||||||||||||||||||||||||||||||
| 464 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 20 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||||||
| 468 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||