line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
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
|
|
|
|
|
|
|
$TestRail::Bin::Report::VERSION = '0.050'; |
7
|
1
|
|
|
1
|
|
608
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
31
|
|
8
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
494
|
use TestRail::Utils; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
44
|
|
11
|
1
|
|
|
1
|
|
766
|
use Getopt::Long qw{GetOptionsFromArray}; |
|
1
|
|
|
|
|
10690
|
|
|
1
|
|
|
|
|
4
|
|
12
|
1
|
|
|
1
|
|
816
|
use Test::Rail::Parser; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
43
|
|
13
|
1
|
|
|
1
|
|
529
|
use File::HomeDir qw{my_home}; |
|
1
|
|
|
|
|
5875
|
|
|
1
|
|
|
|
|
541
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
if ( !caller() ) { |
16
|
|
|
|
|
|
|
my ( $out, $code ) = run( 'args' => \@ARGV ); |
17
|
|
|
|
|
|
|
print $out; |
18
|
|
|
|
|
|
|
exit $code; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
#Main loop------------ |
22
|
|
|
|
|
|
|
sub run { |
23
|
8
|
|
|
8
|
|
28292
|
my %params = @_; |
24
|
8
|
|
|
|
|
17
|
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
|
8
|
|
|
|
|
137
|
); |
46
|
|
|
|
|
|
|
|
47
|
8
|
100
|
|
|
|
14775
|
if ( $opts{help} ) { return ( '', TestRail::Utils::help() ); } |
|
1
|
|
|
|
|
9
|
|
48
|
7
|
|
|
|
|
20
|
$opts{'browser'} = $params{'browser'}; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
#Parse config file if we are missing api url/key or user |
51
|
7
|
|
50
|
|
|
27
|
my $homedir = my_home() || '.'; |
52
|
7
|
50
|
0
|
|
|
359
|
if ( -e $homedir . '/.testrailrc' |
|
|
|
33
|
|
|
|
|
53
|
|
|
|
|
|
|
&& ( !$opts{apiurl} || !$opts{password} || !$opts{user} ) ) |
54
|
|
|
|
|
|
|
{ |
55
|
0
|
|
|
|
|
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
|
|
|
|
|
28
|
my $file = $params{'args'}->[0]; |
61
|
7
|
50
|
33
|
|
|
115
|
die "No Such File $file" if ( $file && !-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
|
50
|
33
|
|
|
78
|
|| !$opts{project} ); |
|
|
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
7
|
|
|
|
|
287
|
print "testrail-report\n----------------------\n"; |
72
|
|
|
|
|
|
|
|
73
|
7
|
|
|
|
|
44
|
my @files = TestRail::Utils::TAP2TestFiles($file); |
74
|
|
|
|
|
|
|
|
75
|
7
|
|
|
|
|
31
|
TestRail::Utils::interrogateUser( \%opts, |
76
|
|
|
|
|
|
|
qw{apiurl user password project run} ); |
77
|
|
|
|
|
|
|
|
78
|
7
|
100
|
|
|
|
22
|
$opts{result_options} = { 'version' => $opts{version} } if $opts{version}; |
79
|
|
|
|
|
|
|
|
80
|
7
|
50
|
|
|
|
40
|
$opts{'debug'} = 1 if $opts{'browser'}; |
81
|
|
|
|
|
|
|
|
82
|
7
|
|
|
|
|
10
|
my $tap; |
83
|
7
|
|
|
|
|
13
|
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
|
|
|
|
|
233
|
'merge' => 1 |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
); |
107
|
8
|
|
|
|
|
54
|
$tap->run(); |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
#all done |
111
|
7
|
|
|
|
|
1156
|
return ( "Done.\n", 0 ); |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
1; |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
__END__ |