line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
|
|
|
|
|
|
# ABSTRACT: List runs in a TestRail project matching the provided filters |
3
|
|
|
|
|
|
|
# PODNAME: TestRail::Bin::Runs |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package TestRail::Bin::Runs; |
6
|
|
|
|
|
|
|
$TestRail::Bin::Runs::VERSION = '0.052'; |
7
|
1
|
|
|
1
|
|
662
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
8
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
35
|
|
9
|
1
|
|
|
1
|
|
640
|
use utf8; |
|
1
|
|
|
|
|
16
|
|
|
1
|
|
|
|
|
4
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
677
|
use TestRail::API; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
76
|
|
12
|
1
|
|
|
1
|
|
730
|
use TestRail::Utils; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
45
|
|
13
|
1
|
|
|
1
|
|
713
|
use TestRail::Utils::Find; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
72
|
|
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
915
|
use Getopt::Long qw{GetOptionsFromArray}; |
|
1
|
|
|
|
|
9852
|
|
|
1
|
|
|
|
|
7
|
|
16
|
1
|
|
|
1
|
|
839
|
use File::HomeDir qw{my_home}; |
|
1
|
|
|
|
|
5644
|
|
|
1
|
|
|
|
|
385
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
if ( !caller() ) { |
19
|
|
|
|
|
|
|
my ( $out, $code ) = run( 'args' => \@ARGV ); |
20
|
|
|
|
|
|
|
print $out; |
21
|
|
|
|
|
|
|
exit $code; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub run { |
25
|
6
|
|
|
6
|
|
9878
|
my %params = @_; |
26
|
6
|
|
|
|
|
17
|
my $opts = {}; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# Parse config file |
29
|
6
|
|
50
|
|
|
44
|
my $homedir = my_home() || '.'; |
30
|
6
|
50
|
|
|
|
551
|
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
|
|
|
|
|
|
|
'c|config=s@' => \$opts->{'configs'}, |
41
|
|
|
|
|
|
|
's|status=s@' => \$opts->{'statuses'}, |
42
|
|
|
|
|
|
|
'e|encoding=s' => \$opts->{'encoding'}, |
43
|
|
|
|
|
|
|
'l|lifo' => \$opts->{'lifo'}, |
44
|
|
|
|
|
|
|
'm|milesort' => \$opts->{'milesort'}, |
45
|
6
|
|
|
|
|
136
|
'h|help' => \$opts->{'help'}, |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
|
48
|
6
|
100
|
|
|
|
6852
|
if ( $opts->{help} ) { return ( '', TestRail::Utils::help() ); } |
|
1
|
|
|
|
|
9
|
|
49
|
|
|
|
|
|
|
|
50
|
5
|
|
|
|
|
19
|
$opts->{'browser'} = $params{'browser'}; |
51
|
|
|
|
|
|
|
|
52
|
5
|
|
|
|
|
39
|
TestRail::Utils::interrogateUser( $opts, qw{apiurl user password project} ); |
53
|
|
|
|
|
|
|
|
54
|
5
|
|
|
|
|
21
|
my $tr = TestRail::Utils::getHandle($opts); |
55
|
5
|
|
|
|
|
47
|
my $runs = TestRail::Utils::Find::findRuns( $opts, $tr ); |
56
|
|
|
|
|
|
|
|
57
|
5
|
|
|
|
|
17
|
@$runs = map { $_->{name} } @$runs; |
|
15
|
|
|
|
|
84
|
|
58
|
5
|
100
|
|
|
|
148
|
return ( join( "\n", @$runs ) . "\n", 0 ) if scalar(@$runs); |
59
|
2
|
|
|
|
|
88
|
return ( "No runs found matching your criterion.\n", 255 ); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=pod |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=encoding UTF-8 |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 NAME |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
TestRail::Bin::Runs - List runs in a TestRail project matching the provided filters |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 VERSION |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
version 0.052 |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 SYNOPSIS |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
testrail-runs [OPTIONS] | xargs prove -PTestrail=... |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
require `which testrail-runs`; |
81
|
|
|
|
|
|
|
TestRail::Bin::Run::run('args' => \@args); |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 DESCRIPTION |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
testrail-runs - list runs in a TestRail project matching the provided filters. |
86
|
|
|
|
|
|
|
Groups by plan for runs which are children of a plan. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Can be used as the modulino TestRail::Bin::Runs. |
89
|
|
|
|
|
|
|
Has a single 'run' function which accepts a hash with the 'args' parameter being the array of arguments. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 PARAMETERS: |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head2 MANDATORY PARAMETERS |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=over 4 |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
--apiurl : full URL to get to TestRail index document |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
--password : Your TestRail Password, or a valid API key (TestRail 4.2 and above). |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
--user : Your TestRail User Name. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
-j --project : desired project name. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=back |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
All mandatory options not passed with the above switches, or in your ~/.testrailrc will be prompted for. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head2 OPTIONAL PARAMETERS |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=over 4 |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
-c --config : configuration name to filter runs. Can be passed multiple times. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
-s --status : only list runs with one or more tests having [status] in testrail. Can be passed multiple times. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
-e --encoding : Character encoding of arguments. Defaults to UTF-8. See L for supported encodings. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
-l --lifo : LIFO sorting of results. Defaults to FIFO sort if not passed. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
-m --milesort : Sort by milestone due time. Defaults to sorting by run creation time if not passed. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Be aware that when sorting by milestone, if a run has no milestone set, it is considered "earlier" than anything else by perl's comparison routines. |
124
|
|
|
|
|
|
|
Ergo if they are the lowest priority, you should consider running LIFO. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=back |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 CONFIGURATION FILE |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
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. |
131
|
|
|
|
|
|
|
Valid Keys are the same as documented by L. |
132
|
|
|
|
|
|
|
All options specified thereby are overridden by passing the command-line switches above. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 MISCELLANEOUS OPTIONS: |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=over 4 |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
--help : show this output |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=back |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head1 SPECIAL THANKS |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Thanks to cPanel Inc, for graciously funding the creation of this distribution. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 AUTHOR |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
George S. Baugh |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 SOURCE |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
The development version is on github at L |
153
|
|
|
|
|
|
|
and may be cloned from L |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
This software is copyright (c) 2022 by George S. Baugh. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
160
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=cut |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
__END__ |