line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Run::CmdLine::Iface; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
275830
|
use warnings; |
|
6
|
|
|
|
|
50
|
|
|
6
|
|
|
|
|
218
|
|
4
|
6
|
|
|
6
|
|
32
|
use strict; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
165
|
|
5
|
|
|
|
|
|
|
|
6
|
6
|
|
|
6
|
|
32
|
use vars (qw($VERSION)); |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
457
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
$VERSION = '0.0132'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
extends ('Test::Run::Base'); |
11
|
|
|
|
|
|
|
|
12
|
6
|
|
|
6
|
|
2505
|
use UNIVERSAL::require; |
|
6
|
|
|
|
|
5745
|
|
|
6
|
|
|
|
|
59
|
|
13
|
|
|
|
|
|
|
|
14
|
6
|
|
|
6
|
|
2840
|
use Test::Run::CmdLine; |
|
6
|
|
|
|
|
21
|
|
|
6
|
|
|
|
|
71
|
|
15
|
|
|
|
|
|
|
|
16
|
6
|
|
|
6
|
|
300
|
use Moose; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
38
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 NAME |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Test::Run::CmdLine::Iface - Analyze tests from the command line using Test::Run |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 SYNOPSIS |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
use Test::Run::CmdLine::Iface; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
my $tester = Test::Run::CmdLine::Iface->new( |
27
|
|
|
|
|
|
|
{ |
28
|
|
|
|
|
|
|
'test_files' => ["t/one.t", "t/two.t"], |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
$tester->run(); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=cut |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
has 'driver_class' => (is => "rw", isa => "Str", init_arg => undef,); |
37
|
|
|
|
|
|
|
has 'driver_plugins' => (is => "rw", isa => "ArrayRef", |
38
|
|
|
|
|
|
|
default => sub { [] }, init_arg => undef,); |
39
|
|
|
|
|
|
|
has '_driver_class_arg' => (is => "ro", isa => "Str", init_arg => "driver_class"); |
40
|
|
|
|
|
|
|
has '_driver_plugins_arg' => (is => "ro", isa => "Maybe[ArrayRef]", init_arg => "driver_plugins"); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
has 'test_files' => (is => "rw", isa => "ArrayRef", default => sub { [] },); |
43
|
|
|
|
|
|
|
has 'backend_params' => (is => "rw", isa => "HashRef", predicate => "has_backend_params"); |
44
|
|
|
|
|
|
|
has '_is_driver_class_prepared' => (is => "rw", isa => "Bool", default => 0); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub BUILD |
47
|
|
|
|
|
|
|
{ |
48
|
10
|
|
|
10
|
1
|
19854
|
my ($self) = @_; |
49
|
|
|
|
|
|
|
|
50
|
10
|
|
|
|
|
363
|
my $driver_class = $self->_driver_class_arg() ; |
51
|
10
|
|
|
|
|
306
|
my $plugins = $self->_driver_plugins_arg(); |
52
|
|
|
|
|
|
|
|
53
|
10
|
100
|
100
|
|
|
81
|
if ($driver_class || $plugins) |
|
|
100
|
66
|
|
|
|
|
54
|
|
|
|
|
|
|
{ |
55
|
5
|
|
100
|
|
|
45
|
$self->_set_driver( |
|
|
|
100
|
|
|
|
|
56
|
|
|
|
|
|
|
{ |
57
|
|
|
|
|
|
|
'class' => ($driver_class || |
58
|
|
|
|
|
|
|
"Test::Run::CmdLine::Drivers::Default"), |
59
|
|
|
|
|
|
|
'plugins' => ($plugins || []), |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
elsif ($ENV{'HARNESS_DRIVER'} || $ENV{'HARNESS_PLUGINS'}) |
64
|
|
|
|
|
|
|
{ |
65
|
|
|
|
|
|
|
$self->_set_driver( |
66
|
|
|
|
|
|
|
{ |
67
|
|
|
|
|
|
|
'class' => ($ENV{'HARNESS_DRIVER'} || |
68
|
|
|
|
|
|
|
"Test::Run::CmdLine::Drivers::Default"), |
69
|
1
|
|
50
|
|
|
12
|
'plugins' => [split(/\s+/, $ENV{'HARNESS_PLUGINS'} || "")] |
|
|
|
50
|
|
|
|
|
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
else |
74
|
|
|
|
|
|
|
{ |
75
|
4
|
|
|
|
|
25
|
$self->_set_driver( |
76
|
|
|
|
|
|
|
{ |
77
|
|
|
|
|
|
|
'class' => "Test::Run::CmdLine::Drivers::Default", |
78
|
|
|
|
|
|
|
'plugins' => [], |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
10
|
|
|
|
|
42
|
return; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 Interface Functions |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head2 $tester = Test::Run::CmdLine::Iface->new({'test_files' => \@test_files, ....}); |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Initializes a new testing front end. C<test_files> is a named argument that |
91
|
|
|
|
|
|
|
contains the files to test. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Other named arguments are: |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=over 4 |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=item backend_params |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
This is a hash of named parameters to be passed to the backend class (derived |
100
|
|
|
|
|
|
|
from L<Test::Run::Obj>.) |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=item driver_class |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
This is the backend class that will be instantiated and used to perform |
105
|
|
|
|
|
|
|
the processing. Defaults to L<Test::Run::CmdLine::Drivers::Default>. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=item driver_plugins |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
This is a list of plugin classes to be used by the driver class. Each plugin |
110
|
|
|
|
|
|
|
is a module and a corresponding class, that is prefixed by |
111
|
|
|
|
|
|
|
C<Test::Run::CmdLine::Plugin::> - a prefix which should not be included in |
112
|
|
|
|
|
|
|
them. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=back |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head2 $tester->run() |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Actually runs the tests on the command line. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head2 BUILD |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
For Moose. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
TODO : Write more. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=cut |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub _real_prepare_driver_class |
129
|
|
|
|
|
|
|
{ |
130
|
6
|
|
|
6
|
|
12
|
my $self = shift; |
131
|
|
|
|
|
|
|
|
132
|
6
|
|
|
|
|
194
|
my $driver_class = $self->driver_class(); |
133
|
6
|
|
|
|
|
65
|
$driver_class->require(); |
134
|
6
|
50
|
|
|
|
45213
|
if ($@) |
135
|
|
|
|
|
|
|
{ |
136
|
0
|
|
|
|
|
0
|
die $@; |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
6
|
|
|
|
|
78
|
foreach my $plugin (@{$self->_calc_plugins_for_ISA()}) |
|
6
|
|
|
|
|
42
|
|
140
|
|
|
|
|
|
|
{ |
141
|
8
|
|
|
|
|
73
|
$plugin->require(); |
142
|
8
|
50
|
|
|
|
20944
|
if ($@) |
143
|
|
|
|
|
|
|
{ |
144
|
0
|
|
|
|
|
0
|
die $@; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
{ |
147
|
6
|
|
|
6
|
|
42470
|
no strict 'refs'; |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
404
|
|
|
8
|
|
|
|
|
21
|
|
148
|
8
|
|
|
|
|
19
|
push @{"${driver_class}::ISA"}, $plugin; |
|
8
|
|
|
|
|
167
|
|
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
# Finally - put Test::Run::CmdLine there. |
153
|
|
|
|
|
|
|
{ |
154
|
6
|
|
|
6
|
|
36
|
no strict 'refs'; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
3698
|
|
|
6
|
|
|
|
|
19
|
|
155
|
6
|
|
|
|
|
13
|
push @{"${driver_class}::ISA"}, "Test::Run::CmdLine"; |
|
6
|
|
|
|
|
89
|
|
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
# Does _real_prepare_driver_class with memoization. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
sub _prepare_driver_class |
164
|
|
|
|
|
|
|
{ |
165
|
6
|
|
|
6
|
|
14
|
my $self = shift; |
166
|
|
|
|
|
|
|
|
167
|
6
|
50
|
|
|
|
222
|
if (! $self->_is_driver_class_prepared()) |
168
|
|
|
|
|
|
|
{ |
169
|
6
|
|
|
|
|
46
|
$self->_real_prepare_driver_class(); |
170
|
|
|
|
|
|
|
|
171
|
6
|
|
|
|
|
246
|
$self->_is_driver_class_prepared(1); |
172
|
|
|
|
|
|
|
} |
173
|
6
|
|
|
|
|
16
|
return; |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
sub _calc_driver |
177
|
|
|
|
|
|
|
{ |
178
|
6
|
|
|
6
|
|
46
|
my $self = shift; |
179
|
|
|
|
|
|
|
|
180
|
6
|
|
|
|
|
23
|
$self->_prepare_driver_class(); |
181
|
|
|
|
|
|
|
|
182
|
6
|
50
|
|
|
|
200
|
my $driver = $self->driver_class()->new( |
183
|
|
|
|
|
|
|
{ |
184
|
|
|
|
|
|
|
'test_files' => $self->test_files(), |
185
|
|
|
|
|
|
|
($self->has_backend_params() |
186
|
|
|
|
|
|
|
? ('backend_params' => $self->backend_params()) |
187
|
|
|
|
|
|
|
: () |
188
|
|
|
|
|
|
|
), |
189
|
|
|
|
|
|
|
} |
190
|
|
|
|
|
|
|
); |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
} |
193
|
|
|
|
|
|
|
sub run |
194
|
|
|
|
|
|
|
{ |
195
|
3
|
|
|
3
|
1
|
2223
|
my $self = shift; |
196
|
|
|
|
|
|
|
|
197
|
3
|
|
|
|
|
11
|
return $self->_calc_driver()->run(); |
198
|
|
|
|
|
|
|
} |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
sub _check_driver_class |
201
|
|
|
|
|
|
|
{ |
202
|
10
|
|
|
10
|
|
22
|
my $self = shift; |
203
|
10
|
|
|
|
|
35
|
return $self->_is_class_name(@_); |
204
|
|
|
|
|
|
|
} |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
sub _check_plugins |
207
|
|
|
|
|
|
|
{ |
208
|
10
|
|
|
10
|
|
24
|
my $self = shift; |
209
|
10
|
|
|
|
|
18
|
my $plugins = shift; |
210
|
10
|
|
|
|
|
28
|
foreach my $p (@$plugins) |
211
|
|
|
|
|
|
|
{ |
212
|
8
|
50
|
|
|
|
20
|
if (! $self->_is_class_name($p)) |
213
|
|
|
|
|
|
|
{ |
214
|
0
|
|
|
|
|
0
|
return 0; |
215
|
|
|
|
|
|
|
} |
216
|
|
|
|
|
|
|
} |
217
|
10
|
|
|
|
|
34
|
return 1; |
218
|
|
|
|
|
|
|
} |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
sub _is_class_name |
221
|
|
|
|
|
|
|
{ |
222
|
22
|
|
|
22
|
|
45
|
my $self = shift; |
223
|
22
|
|
|
|
|
38
|
my $class = shift; |
224
|
22
|
|
|
|
|
153
|
return ($class =~ /^\w+(?:::\w+)*$/); |
225
|
|
|
|
|
|
|
} |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
sub _set_driver |
228
|
|
|
|
|
|
|
{ |
229
|
10
|
|
|
10
|
|
29
|
my ($self, $args) = @_; |
230
|
|
|
|
|
|
|
|
231
|
10
|
|
|
|
|
26
|
my $class = $args->{'class'}; |
232
|
10
|
50
|
|
|
|
34
|
if (! $self->_check_driver_class($class)) |
233
|
|
|
|
|
|
|
{ |
234
|
0
|
|
|
|
|
0
|
die "Invalid Driver Class \"$class\"!"; |
235
|
|
|
|
|
|
|
} |
236
|
10
|
|
|
|
|
321
|
$self->driver_class($class); |
237
|
|
|
|
|
|
|
|
238
|
10
|
|
|
|
|
23
|
my $plugins = $args->{'plugins'}; |
239
|
10
|
50
|
|
|
|
61
|
if (! $self->_check_plugins($plugins)) |
240
|
|
|
|
|
|
|
{ |
241
|
0
|
|
|
|
|
0
|
die "Invalid Plugins for Test::Run::CmdLine::Iface!"; |
242
|
|
|
|
|
|
|
} |
243
|
10
|
|
|
|
|
324
|
$self->driver_plugins($plugins); |
244
|
|
|
|
|
|
|
|
245
|
10
|
|
|
|
|
20
|
return 0; |
246
|
|
|
|
|
|
|
} |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
sub _calc_plugins_for_ISA |
249
|
|
|
|
|
|
|
{ |
250
|
6
|
|
|
6
|
|
17
|
my $self = shift; |
251
|
|
|
|
|
|
|
return |
252
|
|
|
|
|
|
|
[ |
253
|
8
|
|
|
|
|
75
|
map { $self->_calc_single_plugin_for_ISA($_) } |
254
|
6
|
|
|
|
|
16
|
@{$self->driver_plugins()} |
|
6
|
|
|
|
|
227
|
|
255
|
|
|
|
|
|
|
]; |
256
|
|
|
|
|
|
|
} |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
sub _calc_single_plugin_for_ISA |
259
|
|
|
|
|
|
|
{ |
260
|
8
|
|
|
8
|
|
21
|
my $self = shift; |
261
|
8
|
|
|
|
|
16
|
my $p = shift; |
262
|
|
|
|
|
|
|
|
263
|
8
|
|
|
|
|
41
|
return "Test::Run::CmdLine::Plugin::$p"; |
264
|
|
|
|
|
|
|
} |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
=head1 AUTHOR |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
Shlomi Fish, L<http://www.shlomifish.org/> . |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
=head1 BUGS |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
273
|
|
|
|
|
|
|
C<bug-test-run-cmdline@rt.cpan.org>, or through the web interface at |
274
|
|
|
|
|
|
|
L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Run-CmdLine>. |
275
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
276
|
|
|
|
|
|
|
your bug as I make changes. |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
Copyright 2005 Shlomi Fish, all rights reserved. |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
This program is released under the MIT X11 License. |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
=cut |
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
1; # End of Test::Run::CmdLine |