| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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() || '.'
MC/DC0%0/1
my_home() || '.'
my_home()
Truth table50%1/2
A
A= my_home()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 7 | ▶ | if ( -e $homedir . '/.testrailrc' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition11%1/9
-e $homedir . '/.testrailrc' and not $opts{"apiurl"} && $opts{"password"} && $opts{"user"}
$opts{'apiurl'} && $opts{'password'} && $opts{'user'}
$opts{"apiurl"} and $opts{"password"}
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'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition33%1/3
$file and not -e $file
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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition33%4/12
$opts{"run"} and $opts{"apiurl"} and $opts{"password"} and $opts{"user"} and $opts{"project"}
$opts{"run"} and $opts{"apiurl"} and $opts{"password"} and $opts{"user"}
$opts{"run"} and $opts{"apiurl"} and $opts{"password"}
$opts{"run"} and $opts{"apiurl"}
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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 7 | ▶ | $opts{'debug'} = 1 if $opts{'browser'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||