| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
|
2
|
|
|
|
|
|
|
# ABSTRACT: get information about cases inside various testsuites/sections. |
|
3
|
|
|
|
|
|
|
# PODNAME: TestRail::Bin::Cases |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package TestRail::Bin::Cases; |
|
6
|
|
|
|
|
|
|
$TestRail::Bin::Cases::VERSION = '0.052'; |
|
7
|
1
|
|
|
1
|
|
480
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
25
|
|
|
8
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
20
|
|
|
9
|
1
|
|
|
1
|
|
497
|
use utf8; |
|
|
1
|
|
|
|
|
12
|
|
|
|
1
|
|
|
|
|
5
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
675
|
use TestRail::API; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
53
|
|
|
12
|
1
|
|
|
1
|
|
429
|
use TestRail::Utils; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
41
|
|
|
13
|
1
|
|
|
1
|
|
510
|
use TestRail::Utils::Find; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
46
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
654
|
use Getopt::Long qw{GetOptionsFromArray}; |
|
|
1
|
|
|
|
|
9044
|
|
|
|
1
|
|
|
|
|
5
|
|
|
16
|
1
|
|
|
1
|
|
563
|
use File::HomeDir qw{my_home}; |
|
|
1
|
|
|
|
|
4872
|
|
|
|
1
|
|
|
|
|
482
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
if ( !caller() ) { |
|
19
|
|
|
|
|
|
|
my ( $out, $code ) = run( 'args' => \@ARGV ); |
|
20
|
|
|
|
|
|
|
print $out; |
|
21
|
|
|
|
|
|
|
exit $code; |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub run { |
|
25
|
4
|
|
|
4
|
|
4830
|
my %params = @_; |
|
26
|
4
|
|
|
|
|
8
|
my $opts = {}; |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
#Parse config file if we are missing api url/key or user |
|
29
|
4
|
|
50
|
|
|
14
|
my $homedir = my_home() || '.'; |
|
30
|
4
|
50
|
|
|
|
160
|
if ( -e $homedir . '/.testrailrc' ) { |
|
31
|
0
|
|
|
|
|
0
|
$opts = TestRail::Utils::parseConfig($homedir); |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
GetOptionsFromArray( |
|
35
|
|
|
|
|
|
|
$params{'args'}, |
|
36
|
|
|
|
|
|
|
'apiurl=s' => \$opts->{'apiurl'}, |
|
37
|
|
|
|
|
|
|
'password=s' => \$opts->{'password'}, |
|
38
|
|
|
|
|
|
|
'user=s' => \$opts->{'user'}, |
|
39
|
|
|
|
|
|
|
'j|project=s' => \$opts->{'project'}, |
|
40
|
|
|
|
|
|
|
't|testsuite=s' => \$opts->{'testsuite'}, |
|
41
|
|
|
|
|
|
|
'd|directory=s' => \$opts->{'directory'}, |
|
42
|
|
|
|
|
|
|
'm|missing' => \$opts->{'missing'}, |
|
43
|
|
|
|
|
|
|
'o|orphans' => \$opts->{'orphans'}, |
|
44
|
|
|
|
|
|
|
'n|no-recurse' => \$opts->{'no-recurse'}, |
|
45
|
|
|
|
|
|
|
'e|encoding=s' => \$opts->{'encoding'}, |
|
46
|
|
|
|
|
|
|
'section=s' => \$opts->{'section'}, |
|
47
|
|
|
|
|
|
|
'type=s@' => \$opts->{'types'}, |
|
48
|
|
|
|
|
|
|
'extension=s' => \$opts->{'extension'}, |
|
49
|
|
|
|
|
|
|
'h|help' => \$opts->{'help'}, |
|
50
|
4
|
|
|
|
|
51
|
'test' => \$opts->{'test'}, |
|
51
|
|
|
|
|
|
|
); |
|
52
|
|
|
|
|
|
|
|
|
53
|
4
|
100
|
|
|
|
5653
|
if ( $opts->{help} ) { return ( '', TestRail::Utils::help() ); } |
|
|
1
|
|
|
|
|
5
|
|
|
54
|
|
|
|
|
|
|
|
|
55
|
3
|
|
|
|
|
12
|
$opts->{'browser'} = $params{'browser'}; |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
#Mutual exclusivity |
|
58
|
3
|
|
|
|
|
6
|
$opts->{'no-missing'} = !$opts->{'missing'}; |
|
59
|
3
|
|
100
|
|
|
13
|
$opts->{'update'} = !( $opts->{'orphans'} || $opts->{'missing'} ); |
|
60
|
|
|
|
|
|
|
die("orphans and mising options are mutually exclusive.") |
|
61
|
3
|
50
|
66
|
|
|
10
|
if $opts->{'orphans'} && $opts->{'missing'}; |
|
62
|
3
|
|
|
|
|
42
|
delete $opts->{'missing'}; |
|
63
|
|
|
|
|
|
|
|
|
64
|
3
|
|
|
|
|
15
|
TestRail::Utils::interrogateUser( $opts, |
|
65
|
|
|
|
|
|
|
qw{apiurl user password project testsuite directory} ); |
|
66
|
|
|
|
|
|
|
|
|
67
|
3
|
|
|
|
|
8
|
my $tr = TestRail::Utils::getHandle($opts); |
|
68
|
|
|
|
|
|
|
|
|
69
|
3
|
|
|
|
|
12
|
my $cases = TestRail::Utils::Find::getCases( $opts, $tr ); |
|
70
|
3
|
50
|
|
|
|
7
|
die "No cases in TestRail!\n" unless $cases; |
|
71
|
|
|
|
|
|
|
|
|
72
|
3
|
|
|
|
|
9
|
my $tests = TestRail::Utils::Find::findCases( $opts, @$cases ); |
|
73
|
|
|
|
|
|
|
|
|
74
|
3
|
|
|
|
|
6
|
my ( @update, @add, @orphan ); |
|
75
|
1
|
|
|
|
|
3
|
@update = map { $_->{'title'} } @{ $tests->{'update'} } |
|
|
1
|
|
|
|
|
3
|
|
|
76
|
3
|
100
|
|
|
|
7
|
if ref $tests->{'update'} eq 'ARRAY'; |
|
77
|
1
|
|
|
|
|
3
|
@add = map { $_->{'title'} } @{ $tests->{'orphans'} } |
|
|
1
|
|
|
|
|
3
|
|
|
78
|
3
|
100
|
|
|
|
7
|
if ref $tests->{'orphans'} eq 'ARRAY'; |
|
79
|
3
|
100
|
|
|
|
9
|
@orphan = @{ $tests->{'missing'} } if ref $tests->{'missing'} eq 'ARRAY'; |
|
|
1
|
|
|
|
|
3
|
|
|
80
|
|
|
|
|
|
|
|
|
81
|
3
|
|
|
|
|
4
|
my $out = ''; |
|
82
|
3
|
|
|
|
|
8
|
$out .= join( "\n", @update ); |
|
83
|
3
|
|
|
|
|
5
|
$out .= join( "\n", @add ); |
|
84
|
3
|
|
|
|
|
7
|
$out .= join( "\n", @orphan ); |
|
85
|
3
|
|
|
|
|
13
|
$out .= "\n"; |
|
86
|
|
|
|
|
|
|
|
|
87
|
3
|
|
|
|
|
66
|
return ( $out, 0 ); |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
1; |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=pod |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=encoding UTF-8 |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 NAME |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
TestRail::Bin::Cases - get information about cases inside various testsuites/sections. |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 VERSION |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
version 0.052 |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
testrail-cases [OPTIONS] |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
require `which testrail-cases`; |
|
109
|
|
|
|
|
|
|
TestRail::Bin::Cases::run('args' => @args); |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
testrail-cases - get information about cases inside various testsuites/sections. |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
By default will tell you which cases are in both the testsuite and directory passed. |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Can be used as the modulino TestRail::Bin::Cases. |
|
118
|
|
|
|
|
|
|
Has a single 'run' function which accepts a hash with the 'args' parameter being the array of arguments. |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 PARAMETERS: |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head2 MANDATORY PARAMETERS |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=over 4 |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
--apiurl : full URL to get to TestRail index document |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
--password : Your TestRail Password, or a valid API key (TestRail 4.2 and above). |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
--user : Your TestRail User Name. |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
-j --project : desired project name. |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
-t --testsuite : desired testsuite name to search for cases within. May be passed multiple times. |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
-d --directory : directory to search for tests to correlate with TestRail cases. May be passed multiple times. |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=back |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
All mandatory options not passed with the above switches, or in your ~/.testrailrc will be prompted for. |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head2 SEMI-OPTIONAL PARAMETERS |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=over 4 |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
-m --missing : Only show cases which are in the directory passed, but not TestRail. Mutually exclusive with orphans. |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
-o --orphans : Only show cases which are in TestRail, but not the directory passed. Mutually exclusive with missing. |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
-n --no-recurse : do not recurse subdirectories when considering what tests need adding/updating/pruning. |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
-e --encoding : Character encoding of arguments. Defaults to UTF-8. See L for supported encodings. |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=back |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head2 OPTIONAL PARAMETERS |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=over 4 |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
--type : Filter cases to make syncing judgements against type(s). May be passed multiple times. |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
--section : Filter cases to make syncing judgements against a specific section. |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
--extension : only list files ending in the provided string (e.g. .pl, .pm, .t, .test) |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=back |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head1 CONFIGURATION FILE |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
In your \$HOME, (or the current directory, if your system has no concept of a home directory) put a file called .testrailrc with key=value syntax separated by newlines. |
|
171
|
|
|
|
|
|
|
Valid Keys are the same as documented by L. |
|
172
|
|
|
|
|
|
|
All options specified thereby are overridden by passing the command-line switches above. |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=head1 MISCELLANEOUS OPTIONS: |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=over 4 |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
--help : show this output |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
--test : print which tests would be added/updated/removed, but don't actually do anything |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=back |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=head1 SPECIAL THANKS |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
Thanks to cPanel Inc, for graciously funding the creation of this distribution. |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=head1 AUTHOR |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
George S. Baugh |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=head1 SOURCE |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
The development version is on github at L |
|
195
|
|
|
|
|
|
|
and may be cloned from L |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
This software is copyright (c) 2022 by George S. Baugh. |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
202
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=cut |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
__END__ |