| 1 | # ABSTRACT: Utilities for the testrail command line functions, and their main loops. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # PODNAME: TestRail::Utils | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | package TestRail::Utils; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 28 | $TestRail::Utils::VERSION = '0.052'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 28 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 28 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 28 | ▶ | use Carp qw{confess cluck}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 28 | ▶ | use Pod::Usage (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 28 | ▶ | use TestRail::API; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 28 | ▶ | use IO::Interactive::Tiny (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 28 | ▶ | use Term::ANSIColor 2.01 qw(colorstrip); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 28 | ▶ | use Term::ReadKey (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 28 | ▶ | use Scalar::Util qw{blessed}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 17 | ▶ | sub help { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
help: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 17 | Pod::Usage::pod2usage( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | '-verbose' => 2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | '-noperldoc' => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | '-exitval' => 'NOEXIT' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 17 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | sub userInput { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
userInput: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | my ($echo_ok) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | my $input = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | # I'm going to be super paranoid here and consider everything to be sensitive info by default. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | Term::ReadKey::ReadMode('noecho') unless $echo_ok; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | local $SIG{'INT'} = sub { Term::ReadKey::ReadMode(0); exit 130; }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | $input = <STDIN>; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | chomp($input) if $input; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | Term::ReadKey::ReadMode(0) unless $echo_ok; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | print "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | return $input; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 43 | ▶ | sub interrogateUser { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
interrogateUser: called CC=4 SCAR=18.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 43 | my ( $options, @keys ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 43 | foreach my $key (@keys) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 188 | ▶ | if ( !$options->{$key} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | print "Type the $key for your TestRail install below:\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | $options->{$key} = TestRail::Utils::userInput( $key ne 'password' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | die "$key cannot be blank!" unless $options->{$key}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 43 | return $options; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 2 | ▶ | sub parseConfig { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parseConfig: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 2 | my ( $homedir, $login_only ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 2 | my $results = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 2 | my $arr = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 2 | ▶ | open( my $fh, '<', $homedir . '/.testrailrc' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | or return ( undef, undef, undef ); #couldn't open! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 2 | ▶ | while (<$fh>) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 34 | chomp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 34 | @$arr = split( /=/, $_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 34 | ▶ | if ( scalar(@$arr) != 2 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 4 | warn("Could not parse $_ in '$homedir/.testrailrc'!\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 4 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 30 | $results->{ lc( $arr->[0] ) } = $arr->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 2 | close($fh); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 2 | ▶ | return ( $results->{'apiurl'}, $results->{'password'}, $results->{'user'} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | if $login_only; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 1 | return $results; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 392 | ▶ | sub getFilenameFromTapLine { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getFilenameFromTapLine: called CC=8 SCAR=20.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 392 | my $orig = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 392 | $orig =~ s/ *$//g; # Strip all trailing whitespace | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | #Special case | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 392 | my ($is_skipall) = $orig =~ /(.*)\.+ skipped:/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 392 | ▶ | return $is_skipall if $is_skipall; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 390 | my @process_split = split( / /, $orig ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 390 | ▶ | return 0 unless scalar(@process_split); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 363 | my $dotty = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | pop @process_split; #remove the ........ (may repeat a number of times) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 363 | ▶ | return 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | if $dotty =~ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | /\d/; #Apparently looking for literal dots returns numbers too. who knew? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 244 | chomp $dotty; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 244 | my $line = join( ' ', @process_split ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | #IF it ends in a bunch of dots | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | #AND it isn't an ok/not ok | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | #AND it isn't a comment | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | #AND it isn't blank | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | #THEN it's a test name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 244 | ▶ | return $line | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%6/9
$dotty =~ /^\.+$/ and not $line =~ /^ok|not ok/ and not $line =~ /^# / and $line
$dotty =~ /^\.+$/ and not $line =~ /^ok|not ok/ and not $line =~ /^# /
$dotty =~ /^\.+$/ and not $line =~ /^ok|not ok/
MC/DC25%1/4
$dotty =~ /^\.+$/ and not $line =~ /^ok|not ok/ and not $line =~ /^# / and $line
$dotty =~ /^\.+$/
not $line =~ /^ok|not ok/
not $line =~ /^# /
$line
Truth table40%2/5
A and not(B) and not(C) and D
A= $dotty =~ /^\.+$/B= not $line =~ /^ok|not ok/C= not $line =~ /^# /D= $line
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | if ( $dotty =~ /^\.+$/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | && !( $line =~ /^ok|not ok/ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | && !( $line =~ /^# / ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | && $line ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 204 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 9 | ▶ | sub TAP2TestFiles { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TAP2TestFiles: called CC=11 SCAR=32.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 9 | my $file = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 9 | my ( $fh, $fcontents, @files ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 9 | ▶ | if ($file) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 9 | open( $fh, '<', $file ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 9 | ▶ | while (<$fh>) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 197 | $_ = colorstrip($_); #strip prove brain damage | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 197 | ▶ | if ( getFilenameFromTapLine($_) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 17 | ▶ | push( @files, $fcontents ) if $fcontents; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 17 | $fcontents = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 197 | $fcontents .= $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 9 | close($fh); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 9 | ▶ | push( @files, $fcontents ) if $fcontents; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | #Just read STDIN, print help if no file was passed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | die | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | "ERROR: no file passed, and no data piped in! See --help for usage.\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | if IO::Interactive::Tiny::is_interactive(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | while (<>) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | $_ = colorstrip($_); #strip prove brain damage | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | if ( getFilenameFromTapLine($_) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | push( @files, $fcontents ) if $fcontents; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | $fcontents = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | $fcontents .= $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | push( @files, $fcontents ) if $fcontents; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 9 | return @files; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 46 | ▶ | sub getRunInformation { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getRunInformation: called CC=9 SCAR=22.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 46 | my ( $tr, $opts ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 46 | ▶ | confess("First argument must be instance of TestRail::API") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | unless blessed($tr) eq 'TestRail::API'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 46 | my $project = $tr->getProjectByName( $opts->{'project'} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 46 | ▶ | confess "No such project '$opts->{project}'.\n" if !$project; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 45 | my ( $run, $plan ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 45 | ▶ | if ( $opts->{'plan'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 24 | $plan = $tr->getPlanByName( $project->{'id'}, $opts->{'plan'} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 24 | ▶ | confess "No such plan '$opts->{plan}'!\n" if !$plan; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | $run = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 23 | $tr->getChildRunByName( $plan, $opts->{'run'}, $opts->{'configs'} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 21 | $run = $tr->getRunByName( $project->{'id'}, $opts->{'run'} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 44 | ▶ | confess | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | "No such run '$opts->{run}' matching the provided configs (if any).\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | if !$run; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | #If the run/plan has a milestone set, then return it too | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 41 | my $milestone; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 41 | ▶ | my $mid = $plan ? $plan->{'milestone_id'} : $run->{'milestone_id'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 41 | ▶ | if ($mid) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 20 | $milestone = $tr->getMilestoneByID($mid); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 20 | ▶ | confess "Could not fetch run milestone!" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | unless $milestone; #hope this doesn't happen | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 41 | return ( $project, $plan, $run, $milestone ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 37 | ▶ | sub getHandle { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getHandle: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 37 | my $opts = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 37 | ▶ | $opts->{'debug'} = 1 if ( $opts->{'browser'} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | my $tr = TestRail::API->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | $opts->{apiurl}, $opts->{user}, $opts->{password}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 37 | $opts->{'encoding'}, $opts->{'debug'} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 37 | ▶ | if ( $opts->{'browser'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 37 | $tr->{'browser'} = $opts->{'browser'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 37 | $tr->{'debug'} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 37 | return $tr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 28 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||