line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Run::Plugin::CollectStats; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
163517
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
76
|
|
4
|
2
|
|
|
2
|
|
13
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
65
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
2175
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use MRO::Compat; |
9
|
|
|
|
|
|
|
use Storable (); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
extends('Test::Run::Base'); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use Test::Run::Plugin::CollectStats::TestFileData; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 NAME |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Test::Run::Plugin::CollectStats - Test::Run plugin to collect statistics and |
18
|
|
|
|
|
|
|
data. |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 VERSION |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Version 0.0103 |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=cut |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has '_recorded_test_files_data' => (is => "rw", isa => "ArrayRef", |
27
|
|
|
|
|
|
|
default => sub { [] }, |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
has '_test_files_names_map' => (is => "rw", isa => "HashRef", |
31
|
|
|
|
|
|
|
default => sub { +{} }, |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
our $VERSION = '0.0103'; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 SYNOPSIS |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
package MyTestRun; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
use base 'Test::Run::Plugin::AlternateInterpreters'; |
41
|
|
|
|
|
|
|
use base 'Test::Run::Obj'; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 METHODS |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=cut |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub _run_single_test |
48
|
|
|
|
|
|
|
{ |
49
|
|
|
|
|
|
|
my ($self, $args) = @_; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
my $filename = $args->{test_file}; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
$self->next::method($args); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
$self->_test_files_names_map->{$filename} = |
56
|
|
|
|
|
|
|
scalar(@{$self->_recorded_test_files_data()}); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
push @{$self->_recorded_test_files_data}, |
59
|
|
|
|
|
|
|
Test::Run::Plugin::CollectStats::TestFileData->new( |
60
|
|
|
|
|
|
|
{ |
61
|
|
|
|
|
|
|
elapsed_time => $self->last_test_elapsed(), |
62
|
|
|
|
|
|
|
results => Storable::dclone($self->last_test_results()), |
63
|
|
|
|
|
|
|
summary_object => Storable::dclone($self->last_test_obj()), |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
return; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head2 $tester->get_recorded_test_file_data($index) |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Returns the L<Test::Run::Plugin::CollectStats::TestFileData> instance |
73
|
|
|
|
|
|
|
representing the results of test number $index. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=cut |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub get_recorded_test_file_data |
78
|
|
|
|
|
|
|
{ |
79
|
|
|
|
|
|
|
my $self = shift; |
80
|
|
|
|
|
|
|
my $idx = shift; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
return $self->_recorded_test_files_data->[$idx]; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head2 $tester->find_test_file_idx_by_filename($filename) |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Retrieves the (last) index of the test file $filename. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=cut |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub find_test_file_idx_by_filename |
92
|
|
|
|
|
|
|
{ |
93
|
|
|
|
|
|
|
my $self = shift; |
94
|
|
|
|
|
|
|
my $filename = shift; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
return $self->_test_files_names_map->{$filename}; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head2 $tester->get_num_collected_tests() |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Retrieves the number of collected tests. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=cut |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub get_num_collected_tests |
106
|
|
|
|
|
|
|
{ |
107
|
|
|
|
|
|
|
my $self = shift; |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
return scalar(@{$self->_recorded_test_files_data}); |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head2 $tester->get_filename_test_data($filename) |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Returns theL<Test::Run::Plugin::CollectStats::TestFileData> instance |
115
|
|
|
|
|
|
|
representing the results of the (last) test with the filename $filename. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=cut |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub get_filename_test_data |
120
|
|
|
|
|
|
|
{ |
121
|
|
|
|
|
|
|
my $self = shift; |
122
|
|
|
|
|
|
|
my $filename = shift; |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
return $self->get_recorded_test_file_data( |
125
|
|
|
|
|
|
|
$self->find_test_file_idx_by_filename($filename) |
126
|
|
|
|
|
|
|
); |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 SEE ALSO |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
L<Test::Run::Plugin::CollectStats::TestFileData>, L<Test::Run::Core>, |
132
|
|
|
|
|
|
|
L<Test::Run::Obj>. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 AUTHOR |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Shlomi Fish, C<< <shlomif at cpan.org> >> |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head1 BUGS |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
141
|
|
|
|
|
|
|
C<bug-test-run-plugin-collectstats at rt.cpan.org>, or through the web interface at |
142
|
|
|
|
|
|
|
L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Run-Plugin-CollectStats>. |
143
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
144
|
|
|
|
|
|
|
your bug as I make changes. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 SUPPORT |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
perldoc Test::Run::Plugin::CollectStats |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
You can also look for information at: |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=over 4 |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
L<http://annocpan.org/dist/Test-Run-Plugin-CollectStats> |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=item * CPAN Ratings |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
L<http://cpanratings.perl.org/d/Test-Run-Plugin-CollectStats> |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Test-Run-Plugin-CollectStats> |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=item * Search CPAN |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
L<http://search.cpan.org/dist/Test-Run-Plugin-CollectStats> |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=back |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
Copyright 2007 Shlomi Fish, all rights reserved. |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
This program is released under the following license: MIT/X11. |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=cut |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
1; # End of Test::Run::Plugin::CollectStats |