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.052'; |
7
|
1
|
|
|
1
|
|
595
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
8
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
431
|
use TestRail::Utils; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
35
|
|
11
|
1
|
|
|
1
|
|
620
|
use Getopt::Long qw{GetOptionsFromArray}; |
|
1
|
|
|
|
|
9282
|
|
|
1
|
|
|
|
|
4
|
|
12
|
1
|
|
|
1
|
|
668
|
use Test::Rail::Parser; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
35
|
|
13
|
1
|
|
|
1
|
|
453
|
use File::HomeDir qw{my_home}; |
|
1
|
|
|
|
|
4781
|
|
|
1
|
|
|
|
|
488
|
|
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
|
|
27463
|
my %params = @_; |
24
|
8
|
|
|
|
|
14
|
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
|
|
|
|
|
146
|
); |
46
|
|
|
|
|
|
|
|
47
|
8
|
100
|
|
|
|
12632
|
if ( $opts{help} ) { return ( '', TestRail::Utils::help() ); } |
|
1
|
|
|
|
|
8
|
|
48
|
7
|
|
|
|
|
16
|
$opts{'browser'} = $params{'browser'}; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
#Parse config file if we are missing api url/key or user |
51
|
7
|
|
50
|
|
|
29
|
my $homedir = my_home() || '.'; |
52
|
7
|
50
|
0
|
|
|
339
|
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
|
|
|
|
|
22
|
my $file = $params{'args'}->[0]; |
61
|
7
|
50
|
33
|
|
|
103
|
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
|
|
|
77
|
|| !$opts{project} ); |
|
|
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
7
|
|
|
|
|
291
|
print "testrail-report\n----------------------\n"; |
72
|
|
|
|
|
|
|
|
73
|
7
|
|
|
|
|
44
|
my @files = TestRail::Utils::TAP2TestFiles($file); |
74
|
|
|
|
|
|
|
|
75
|
7
|
|
|
|
|
32
|
TestRail::Utils::interrogateUser( \%opts, |
76
|
|
|
|
|
|
|
qw{apiurl user password project run} ); |
77
|
|
|
|
|
|
|
|
78
|
7
|
100
|
|
|
|
23
|
$opts{result_options} = { 'version' => $opts{version} } if $opts{version}; |
79
|
|
|
|
|
|
|
|
80
|
7
|
50
|
|
|
|
37
|
$opts{'debug'} = 1 if $opts{'browser'}; |
81
|
|
|
|
|
|
|
|
82
|
7
|
|
|
|
|
11
|
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
|
|
|
|
|
225
|
'merge' => 1 |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
); |
107
|
8
|
|
|
|
|
60
|
$tap->run(); |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
#all done |
111
|
7
|
|
|
|
|
1161
|
return ( "Done.\n", 0 ); |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
1; |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
__END__ |