File Coverage

blib/lib/Test/Class/Moose/CLI.pm
Criterion Covered Total %
statement 11 11 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 15 15 100.0


line stmt bran cond sub pod time code
1             package Test::Class::Moose::CLI;
2              
3             # ABSTRACT: Use this in your tcm.t script for a drop-in runner tool
4              
5 1     1   295960 use 5.010000;
  1         8  
6              
7             our $VERSION = '0.98';
8              
9 1     1   531 use Moose 2.0000;
  1         445225  
  1         9  
10 1     1   7669 use Carp;
  1         3  
  1         64  
11 1     1   564 use namespace::autoclean;
  1         8372  
  1         3  
12              
13             with 'Test::Class::Moose::Role::CLI';
14              
15             __PACKAGE__->meta->make_immutable;
16              
17             1;
18              
19             __END__
20              
21             =pod
22              
23             =encoding UTF-8
24              
25             =head1 NAME
26              
27             Test::Class::Moose::CLI - Use this in your tcm.t script for a drop-in runner tool
28              
29             =head1 VERSION
30              
31             version 0.98
32              
33             =head1 SYNOPSIS
34              
35             # In a t/tcm.t file ...
36             use Test::Class::Moose::CLI;
37              
38             Test::Class::Moose::CLI->new_with_options->run;
39              
40             # From the command line ...
41             $> prove -lv t/tcm.t :: --classes TestFor::Foo --classes TestFor::Bar --tags quick --tags db --jobs 8
42              
43             =head1 DESCRIPTION
44              
45             This class provides support for passing various L<Test::Class::Moose::Config>
46             options via the command line.
47              
48             It is entirely implemented by the L<Test::Class::Moose::Role::CLI> role, which
49             you can use in your own class to provide your own custom test runner.
50              
51             =head1 COMMAND LINE OPTIONS
52              
53             This class allows you to pass the following command-line options:
54              
55             =head2 --classes
56              
57             This should be the full name of one a class that you want to run (rather than
58             running classes).
59              
60             You can also pass a path to a single class. Any leading C<t/lib/> part of the
61             path will be stripped, and the rest will be transformed from a path to a
62             module name.
63              
64             Finally, you can pass a path to a directory. It will be searched for F<.pm>
65             files and each of those files will be loaded as a test class.
66              
67             You can pass this option more than once.
68              
69             =head2 --methods
70              
71             The name of a method that you want to run. You can pass this option more than
72             once.
73              
74             This will actually be turned into a regex like C<qr/^(?:foo|bar)$/>. It will
75             be matched against all classes that are being run.
76              
77             =head2 --exclude-methods
78              
79             The name of a method that you do not want to run. You can pass this option
80             more than once. This is turned into a regex just like C<--methods>.
81              
82             =head2 --tags
83              
84             The name of one or more test method tags that you want to include. Only test
85             method matching these tags will be run.
86              
87             =head2 --exclude-tags
88              
89             The name of one or more test method tags that you want to exclude. Any test
90             methods matching these tags will be ignored.
91              
92             =head2 --parallel-progress and --no-parallel-progress
93              
94             Show a progress indicator when running tests in parallel. Defaults to true.
95              
96             =head2 --color and --no-color
97              
98             Enable/disable color for the parallel progress output. Defaults to true.
99              
100             =head2 --jobs
101              
102             The number of jobs to run. Defaults to 1.
103              
104             =head2 --randomize-methods
105              
106             If true, methods for each class will be run in a random order. Defaults to
107             false.
108              
109             =head2 --randomize-classes
110              
111             If true, classes will be run in a random order. Defaults to false.
112              
113             =head2 --set-process-name
114              
115             If true, the process name (C<$0>) will be updated to include the name of each
116             test class as the class is being run.
117              
118             =head2 --statistics
119              
120             If true, this will output some extra statistics info as diagnostic output at
121             the end of the run. Defaults to false unless C<--use-environment> is true and
122             the C<HARNESS_IS_VERBOSE> environment variable is also true.
123              
124             =head2 --show-timing
125              
126             If true, this will output some extra timing info as diagnostic output at the
127             end of the run. Defaults to false unless C<--use-environment> is true and the
128             C<HARNESS_IS_VERBOSE> environment variable is also true.
129              
130             =head2 --runner-class
131              
132             The name of the runner class to use. Defaults to
133             L<Test::Class::Moose::Runner>. This class will be loaded when creating the
134             runner if it is not already loaded.
135              
136             =head2 --test-lib-dirs
137              
138             This should be the path to a directory containing test classes. The path can
139             be relative to the project root (F<t/lib>) or absolute. If you do not pass
140             this argument it will default to F<t/lib>.
141              
142             You can pass this option more than once if you'd like to include multiple test
143             directories.
144              
145             =head2 --timing-data-file
146              
147             If this is passed, the value returned by C<<
148             Test::Class::Moose::Report->timing_data >> plus some other information will be
149             encoded as JSON and stored in this file. The exact data stored looks like:
150              
151             {
152             process_name => $0,
153             start_time => $epoch_time
154             timing => \%timing_data_from_report,
155             }
156              
157             =head1 LOADING TEST CLASSES
158              
159             If you pass classes with the C<--classes> option, only these classes will be
160             loaded. Otherwise all classes under F<t/lib> will be loaded.
161              
162             =head1 SUPPORT
163              
164             Bugs may be submitted at L<https://github.com/houseabsolute/test-class-moose/issues>.
165              
166             I am also usually active on IRC as 'autarch' on C<irc://irc.perl.org>.
167              
168             =head1 SOURCE
169              
170             The source code repository for Test-Class-Moose can be found at L<https://github.com/houseabsolute/test-class-moose>.
171              
172             =head1 AUTHORS
173              
174             =over 4
175              
176             =item *
177              
178             Curtis "Ovid" Poe <ovid@cpan.org>
179              
180             =item *
181              
182             Dave Rolsky <autarch@urth.org>
183              
184             =back
185              
186             =head1 COPYRIGHT AND LICENSE
187              
188             This software is copyright (c) 2012 - 2019 by Curtis "Ovid" Poe.
189              
190             This is free software; you can redistribute it and/or modify it under
191             the same terms as the Perl 5 programming language system itself.
192              
193             The full text of the license can be found in the
194             F<LICENSE> file included with this distribution.
195              
196             =cut