| 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.051'; |
|
7
|
1
|
|
|
1
|
|
593
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
32
|
|
|
8
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
25
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
502
|
use TestRail::Utils; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
42
|
|
|
11
|
1
|
|
|
1
|
|
725
|
use Getopt::Long qw{GetOptionsFromArray}; |
|
|
1
|
|
|
|
|
10688
|
|
|
|
1
|
|
|
|
|
5
|
|
|
12
|
1
|
|
|
1
|
|
819
|
use Test::Rail::Parser; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
80
|
|
|
13
|
1
|
|
|
1
|
|
505
|
use File::HomeDir qw{my_home}; |
|
|
1
|
|
|
|
|
5684
|
|
|
|
1
|
|
|
|
|
551
|
|
|
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
|
|
28198
|
my %params = @_; |
|
24
|
8
|
|
|
|
|
19
|
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
|
|
|
|
|
141
|
); |
|
46
|
|
|
|
|
|
|
|
|
47
|
8
|
100
|
|
|
|
14777
|
if ( $opts{help} ) { return ( '', TestRail::Utils::help() ); } |
|
|
1
|
|
|
|
|
11
|
|
|
48
|
7
|
|
|
|
|
21
|
$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
|
|
|
374
|
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
|
|
|
|
|
26
|
my $file = $params{'args'}->[0]; |
|
61
|
7
|
50
|
33
|
|
|
117
|
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
|
|
|
82
|
|| !$opts{project} ); |
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
|
71
|
7
|
|
|
|
|
309
|
print "testrail-report\n----------------------\n"; |
|
72
|
|
|
|
|
|
|
|
|
73
|
7
|
|
|
|
|
48
|
my @files = TestRail::Utils::TAP2TestFiles($file); |
|
74
|
|
|
|
|
|
|
|
|
75
|
7
|
|
|
|
|
36
|
TestRail::Utils::interrogateUser( \%opts, |
|
76
|
|
|
|
|
|
|
qw{apiurl user password project run} ); |
|
77
|
|
|
|
|
|
|
|
|
78
|
7
|
100
|
|
|
|
26
|
$opts{result_options} = { 'version' => $opts{version} } if $opts{version}; |
|
79
|
|
|
|
|
|
|
|
|
80
|
7
|
50
|
|
|
|
39
|
$opts{'debug'} = 1 if $opts{'browser'}; |
|
81
|
|
|
|
|
|
|
|
|
82
|
7
|
|
|
|
|
13
|
my $tap; |
|
83
|
7
|
|
|
|
|
14
|
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
|
|
|
|
|
238
|
'merge' => 1 |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
); |
|
107
|
8
|
|
|
|
|
58
|
$tap->run(); |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
#all done |
|
111
|
7
|
|
|
|
|
1092
|
return ( "Done.\n", 0 ); |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
1; |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
__END__ |