bin/testrail-runs

filter: Statementstmt 97.7% 44 / 45 Branchbran 75.0% 6 / 8 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 9 / 9 Podpod n/a totaltotal 92.3% 60 / 65 CC 5 SCAR 9.4
CC
5
Cov
93%
run
5.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.6
« bin/testrail-lock ↑ Summary blib/lib/TestRail/Utils/Results.pm »
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 2 $TestRail::Bin::Runs::VERSION = '0.052';
7 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 3 ▶use TestRail::API;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 3 ▶use TestRail::Utils;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 3 ▶use TestRail::Utils::Find;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 3 ▶use Getopt::Long qw{GetOptionsFromArray};
Subroutine BEGIN: called CC=1 SCAR=0.0
16 3 ▶use File::HomeDir qw{my_home};
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 2 ▶if ( !caller() ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (caller()) 2 0 2
19 2 my ( $out, $code ) = run( 'args' => \@ARGV );
20 2 print $out;
21 2 exit $code;
22 }
23  
24 8 ▶sub run {
Subroutine run: called CC=5 SCAR=16.2
25 8 my %params = @_;
26 8 my $opts = {};
27  
28 # Parse config file
29 8 ▶ my $homedir = my_home() || '.';
Condition50%1/2
my_home() || '.'
l!l
80
MC/DC0%0/1
my_home() || '.'
my_home()
Truth table50%1/2
A
A= my_home()
Aresult
11
00
30 8 ▶ if ( -e $homedir . '/.testrailrc' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $homedir . '/.testrailrc') 0 8 8
31 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 8 'h|help' => \$opts->{'help'},
46 );
47  
48 8 ▶ if ( $opts->{help} ) { return ( '', TestRail::Utils::help() ); }
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{"help"}) 3 5 8
49  
50 5 $opts->{'browser'} = $params{'browser'};
51  
52 5 TestRail::Utils::interrogateUser( $opts, qw{apiurl user password project} );
53  
54 5 my $tr = TestRail::Utils::getHandle($opts);
55 5 my $runs = TestRail::Utils::Find::findRuns( $opts, $tr );
56  
57 5 @$runs = map { $_->{name} } @$runs;
58 5 ▶ return ( join( "\n", @$runs ) . "\n", 0 ) if scalar(@$runs);
Branch: 1 branch
BranchTrueFalseTotal
if scalar @$runs 3 2 5
59 2 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<Encode::Supported> 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<App::Prove::Plugin::TestRail>.
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 <teodesian@cpan.org>
149  
150 =head1 SOURCE
151  
152 The development version is on github at L<https://github.com/teodesian/TestRail-Perl>
153 and may be cloned from L<git://github.com/teodesian/TestRail-Perl.git>
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__
« bin/testrail-lock ↑ Summary blib/lib/TestRail/Utils/Results.pm »