bin/testrail-report

filter: Statementstmt 97.7% 44 / 45 Branchbran 64.2% 9 / 14 Conditioncond 26.9% 7 / 26 MC/DCmcdc 0.0% 0 / 12 Subroutinesub 100% 7 / 7 Podpod n/a totaltotal 64.4% 67 / 104 CC 17 SCAR 32.8
CC
17
Cov
71%
run
35.5
BEGIN
1.0
BEGIN
1.0
CRAP 26.5
« bin/testrail-replay ↑ Summary blib/lib/TestRail/Utils.pm »
1 #!/usr/bin/perl
2 # ABSTRACT: Upload your TAP results to TestRail after they've finished
3 # PODNAME: TestRail::Bin::Report
4  
5 package TestRail::Bin::Report;
6 1 $TestRail::Bin::Report::VERSION = '0.052';
7 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 ▶use TestRail::Utils;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use Getopt::Long qw{GetOptionsFromArray};
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use Test::Rail::Parser;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use File::HomeDir qw{my_home};
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 1 ▶if ( !caller() ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (caller()) 1 0 1
16 1 my ( $out, $code ) = run( 'args' => \@ARGV );
17 1 print $out;
18 1 exit $code;
19 }
20  
21 #Main loop------------
22 9 ▶sub run {
Subroutine run: called CC=17 SCAR=35.7
23 9 my %params = @_;
24 9 my %opts;
25  
26 #parse switches
27 GetOptionsFromArray(
28 $params{'args'},
29 'run=s' => \$opts{run},
30 'apiurl=s' => \$opts{apiurl},
31 'password=s' => \$opts{password},
32 'user=s' => \$opts{user},
33 'project=s' => \$opts{project},
34 'step-results=s' => \$opts{step_results},
35 'config=s@' => \$opts{configs},
36 'plan=s' => \$opts{plan},
37 'version=s' => \$opts{version},
38 'testsuite_id=i' => \$opts{testsuite_id},
39 'testsuite=s' => \$opts{testsuite},
40 'section=s@' => \$opts{sections},
41 'autoclose' => \$opts{autoclose},
42 'e|encoding=s' => \$opts{encoding},
43 'max_tries=i' => \$opts{max_tries},
44 'help' => \$opts{help},
45 9 );
46  
47 9 ▶ if ( $opts{help} ) { return ( '', TestRail::Utils::help() ); }
Branch: 1 branch
BranchTrueFalseTotal
if ($opts{"help"}) 2 7 9
48 7 $opts{'browser'} = $params{'browser'};
49  
50 #Parse config file if we are missing api url/key or user
51 7 ▶ my $homedir = my_home() || '.';
Condition50%1/2
my_home() || '.'
l!l
70
MC/DC0%0/1
my_home() || '.'
my_home()
Truth table50%1/2
A
A= my_home()
Aresult
11
00
52 7 ▶ if ( -e $homedir . '/.testrailrc'
Branch: 1 branch
BranchTrueFalseTotal
if (-e $homedir . '/.testrailrc' and not $opts{"apiurl"} && $opts{"password"} && $opts{"user"}) 0 7 7
Condition11%1/9
-e $homedir . '/.testrailrc' and not $opts{"apiurl"} && $opts{"password"} && $opts{"user"}
!ll&&!rl&&r
700
$opts{'apiurl'} && $opts{'password'} && $opts{'user'}
!ll&&!rl&&r
000
$opts{"apiurl"} and $opts{"password"}
!ll&&!rl&&r
000
MC/DC0%0/4
-e $homedir . '/.testrailrc' and not $opts{"apiurl"} && $opts{"password"} && $opts{"user"}
-e $homedir . '/.testrailrc' $opts{"apiurl"} $opts{"password"} $opts{'user'}
Truth table20%1/5
A and not(B and C && D)
A= -e $homedir . '/.testrailrc'B= $opts{"apiurl"}C= $opts{"password"}D= $opts{'user'}
ABCDresult
0XXX0
11110
10XX1
110X1
11101
53 && ( !$opts{apiurl} || !$opts{password} || !$opts{user} ) )
54 {
55 0 ( $opts{apiurl}, $opts{password}, $opts{user} ) =
56 TestRail::Utils::parseConfig( $homedir, 1 );
57 }
58  
59 #If argument is passed use it instead of stdin
60 7 my $file = $params{'args'}->[0];
61 7 ▶ die "No Such File $file" if ( $file && !-e $file );
Branch: 1 branch
BranchTrueFalseTotal
if $file and not -e $file 0 7 7
Condition33%1/3
$file and not -e $file
!ll&&!rl&&r
070
MC/DC0%0/2
$file and not -e $file
$file not -e $file
Truth table33%1/3
A and not(B)
A= $fileB= not -e $file
ABresult
0X0
100
111
62  
63 die
64 "ERROR: Interactive mode not allowed when piping input. See --help for options."
65 if ( !$opts{run}
66 || !$opts{apiurl}
67 || !$opts{password}
68 || !$opts{user}
69 7 ▶ || !$opts{project} );
Branch: 1 branch
BranchTrueFalseTotal
unless $opts{"run"} and $opts{"apiurl"} and $opts{"password"} and $opts{"user"} and $opts{"project"} 0 7 7
Condition33%4/12
$opts{"run"} and $opts{"apiurl"} and $opts{"password"} and $opts{"user"} and $opts{"project"}
!ll&&!rl&&r
007
$opts{"run"} and $opts{"apiurl"} and $opts{"password"} and $opts{"user"}
!ll&&!rl&&r
007
$opts{"run"} and $opts{"apiurl"} and $opts{"password"}
!ll&&!rl&&r
007
$opts{"run"} and $opts{"apiurl"}
!ll&&!rl&&r
007
MC/DC0%0/5
$opts{"run"} and $opts{"apiurl"} and $opts{"password"} and $opts{"user"} and $opts{"project"}
$opts{"run"} $opts{"apiurl"} $opts{"password"} $opts{"user"} $opts{"project"}
Truth table16%1/6
A and B and C and D and E
A= $opts{"run"}B= $opts{"apiurl"}C= $opts{"password"}D= $opts{"user"}E= $opts{"project"}
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
70  
71 7 print "testrail-report\n----------------------\n";
72  
73 7 my @files = TestRail::Utils::TAP2TestFiles($file);
74  
75 7 TestRail::Utils::interrogateUser( \%opts,
76 qw{apiurl user password project run} );
77  
78 7 ▶ $opts{result_options} = { 'version' => $opts{version} } if $opts{version};
Branch: 1 branch
BranchTrueFalseTotal
if $opts{"version"} 1 6 7
79  
80 7 ▶ $opts{'debug'} = 1 if $opts{'browser'};
Branch: 1 branch
BranchTrueFalseTotal
if $opts{"browser"} 7 0 7
81  
82 7 my $tap;
83 7 foreach my $phil (@files) {
84 $tap = Test::Rail::Parser->new(
85 {
86 'tap' => $phil,
87 'apiurl' => $opts{apiurl},
88 'user' => $opts{user},
89 'pass' => $opts{password},
90 'run' => $opts{run},
91 'project' => $opts{project},
92 'step_results' => $opts{step_results},
93 'debug' => $opts{debug},
94 'browser' => $opts{browser},
95 'plan' => $opts{plan},
96 'configs' => $opts{configs},
97 'result_options' => $opts{result_options},
98 'testsuite_id' => $opts{testsuite_id},
99 'testsuite' => $opts{testsuite},
100 'sections' => $opts{sections},
101 'autoclose' => $opts{autoclose},
102 'encoding' => $opts{encoding},
103 'max_tries' => $opts{max_tries},
104 8 'merge' => 1
105 }
106 );
107 8 $tap->run();
108 }
109  
110 #all done
111 7 return ( "Done.\n", 0 );
112 }
113  
114 1;
115  
116 __END__
« bin/testrail-replay ↑ Summary blib/lib/TestRail/Utils.pm »