testrail-runs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. #!/usr/bin/env perl
  2. # ABSTRACT: List runs in a TestRail project matching the provided filters
  3. # PODNAME: testrail-runs
  4. =head1 SYNOPSIS
  5. testrail-runs [OPTIONS] | xargs prove -PTestrail=...
  6. =head1 DESCRIPTION
  7. testrail-tests - list runs in a TestRail project matching the provided filters.
  8. Groups by plan for runs which are children of a plan.
  9. =head1 PARAMETERS:
  10. =head2 MANDATORY PARAMETERS
  11. =over 4
  12. --apiurl : full URL to get to TestRail index document
  13. --password : Your TestRail Password, or a valid API key (TestRail 4.2 and above).
  14. --user : Your TestRail User Name.
  15. -j --project : desired project name.
  16. =back
  17. All mandatory options not passed with the above switches, or in your ~/.testrailrc will be prompted for.
  18. =head2 OPTIONAL PARAMETERS
  19. =over 4
  20. -c --config : configuration name to filter runs. Can be passed multiple times.
  21. -s --status : only list runs with one or more tests having [status] in testrail. Can be passed multiple times.
  22. -e --encoding : Character encoding of arguments. Defaults to UTF-8. See L<Encode::Supported> for supported encodings.
  23. -l --lifo : LIFO sorting of results. Defaults to FIFO sort if not passed.
  24. -m --milesort : Sort by milestone due time. Defaults to sorting by run creation time if not passed.
  25. 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.
  26. Ergo if they are the lowest priority, you should consider running LIFO.
  27. =back
  28. =head1 CONFIGURATION FILE
  29. 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.
  30. Valid Keys are the same as documented by L<App::Prove::Plugin::TestRail>.
  31. All options specified thereby are overridden by passing the command-line switches above.
  32. =head1 MISCELLANEOUS OPTIONS:
  33. =over 4
  34. --help : show this output
  35. =back
  36. =cut
  37. use strict;
  38. use warnings;
  39. use utf8;
  40. use TestRail::API;
  41. use TestRail::Utils;
  42. use TestRail::Utils::Find;
  43. use Getopt::Long;
  44. use File::HomeDir qw{my_home};
  45. my $opts ={};
  46. # Parse config file
  47. my $homedir = my_home() || '.';
  48. if (-e $homedir . '/.testrailrc') {
  49. $opts = TestRail::Utils::parseConfig($homedir);
  50. }
  51. GetOptions(
  52. 'apiurl=s' => \$opts->{'apiurl'},
  53. 'password=s' => \$opts->{'password'},
  54. 'user=s' => \$opts->{'user'},
  55. 'j|project=s' => \$opts->{'project'},
  56. 'c|config=s@' => \$opts->{'configs'},
  57. 's|status=s@' => \$opts->{'statuses'},
  58. 'e|encoding=s' => \$opts->{'encoding'},
  59. 'l|lifo' => \$opts->{'lifo'},
  60. 'm|milesort' => \$opts->{'milesort'},
  61. 'h|help' => \$opts->{'help'}
  62. );
  63. if ($opts->{help}) { TestRail::Utils::help(); }
  64. TestRail::Utils::interrogateUser($opts,qw{apiurl user password project});
  65. my $tr = TestRail::API->new($opts->{apiurl},$opts->{user},$opts->{password},$opts->{'encoding'},$opts->{'debug'});
  66. my $runs = TestRail::Utils::Find::findRuns($opts,$tr);
  67. @$runs = map {$_->{name}} @$runs;
  68. print join("\n",@$runs)."\n" if scalar(@$runs);
  69. exit 0;
  70. __END__
  71. L<TestRail::API>
  72. L<File::HomeDir> for the finding of .testrailrc
  73. =head1 SPECIAL THANKS
  74. Thanks to cPanel Inc, for graciously funding the creation of this distribution.