line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::Prove::State; |
2
|
|
|
|
|
|
|
|
3
|
8
|
|
|
8
|
|
31546
|
use strict; |
|
8
|
|
|
|
|
10
|
|
|
8
|
|
|
|
|
204
|
|
4
|
8
|
|
|
8
|
|
27
|
use warnings; |
|
8
|
|
|
|
|
8
|
|
|
8
|
|
|
|
|
198
|
|
5
|
|
|
|
|
|
|
|
6
|
8
|
|
|
8
|
|
27
|
use File::Find; |
|
8
|
|
|
|
|
9
|
|
|
8
|
|
|
|
|
434
|
|
7
|
8
|
|
|
8
|
|
34
|
use File::Spec; |
|
8
|
|
|
|
|
9
|
|
|
8
|
|
|
|
|
155
|
|
8
|
8
|
|
|
8
|
|
28
|
use Carp; |
|
8
|
|
|
|
|
8
|
|
|
8
|
|
|
|
|
410
|
|
9
|
|
|
|
|
|
|
|
10
|
8
|
|
|
8
|
|
2930
|
use App::Prove::State::Result; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
158
|
|
11
|
8
|
|
|
8
|
|
2344
|
use TAP::Parser::YAMLish::Reader (); |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
156
|
|
12
|
8
|
|
|
8
|
|
2993
|
use TAP::Parser::YAMLish::Writer (); |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
176
|
|
13
|
8
|
|
|
8
|
|
38
|
use base 'TAP::Base'; |
|
8
|
|
|
|
|
10
|
|
|
8
|
|
|
|
|
1890
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
BEGIN { |
16
|
8
|
|
|
8
|
|
64
|
__PACKAGE__->mk_methods('result_class'); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
8
|
|
|
8
|
|
39
|
use constant IS_WIN32 => ( $^O =~ /^(MS)?Win32$/ ); |
|
8
|
|
|
|
|
7
|
|
|
8
|
|
|
|
|
384
|
|
20
|
8
|
|
|
8
|
|
26
|
use constant NEED_GLOB => IS_WIN32; |
|
8
|
|
|
|
|
8
|
|
|
8
|
|
|
|
|
15391
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 NAME |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
App::Prove::State - State storage for the C command. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 VERSION |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Version 3.38 |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=cut |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
our $VERSION = '3.38'; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 DESCRIPTION |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
The C command supports a C<--state> option that instructs it to |
37
|
|
|
|
|
|
|
store persistent state across runs. This module implements that state |
38
|
|
|
|
|
|
|
and the operations that may be performed on it. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 SYNOPSIS |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# Re-run failed tests |
43
|
|
|
|
|
|
|
$ prove --state=failed,save -rbv |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=cut |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 METHODS |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head2 Class Methods |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head3 C |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Accepts a hashref with the following key/value pairs: |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=over 4 |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=item * C |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
The filename of the data store holding the data that App::Prove::State reads. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=item * C (optional) |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
The test name extensions. Defaults to C<.t>. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=item * C (optional) |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
The name of the C. Defaults to C. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=back |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# override TAP::Base::new: |
74
|
|
|
|
|
|
|
sub new { |
75
|
74
|
|
|
74
|
1
|
8012
|
my $class = shift; |
76
|
74
|
100
|
|
|
|
69
|
my %args = %{ shift || {} }; |
|
74
|
|
|
|
|
386
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
my $self = bless { |
79
|
|
|
|
|
|
|
select => [], |
80
|
|
|
|
|
|
|
seq => 1, |
81
|
|
|
|
|
|
|
store => delete $args{store}, |
82
|
|
|
|
|
|
|
extensions => ( delete $args{extensions} || ['.t'] ), |
83
|
|
|
|
|
|
|
result_class => |
84
|
74
|
|
50
|
|
|
818
|
( delete $args{result_class} || 'App::Prove::State::Result' ), |
|
|
|
50
|
|
|
|
|
85
|
|
|
|
|
|
|
}, $class; |
86
|
|
|
|
|
|
|
|
87
|
74
|
|
|
|
|
213
|
$self->{_} = $self->result_class->new( |
88
|
|
|
|
|
|
|
{ tests => {}, |
89
|
|
|
|
|
|
|
generation => 1, |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
); |
92
|
74
|
|
|
|
|
161
|
my $store = $self->{store}; |
93
|
74
|
50
|
66
|
|
|
724
|
$self->load($store) |
94
|
|
|
|
|
|
|
if defined $store && -f $store; |
95
|
|
|
|
|
|
|
|
96
|
74
|
|
|
|
|
177
|
return $self; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head2 C |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Getter/setter for the name of the class used for tracking test results. This |
102
|
|
|
|
|
|
|
class should either subclass from C or provide an |
103
|
|
|
|
|
|
|
identical interface. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=cut |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head2 C |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Get or set the list of extensions that files must have in order to be |
110
|
|
|
|
|
|
|
considered tests. Defaults to ['.t']. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=cut |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub extensions { |
115
|
2
|
|
|
2
|
1
|
3
|
my $self = shift; |
116
|
2
|
50
|
|
|
|
6
|
$self->{extensions} = shift if @_; |
117
|
2
|
|
|
|
|
3
|
return $self->{extensions}; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head2 C |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Get the results of the last test run. Returns a C instance. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=cut |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub results { |
127
|
183
|
|
|
183
|
1
|
145
|
my $self = shift; |
128
|
183
|
50
|
|
|
|
601
|
$self->{_} || $self->result_class->new; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head2 C |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Save the test results. Should be called after all tests have run. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=cut |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
sub commit { |
138
|
2
|
|
|
2
|
1
|
7
|
my $self = shift; |
139
|
2
|
50
|
|
|
|
10
|
if ( $self->{should_save} ) { |
140
|
0
|
|
|
|
|
0
|
$self->save; |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head2 Instance Methods |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head3 C |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
$self->apply_switch('failed,save'); |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Apply a list of switch options to the state, updating the internal |
151
|
|
|
|
|
|
|
object state as a result. Nothing is returned. |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Diagnostics: |
154
|
|
|
|
|
|
|
- "Illegal state option: %s" |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=over |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=item C |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Run in the same order as last time |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=item C |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
Run only the failed tests from last time |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=item C |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
Run only the passed tests from last time |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=item C |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
Run all tests in normal order |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=item C |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
Run the tests that most recently failed first |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=item C |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
Run the tests ordered by number of todos. |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=item C |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
Run the tests in slowest to fastest order. |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=item C |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
Run test tests in fastest to slowest order. |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=item C |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
Run the tests in newest to oldest order. |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=item C |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
Run the tests in oldest to newest order. |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=item C |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
Save the state on exit. |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=back |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=cut |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
sub apply_switch { |
207
|
74
|
|
|
74
|
1
|
285
|
my $self = shift; |
208
|
74
|
|
|
|
|
98
|
my @opts = @_; |
209
|
|
|
|
|
|
|
|
210
|
74
|
|
|
|
|
135
|
my $last_gen = $self->results->generation - 1; |
211
|
74
|
|
|
|
|
115
|
my $last_run_time = $self->results->last_run_time; |
212
|
74
|
|
|
|
|
226
|
my $now = $self->get_time; |
213
|
|
|
|
|
|
|
|
214
|
74
|
|
|
|
|
120
|
my @switches = map { split /,/ } @opts; |
|
15
|
|
|
|
|
71
|
|
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
my %handler = ( |
217
|
|
|
|
|
|
|
last => sub { |
218
|
|
|
|
|
|
|
$self->_select( |
219
|
|
|
|
|
|
|
limit => shift, |
220
|
6
|
|
|
|
|
13
|
where => sub { $_->generation >= $last_gen }, |
221
|
5
|
|
|
|
|
13
|
order => sub { $_->sequence } |
222
|
1
|
|
|
1
|
|
7
|
); |
223
|
|
|
|
|
|
|
}, |
224
|
|
|
|
|
|
|
failed => sub { |
225
|
|
|
|
|
|
|
$self->_select( |
226
|
|
|
|
|
|
|
limit => shift, |
227
|
18
|
|
|
|
|
33
|
where => sub { $_->result != 0 }, |
228
|
6
|
|
|
|
|
9
|
order => sub { -$_->result } |
229
|
3
|
|
|
3
|
|
21
|
); |
230
|
|
|
|
|
|
|
}, |
231
|
|
|
|
|
|
|
passed => sub { |
232
|
|
|
|
|
|
|
$self->_select( |
233
|
|
|
|
|
|
|
limit => shift, |
234
|
18
|
|
|
|
|
31
|
where => sub { $_->result == 0 } |
235
|
3
|
|
|
3
|
|
12
|
); |
236
|
|
|
|
|
|
|
}, |
237
|
|
|
|
|
|
|
all => sub { |
238
|
2
|
|
|
2
|
|
6
|
$self->_select( limit => shift ); |
239
|
|
|
|
|
|
|
}, |
240
|
|
|
|
|
|
|
todo => sub { |
241
|
|
|
|
|
|
|
$self->_select( |
242
|
|
|
|
|
|
|
limit => shift, |
243
|
6
|
|
|
|
|
13
|
where => sub { $_->num_todo != 0 }, |
244
|
2
|
|
|
|
|
6
|
order => sub { -$_->num_todo; } |
245
|
1
|
|
|
1
|
|
8
|
); |
246
|
|
|
|
|
|
|
}, |
247
|
|
|
|
|
|
|
hot => sub { |
248
|
|
|
|
|
|
|
$self->_select( |
249
|
|
|
|
|
|
|
limit => shift, |
250
|
12
|
|
|
|
|
28
|
where => sub { defined $_->last_fail_time }, |
251
|
6
|
|
|
|
|
13
|
order => sub { $now - $_->last_fail_time } |
252
|
2
|
|
|
2
|
|
14
|
); |
253
|
|
|
|
|
|
|
}, |
254
|
|
|
|
|
|
|
slow => sub { |
255
|
|
|
|
|
|
|
$self->_select( |
256
|
|
|
|
|
|
|
limit => shift, |
257
|
6
|
|
|
|
|
17
|
order => sub { -$_->elapsed } |
258
|
1
|
|
|
1
|
|
6
|
); |
259
|
|
|
|
|
|
|
}, |
260
|
|
|
|
|
|
|
fast => sub { |
261
|
|
|
|
|
|
|
$self->_select( |
262
|
|
|
|
|
|
|
limit => shift, |
263
|
6
|
|
|
|
|
16
|
order => sub { $_->elapsed } |
264
|
1
|
|
|
1
|
|
6
|
); |
265
|
|
|
|
|
|
|
}, |
266
|
|
|
|
|
|
|
new => sub { |
267
|
|
|
|
|
|
|
$self->_select( |
268
|
|
|
|
|
|
|
limit => shift, |
269
|
6
|
|
|
|
|
14
|
order => sub { -$_->mtime } |
270
|
1
|
|
|
1
|
|
5
|
); |
271
|
|
|
|
|
|
|
}, |
272
|
|
|
|
|
|
|
old => sub { |
273
|
|
|
|
|
|
|
$self->_select( |
274
|
|
|
|
|
|
|
limit => shift, |
275
|
6
|
|
|
|
|
17
|
order => sub { $_->mtime } |
276
|
1
|
|
|
1
|
|
5
|
); |
277
|
|
|
|
|
|
|
}, |
278
|
|
|
|
|
|
|
fresh => sub { |
279
|
|
|
|
|
|
|
$self->_select( |
280
|
|
|
|
|
|
|
limit => shift, |
281
|
6
|
|
|
|
|
17
|
where => sub { $_->mtime >= $last_run_time } |
282
|
1
|
|
|
1
|
|
6
|
); |
283
|
|
|
|
|
|
|
}, |
284
|
|
|
|
|
|
|
save => sub { |
285
|
1
|
|
|
1
|
|
6
|
$self->{should_save}++; |
286
|
|
|
|
|
|
|
}, |
287
|
|
|
|
|
|
|
adrian => sub { |
288
|
1
|
|
|
1
|
|
7
|
unshift @switches, qw( hot all save ); |
289
|
|
|
|
|
|
|
}, |
290
|
74
|
|
|
|
|
1758
|
); |
291
|
|
|
|
|
|
|
|
292
|
74
|
|
|
|
|
230
|
while ( defined( my $ele = shift @switches ) ) { |
293
|
19
|
50
|
|
|
|
63
|
my ( $opt, $arg ) |
294
|
|
|
|
|
|
|
= ( $ele =~ /^([^:]+):(.*)/ ) |
295
|
|
|
|
|
|
|
? ( $1, $2 ) |
296
|
|
|
|
|
|
|
: ( $ele, undef ); |
297
|
19
|
|
33
|
|
|
47
|
my $code = $handler{$opt} |
298
|
|
|
|
|
|
|
|| croak "Illegal state option: $opt"; |
299
|
19
|
|
|
|
|
33
|
$code->($arg); |
300
|
|
|
|
|
|
|
} |
301
|
74
|
|
|
|
|
1081
|
return; |
302
|
|
|
|
|
|
|
} |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
sub _select { |
305
|
17
|
|
|
17
|
|
60
|
my ( $self, %spec ) = @_; |
306
|
17
|
|
|
|
|
15
|
push @{ $self->{select} }, \%spec; |
|
17
|
|
|
|
|
85
|
|
307
|
|
|
|
|
|
|
} |
308
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
=head3 C |
310
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
Given a list of args get the names of tests that should run |
312
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
=cut |
314
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
sub get_tests { |
316
|
74
|
|
|
74
|
1
|
118
|
my $self = shift; |
317
|
74
|
|
|
|
|
61
|
my $recurse = shift; |
318
|
74
|
|
|
|
|
123
|
my @argv = @_; |
319
|
74
|
|
|
|
|
71
|
my %seen; |
320
|
|
|
|
|
|
|
|
321
|
74
|
|
|
|
|
186
|
my @selected = $self->_query; |
322
|
|
|
|
|
|
|
|
323
|
74
|
100
|
100
|
|
|
165
|
unless ( @argv || @{ $self->{select} } ) { |
|
16
|
|
|
|
|
66
|
|
324
|
2
|
50
|
|
|
|
6
|
@argv = $recurse ? '.' : 't'; |
325
|
2
|
50
|
|
|
|
25
|
croak qq{No tests named and '@argv' directory not found} |
326
|
|
|
|
|
|
|
unless -d $argv[0]; |
327
|
|
|
|
|
|
|
} |
328
|
|
|
|
|
|
|
|
329
|
74
|
100
|
|
|
|
213
|
push @selected, $self->_get_raw_tests( $recurse, @argv ) if @argv; |
330
|
74
|
|
|
|
|
105
|
return grep { !$seen{$_}++ } @selected; |
|
172
|
|
|
|
|
573
|
|
331
|
|
|
|
|
|
|
} |
332
|
|
|
|
|
|
|
|
333
|
|
|
|
|
|
|
sub _query { |
334
|
74
|
|
|
74
|
|
586
|
my $self = shift; |
335
|
74
|
100
|
|
|
|
66
|
if ( my @sel = @{ $self->{select} } ) { |
|
74
|
|
|
|
|
177
|
|
336
|
14
|
50
|
|
|
|
29
|
warn "No saved state, selection will be empty\n" |
337
|
|
|
|
|
|
|
unless $self->results->num_tests; |
338
|
14
|
|
|
|
|
20
|
return map { $self->_query_clause($_) } @sel; |
|
17
|
|
|
|
|
35
|
|
339
|
|
|
|
|
|
|
} |
340
|
60
|
|
|
|
|
68
|
return; |
341
|
|
|
|
|
|
|
} |
342
|
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
sub _query_clause { |
344
|
17
|
|
|
17
|
|
23
|
my ( $self, $clause ) = @_; |
345
|
17
|
|
|
|
|
17
|
my @got; |
346
|
17
|
|
|
|
|
25
|
my $results = $self->results; |
347
|
17
|
|
100
|
36
|
|
65
|
my $where = $clause->{where} || sub {1}; |
|
36
|
|
|
|
|
121
|
|
348
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
# Select |
350
|
17
|
|
|
|
|
52
|
for my $name ( $results->test_names ) { |
351
|
102
|
50
|
|
|
|
1120
|
next unless -f $name; |
352
|
102
|
|
|
|
|
241
|
local $_ = $results->test($name); |
353
|
102
|
100
|
|
|
|
147
|
push @got, $name if $where->(); |
354
|
|
|
|
|
|
|
} |
355
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
# Sort |
357
|
17
|
100
|
|
|
|
56
|
if ( my $order = $clause->{order} ) { |
358
|
43
|
|
|
|
|
73
|
@got = map { $_->[0] } |
359
|
|
|
|
|
|
|
sort { |
360
|
59
|
0
|
50
|
|
|
209
|
( defined $b->[1] <=> defined $a->[1] ) |
|
|
|
50
|
|
|
|
|
361
|
|
|
|
|
|
|
|| ( ( $a->[1] || 0 ) <=> ( $b->[1] || 0 ) ) |
362
|
|
|
|
|
|
|
} map { |
363
|
11
|
|
|
|
|
21
|
[ $_, |
364
|
43
|
|
|
|
|
37
|
do { local $_ = $results->test($_); $order->() } |
|
43
|
|
|
|
|
80
|
|
|
43
|
|
|
|
|
54
|
|
365
|
|
|
|
|
|
|
] |
366
|
|
|
|
|
|
|
} @got; |
367
|
|
|
|
|
|
|
} |
368
|
|
|
|
|
|
|
|
369
|
17
|
50
|
|
|
|
52
|
if ( my $limit = $clause->{limit} ) { |
370
|
0
|
0
|
|
|
|
0
|
@got = splice @got, 0, $limit if @got > $limit; |
371
|
|
|
|
|
|
|
} |
372
|
|
|
|
|
|
|
|
373
|
17
|
|
|
|
|
104
|
return @got; |
374
|
|
|
|
|
|
|
} |
375
|
|
|
|
|
|
|
|
376
|
|
|
|
|
|
|
sub _get_raw_tests { |
377
|
60
|
|
|
60
|
|
50
|
my $self = shift; |
378
|
60
|
|
|
|
|
48
|
my $recurse = shift; |
379
|
60
|
|
|
|
|
75
|
my @argv = @_; |
380
|
60
|
|
|
|
|
51
|
my @tests; |
381
|
|
|
|
|
|
|
|
382
|
|
|
|
|
|
|
# Do globbing on Win32. |
383
|
60
|
50
|
|
|
|
164
|
if (NEED_GLOB) { |
384
|
0
|
|
|
|
|
0
|
eval "use File::Glob::Windows"; # [49732] |
385
|
0
|
|
|
|
|
0
|
@argv = map { glob "$_" } @argv; |
|
0
|
|
|
|
|
0
|
|
386
|
|
|
|
|
|
|
} |
387
|
60
|
|
|
|
|
61
|
my $extensions = $self->{extensions}; |
388
|
|
|
|
|
|
|
|
389
|
60
|
|
|
|
|
83
|
for my $arg (@argv) { |
390
|
105
|
50
|
|
|
|
168
|
if ( '-' eq $arg ) { |
391
|
0
|
|
|
|
|
0
|
push @argv => ; |
392
|
0
|
|
|
|
|
0
|
chomp(@argv); |
393
|
0
|
|
|
|
|
0
|
next; |
394
|
|
|
|
|
|
|
} |
395
|
|
|
|
|
|
|
|
396
|
|
|
|
|
|
|
push @tests, |
397
|
|
|
|
|
|
|
sort -d $arg |
398
|
|
|
|
|
|
|
? $recurse |
399
|
|
|
|
|
|
|
? $self->_expand_dir_recursive( $arg, $extensions ) |
400
|
3
|
|
|
|
|
278
|
: map { glob( File::Spec->catfile( $arg, "*$_" ) ) } |
401
|
105
|
50
|
|
|
|
897
|
@{$extensions} |
|
2
|
100
|
|
|
|
3
|
|
402
|
|
|
|
|
|
|
: $arg; |
403
|
|
|
|
|
|
|
} |
404
|
60
|
|
|
|
|
171
|
return @tests; |
405
|
|
|
|
|
|
|
} |
406
|
|
|
|
|
|
|
|
407
|
|
|
|
|
|
|
sub _expand_dir_recursive { |
408
|
0
|
|
|
0
|
|
0
|
my ( $self, $dir, $extensions ) = @_; |
409
|
|
|
|
|
|
|
|
410
|
0
|
|
|
|
|
0
|
my @tests; |
411
|
0
|
|
|
|
|
0
|
my $ext_string = join( '|', map {quotemeta} @{$extensions} ); |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
412
|
|
|
|
|
|
|
|
413
|
|
|
|
|
|
|
find( |
414
|
|
|
|
|
|
|
{ follow => 1, #21938 |
415
|
|
|
|
|
|
|
follow_skip => 2, |
416
|
|
|
|
|
|
|
wanted => sub { |
417
|
|
|
|
|
|
|
-f |
418
|
0
|
0
|
0
|
0
|
|
0
|
&& /(?:$ext_string)$/ |
419
|
|
|
|
|
|
|
&& push @tests => $File::Find::name; |
420
|
|
|
|
|
|
|
} |
421
|
|
|
|
|
|
|
}, |
422
|
0
|
|
|
|
|
0
|
$dir |
423
|
|
|
|
|
|
|
); |
424
|
0
|
|
|
|
|
0
|
return @tests; |
425
|
|
|
|
|
|
|
} |
426
|
|
|
|
|
|
|
|
427
|
|
|
|
|
|
|
=head3 C |
428
|
|
|
|
|
|
|
|
429
|
|
|
|
|
|
|
Store the results of a test. |
430
|
|
|
|
|
|
|
|
431
|
|
|
|
|
|
|
=cut |
432
|
|
|
|
|
|
|
|
433
|
|
|
|
|
|
|
# Store: |
434
|
|
|
|
|
|
|
# last fail time |
435
|
|
|
|
|
|
|
# last pass time |
436
|
|
|
|
|
|
|
# last run time |
437
|
|
|
|
|
|
|
# most recent result |
438
|
|
|
|
|
|
|
# most recent todos |
439
|
|
|
|
|
|
|
# total failures |
440
|
|
|
|
|
|
|
# total passes |
441
|
|
|
|
|
|
|
# state generation |
442
|
|
|
|
|
|
|
# parser |
443
|
|
|
|
|
|
|
|
444
|
|
|
|
|
|
|
sub observe_test { |
445
|
|
|
|
|
|
|
|
446
|
2
|
|
|
2
|
1
|
4
|
my ( $self, $test_info, $parser ) = @_; |
447
|
2
|
|
|
|
|
4
|
my $name = $test_info->[0]; |
448
|
2
|
50
|
|
|
|
7
|
my $fail = scalar( $parser->failed ) + ( $parser->has_problems ? 1 : 0 ); |
449
|
2
|
|
|
|
|
10
|
my $todo = scalar( $parser->todo ); |
450
|
2
|
|
|
|
|
6
|
my $start_time = $parser->start_time; |
451
|
2
|
|
|
|
|
4
|
my $end_time = $parser->end_time, |
452
|
|
|
|
|
|
|
|
453
|
|
|
|
|
|
|
my $test = $self->results->test($name); |
454
|
|
|
|
|
|
|
|
455
|
2
|
|
|
|
|
13
|
$test->sequence( $self->{seq}++ ); |
456
|
2
|
|
|
|
|
291
|
$test->generation( $self->results->generation ); |
457
|
|
|
|
|
|
|
|
458
|
2
|
|
|
|
|
10
|
$test->run_time($end_time); |
459
|
2
|
|
|
|
|
7
|
$test->result($fail); |
460
|
2
|
|
|
|
|
7
|
$test->num_todo($todo); |
461
|
2
|
|
|
|
|
7
|
$test->elapsed( $end_time - $start_time ); |
462
|
|
|
|
|
|
|
|
463
|
2
|
|
|
|
|
6
|
$test->parser($parser); |
464
|
|
|
|
|
|
|
|
465
|
2
|
50
|
|
|
|
4
|
if ($fail) { |
466
|
0
|
|
|
|
|
0
|
$test->total_failures( $test->total_failures + 1 ); |
467
|
0
|
|
|
|
|
0
|
$test->last_fail_time($end_time); |
468
|
|
|
|
|
|
|
} |
469
|
|
|
|
|
|
|
else { |
470
|
2
|
|
|
|
|
8
|
$test->total_passes( $test->total_passes + 1 ); |
471
|
2
|
|
|
|
|
8
|
$test->last_pass_time($end_time); |
472
|
|
|
|
|
|
|
} |
473
|
|
|
|
|
|
|
} |
474
|
|
|
|
|
|
|
|
475
|
|
|
|
|
|
|
=head3 C |
476
|
|
|
|
|
|
|
|
477
|
|
|
|
|
|
|
Write the state to a file. |
478
|
|
|
|
|
|
|
|
479
|
|
|
|
|
|
|
=cut |
480
|
|
|
|
|
|
|
|
481
|
|
|
|
|
|
|
sub save { |
482
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
483
|
|
|
|
|
|
|
|
484
|
0
|
0
|
|
|
|
|
my $store = $self->{store} or return; |
485
|
0
|
|
|
|
|
|
$self->results->last_run_time( $self->get_time ); |
486
|
|
|
|
|
|
|
|
487
|
0
|
|
|
|
|
|
my $writer = TAP::Parser::YAMLish::Writer->new; |
488
|
0
|
|
|
|
|
|
local *FH; |
489
|
0
|
0
|
|
|
|
|
open FH, ">$store" or croak "Can't write $store ($!)"; |
490
|
0
|
|
|
|
|
|
$writer->write( $self->results->raw, \*FH ); |
491
|
0
|
|
|
|
|
|
close FH; |
492
|
|
|
|
|
|
|
} |
493
|
|
|
|
|
|
|
|
494
|
|
|
|
|
|
|
=head3 C |
495
|
|
|
|
|
|
|
|
496
|
|
|
|
|
|
|
Load the state from a file |
497
|
|
|
|
|
|
|
|
498
|
|
|
|
|
|
|
=cut |
499
|
|
|
|
|
|
|
|
500
|
|
|
|
|
|
|
sub load { |
501
|
0
|
|
|
0
|
1
|
|
my ( $self, $name ) = @_; |
502
|
0
|
|
|
|
|
|
my $reader = TAP::Parser::YAMLish::Reader->new; |
503
|
0
|
|
|
|
|
|
local *FH; |
504
|
0
|
0
|
|
|
|
|
open FH, "<$name" or croak "Can't read $name ($!)"; |
505
|
|
|
|
|
|
|
|
506
|
|
|
|
|
|
|
# XXX this is temporary |
507
|
|
|
|
|
|
|
$self->{_} = $self->result_class->new( |
508
|
|
|
|
|
|
|
$reader->read( |
509
|
|
|
|
|
|
|
sub { |
510
|
0
|
|
|
0
|
|
|
my $line = ; |
511
|
0
|
0
|
|
|
|
|
defined $line && chomp $line; |
512
|
0
|
|
|
|
|
|
return $line; |
513
|
|
|
|
|
|
|
} |
514
|
|
|
|
|
|
|
) |
515
|
0
|
|
|
|
|
|
); |
516
|
|
|
|
|
|
|
|
517
|
|
|
|
|
|
|
# $writer->write( $self->{tests} || {}, \*FH ); |
518
|
0
|
|
|
|
|
|
close FH; |
519
|
0
|
|
|
|
|
|
$self->_regen_seq; |
520
|
0
|
|
|
|
|
|
$self->_prune_and_stamp; |
521
|
0
|
|
|
|
|
|
$self->results->generation( $self->results->generation + 1 ); |
522
|
|
|
|
|
|
|
} |
523
|
|
|
|
|
|
|
|
524
|
|
|
|
|
|
|
sub _prune_and_stamp { |
525
|
0
|
|
|
0
|
|
|
my $self = shift; |
526
|
|
|
|
|
|
|
|
527
|
0
|
|
|
|
|
|
my $results = $self->results; |
528
|
0
|
|
|
|
|
|
my @tests = $self->results->tests; |
529
|
0
|
|
|
|
|
|
for my $test (@tests) { |
530
|
0
|
|
|
|
|
|
my $name = $test->name; |
531
|
0
|
0
|
|
|
|
|
if ( my @stat = stat $name ) { |
532
|
0
|
|
|
|
|
|
$test->mtime( $stat[9] ); |
533
|
|
|
|
|
|
|
} |
534
|
|
|
|
|
|
|
else { |
535
|
0
|
|
|
|
|
|
$results->remove($name); |
536
|
|
|
|
|
|
|
} |
537
|
|
|
|
|
|
|
} |
538
|
|
|
|
|
|
|
} |
539
|
|
|
|
|
|
|
|
540
|
|
|
|
|
|
|
sub _regen_seq { |
541
|
0
|
|
|
0
|
|
|
my $self = shift; |
542
|
0
|
|
|
|
|
|
for my $test ( $self->results->tests ) { |
543
|
|
|
|
|
|
|
$self->{seq} = $test->sequence + 1 |
544
|
0
|
0
|
0
|
|
|
|
if defined $test->sequence && $test->sequence >= $self->{seq}; |
545
|
|
|
|
|
|
|
} |
546
|
|
|
|
|
|
|
} |
547
|
|
|
|
|
|
|
|
548
|
|
|
|
|
|
|
1; |