line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::AllModules; |
2
|
22
|
|
|
22
|
|
202905
|
use strict; |
|
22
|
|
|
|
|
173
|
|
|
22
|
|
|
|
|
602
|
|
3
|
22
|
|
|
22
|
|
112
|
use warnings; |
|
22
|
|
|
|
|
44
|
|
|
22
|
|
|
|
|
524
|
|
4
|
22
|
|
|
22
|
|
11348
|
use Module::Pluggable::Object; |
|
22
|
|
|
|
|
210008
|
|
|
22
|
|
|
|
|
692
|
|
5
|
22
|
|
|
22
|
|
12472
|
use Test::More (); |
|
22
|
|
|
|
|
1303286
|
|
|
22
|
|
|
|
|
4210
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.17'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my $USE_OK = sub { |
10
|
5
|
|
|
5
|
|
1807
|
eval "use $_[0];"; ## no critic |
|
5
|
|
|
|
|
604
|
|
|
5
|
|
|
|
|
96
|
|
11
|
|
|
|
|
|
|
if (my $e = $@) { |
12
|
|
|
|
|
|
|
Test::More::note($e); |
13
|
|
|
|
|
|
|
return; |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
return 1; |
16
|
|
|
|
|
|
|
}; |
17
|
|
|
|
|
|
|
my $USE_NO_IMPORT_OK = sub { |
18
|
|
|
|
|
|
|
eval "use $_[0] qw//;"; ## no critic |
19
|
|
|
|
|
|
|
if (my $e = $@) { |
20
|
|
|
|
|
|
|
Test::More::note($e); |
21
|
|
|
|
|
|
|
return; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
return 1; |
24
|
|
|
|
|
|
|
}; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my $REQUIRE_OK = sub { |
28
|
|
|
|
|
|
|
eval "require $_[0];"; ## no critic |
29
|
|
|
|
|
|
|
if (my $e = $@) { |
30
|
|
|
|
|
|
|
Test::More::note($e); |
31
|
|
|
|
|
|
|
return; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
return 1; |
34
|
|
|
|
|
|
|
}; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub import { |
37
|
22
|
|
|
22
|
|
239
|
my $class = shift; |
38
|
|
|
|
|
|
|
|
39
|
22
|
|
|
|
|
60
|
my $caller = caller; |
40
|
|
|
|
|
|
|
|
41
|
22
|
|
|
22
|
|
203
|
no strict 'refs'; ## no critic |
|
22
|
|
|
|
|
48
|
|
|
22
|
|
|
|
|
17427
|
|
42
|
22
|
|
|
|
|
62
|
for my $func (qw/ all_ok /) { |
43
|
22
|
|
|
|
|
36
|
*{"${caller}::$func"} = \&{"Test::AllModules::$func"}; |
|
22
|
|
|
|
|
3062
|
|
|
22
|
|
|
|
|
101
|
|
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub all_ok { |
48
|
20
|
|
|
20
|
1
|
1855
|
my %param = @_; |
49
|
|
|
|
|
|
|
|
50
|
20
|
|
|
|
|
68
|
my $search_path = delete $param{search_path}; |
51
|
20
|
|
66
|
|
|
159
|
my $use_ok = delete $param{use} || $param{use_ok}; |
52
|
20
|
|
66
|
|
|
142
|
my $require_ok = delete $param{require} || $param{require_ok}; |
53
|
20
|
|
|
|
|
48
|
my $check = delete $param{check}; |
54
|
20
|
|
|
|
|
42
|
my $checks = delete $param{checks}; |
55
|
20
|
|
|
|
|
51
|
my $except = delete $param{except}; |
56
|
20
|
|
|
|
|
50
|
my $lib = delete $param{lib}; |
57
|
20
|
|
|
|
|
70
|
my $fork = delete $param{fork}; |
58
|
20
|
|
|
|
|
42
|
my $shuffle = delete $param{shuffle}; |
59
|
20
|
|
|
|
|
36
|
my $show_version = delete $param{show_version}; |
60
|
20
|
|
|
|
|
71
|
my $no_import = delete $param{no_import}; |
61
|
20
|
|
|
|
|
39
|
my $before_hook = delete $param{before_hook}; |
62
|
20
|
|
|
|
|
31
|
my $after_hook = delete $param{after_hook}; |
63
|
|
|
|
|
|
|
|
64
|
20
|
50
|
33
|
|
|
57
|
if ( _is_win() && $fork ) { |
65
|
0
|
|
|
|
|
0
|
Test::More::plan skip_all => 'The "fork" option is not supported in Windows'; |
66
|
0
|
|
|
|
|
0
|
exit; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
20
|
|
|
|
|
60
|
my @checks; |
70
|
20
|
50
|
|
|
|
123
|
push @checks, +{ test => $no_import ? $USE_NO_IMPORT_OK : $USE_OK, name => 'use: ' } if $use_ok; |
|
|
100
|
|
|
|
|
|
71
|
20
|
100
|
|
|
|
64
|
push @checks, +{ test => $REQUIRE_OK, name => 'require: ' } if $require_ok; |
72
|
|
|
|
|
|
|
|
73
|
20
|
100
|
|
|
|
66
|
if (ref($check) eq 'CODE') { |
74
|
1
|
|
|
|
|
3
|
push @checks, +{ test => $check, name => '', }; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
else { |
77
|
19
|
100
|
|
|
|
40
|
for my $code ( $check, @{ $checks || [] } ) { |
|
19
|
|
|
|
|
168
|
|
78
|
25
|
100
|
|
|
|
49
|
my ($name) = keys %{$code || +{}}; |
|
25
|
|
|
|
|
160
|
|
79
|
25
|
100
|
|
|
|
96
|
my $test = $name ? $code->{$name} : undef; |
80
|
25
|
100
|
|
|
|
127
|
if (ref($test) eq 'CODE') { |
81
|
17
|
|
|
|
|
86
|
push @checks, +{ test => $test, name => "$name: ", }; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
20
|
50
|
|
|
|
76
|
unless ($search_path) { |
87
|
0
|
|
|
|
|
0
|
Test::More::plan skip_all => 'no search path'; |
88
|
0
|
|
|
|
|
0
|
exit; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
20
|
|
|
|
|
94
|
Test::More::plan('no_plan'); |
92
|
20
|
100
|
|
|
|
5559
|
my @exceptions = @{ $except || [] }; |
|
20
|
|
|
|
|
135
|
|
93
|
|
|
|
|
|
|
|
94
|
20
|
100
|
|
|
|
71
|
if ($fork) { |
95
|
8
|
|
|
|
|
4104
|
require Test::SharedFork; |
96
|
8
|
|
|
|
|
393004
|
Test::More::note("Tests run under forking. Parent PID=$$"); |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
20
|
|
|
|
|
5209
|
my $count = 0; |
100
|
20
|
|
|
|
|
183
|
for my $class ( |
101
|
41
|
|
|
|
|
144
|
grep { !_is_excluded( $_, @exceptions ) } |
102
|
|
|
|
|
|
|
_classes($search_path, $lib, $shuffle) ) { |
103
|
33
|
|
|
|
|
132
|
$count++; |
104
|
33
|
|
|
|
|
119
|
for my $code (@checks) { |
105
|
38
|
50
|
33
|
|
|
239
|
next if $before_hook && $before_hook->($code, $class, $count); |
106
|
38
|
|
|
|
|
174
|
my $ret = _exec_test($code, $class, $count, $fork, $show_version); |
107
|
32
|
50
|
|
|
|
339
|
$after_hook && $after_hook->($ret, $code, $class, $count); |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
14
|
100
|
|
|
|
384
|
Test::More::note( "total: $count module". ($count > 1 ? 's' : '') ); |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub _exec_test { |
116
|
38
|
|
|
38
|
|
196
|
my ($code, $class, $count, $fork, $show_version) = @_; |
117
|
|
|
|
|
|
|
|
118
|
38
|
|
|
|
|
85
|
my $ret; |
119
|
|
|
|
|
|
|
|
120
|
38
|
100
|
|
|
|
132
|
unless ($fork) { |
121
|
20
|
|
|
|
|
50
|
$ret = _ok($code, $class, $count, undef, $show_version); |
122
|
20
|
|
|
|
|
46
|
return $ret; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
18
|
|
|
|
|
16028
|
my $pid = fork(); |
126
|
18
|
50
|
|
|
|
875
|
die 'could not fork' unless defined $pid; |
127
|
|
|
|
|
|
|
|
128
|
18
|
100
|
|
|
|
454
|
if ($pid) { |
129
|
12
|
|
|
|
|
3822034
|
waitpid($pid, 0); |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
else { |
132
|
6
|
|
|
|
|
987
|
$ret = _ok($code, $class, $count, $fork, $show_version); |
133
|
6
|
|
|
|
|
14891
|
exit; |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
12
|
|
|
|
|
517
|
return $ret; |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
sub _ok { |
140
|
26
|
|
|
26
|
|
221
|
my ($code, $class, $count, $fork, $show_version) = @_; |
141
|
|
|
|
|
|
|
|
142
|
26
|
100
|
100
|
|
|
687
|
my $test_name = "$code->{name}$class". ($fork && $fork == 2 ? "(PID=$$)" : ''); |
143
|
|
|
|
|
|
|
|
144
|
26
|
|
|
|
|
106
|
my $ret; |
145
|
26
|
|
|
|
|
154
|
eval { |
146
|
26
|
|
|
|
|
331
|
$ret = $code->{test}->($class, $count); |
147
|
|
|
|
|
|
|
}; |
148
|
|
|
|
|
|
|
|
149
|
26
|
50
|
|
|
|
13511
|
if (my $e = $@) { |
150
|
0
|
|
|
|
|
0
|
Test::More::fail($test_name); |
151
|
0
|
|
|
|
|
0
|
Test::More::note("The Test failed: $e"); |
152
|
0
|
|
|
|
|
0
|
return; |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
26
|
50
|
|
|
|
259
|
if ( Test::More::ok($ret, $test_name) ) { |
156
|
26
|
100
|
|
|
|
21509
|
if ($show_version) { |
157
|
22
|
|
|
22
|
|
178
|
no strict 'refs'; ## no critic |
|
22
|
|
|
|
|
53
|
|
|
22
|
|
|
|
|
10286
|
|
158
|
2
|
100
|
|
|
|
5
|
if ( my $version = ${"$class\::VERSION"} ) { |
|
2
|
|
|
|
|
11
|
|
159
|
1
|
|
|
|
|
4
|
Test::More::note("$class $version"); |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
} |
162
|
26
|
|
|
|
|
422
|
return 1; # ok |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
else { |
165
|
0
|
0
|
|
|
|
0
|
my $got = defined $ret ? $ret : ''; |
166
|
0
|
|
|
|
|
0
|
Test::More::note("The Test did NOT return true value. got: $got"); |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
|
169
|
0
|
|
|
|
|
0
|
return; |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
sub _classes { |
173
|
22
|
|
|
22
|
|
278
|
my ($search_path, $lib, $shuffle) = @_; |
174
|
|
|
|
|
|
|
|
175
|
22
|
100
|
|
|
|
37
|
local @INC = @{ $lib || ['lib'] }; |
|
22
|
|
|
|
|
257
|
|
176
|
22
|
|
|
|
|
321
|
my $finder = Module::Pluggable::Object->new( |
177
|
|
|
|
|
|
|
search_path => $search_path, |
178
|
|
|
|
|
|
|
); |
179
|
22
|
|
|
|
|
306
|
my @classes = ( $search_path, $finder->plugins ); |
180
|
|
|
|
|
|
|
|
181
|
22
|
100
|
|
|
|
18560
|
return $shuffle ? _shuffle(@classes) : sort(@classes); |
182
|
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
# This '_shuffle' method copied |
185
|
|
|
|
|
|
|
# from http://blog.nomadscafe.jp/archives/000246.html |
186
|
|
|
|
|
|
|
sub _shuffle { |
187
|
2
|
|
|
2
|
|
17
|
map { $_[$_->[0]] } sort { $a->[1] <=> $b->[1] } map { [$_ , rand(1)] } 0..$#_; |
|
6
|
|
|
|
|
44
|
|
|
6
|
|
|
|
|
33
|
|
|
6
|
|
|
|
|
55
|
|
188
|
|
|
|
|
|
|
} |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
# This '_any' method copied from List::MoreUtils. |
191
|
|
|
|
|
|
|
sub _any (&@) { ## no critic |
192
|
41
|
|
|
41
|
|
105
|
my $f = shift; |
193
|
|
|
|
|
|
|
|
194
|
41
|
|
|
|
|
82
|
foreach ( @_ ) { |
195
|
5
|
100
|
|
|
|
10
|
return 1 if $f->(); |
196
|
|
|
|
|
|
|
} |
197
|
39
|
|
|
|
|
206
|
return; |
198
|
|
|
|
|
|
|
} |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
sub _is_excluded { |
201
|
41
|
|
|
41
|
|
119
|
my ( $module, @exceptions ) = @_; |
202
|
41
|
100
|
|
5
|
|
187
|
_any { $module eq $_ || $module =~ /$_/ } @exceptions; |
|
5
|
|
|
|
|
54
|
|
203
|
|
|
|
|
|
|
} |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
sub _is_win { |
206
|
20
|
50
|
33
|
20
|
|
242
|
return ($^O && $^O eq 'MSWin32') ? 1 : 0; |
207
|
|
|
|
|
|
|
} |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
1; |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
__END__ |