| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Test::Plan; |
|
2
|
|
|
|
|
|
|
|
|
3
|
28
|
|
|
28
|
|
347640
|
use 5.005; |
|
|
28
|
|
|
|
|
104
|
|
|
|
28
|
|
|
|
|
1102
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
28
|
|
|
28
|
|
151
|
use strict; |
|
|
28
|
|
|
|
|
51
|
|
|
|
28
|
|
|
|
|
1256
|
|
|
6
|
28
|
|
|
28
|
|
168
|
use warnings FATAL => qw(all); |
|
|
28
|
|
|
|
|
47
|
|
|
|
28
|
|
|
|
|
1331
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
28
|
|
|
28
|
|
141
|
use Config; |
|
|
28
|
|
|
|
|
48
|
|
|
|
28
|
|
|
|
|
1275
|
|
|
9
|
28
|
|
|
28
|
|
153
|
use Exporter; |
|
|
28
|
|
|
|
|
68
|
|
|
|
28
|
|
|
|
|
1291
|
|
|
10
|
28
|
|
|
28
|
|
3691
|
use Test::Builder (); |
|
|
28
|
|
|
|
|
38443
|
|
|
|
28
|
|
|
|
|
826
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
28
|
|
|
28
|
|
216
|
use vars qw(@ISA @EXPORT @EXPORT_OK $VERSION @SkipReasons); |
|
|
28
|
|
|
|
|
58
|
|
|
|
28
|
|
|
|
|
4519
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
$VERSION = 0.03; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
@EXPORT = qw(need |
|
19
|
|
|
|
|
|
|
plan |
|
20
|
|
|
|
|
|
|
need_module |
|
21
|
|
|
|
|
|
|
need_min_perl_version |
|
22
|
|
|
|
|
|
|
need_min_module_version |
|
23
|
|
|
|
|
|
|
need_perl_iolayers |
|
24
|
|
|
|
|
|
|
need_threads |
|
25
|
|
|
|
|
|
|
need_perl |
|
26
|
|
|
|
|
|
|
under_construction |
|
27
|
|
|
|
|
|
|
skip_reason); |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my $Test = Test::Builder->new; |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# you need to load Test::More before Test::Plan if |
|
33
|
|
|
|
|
|
|
# modules want to use functions in their own namspaces |
|
34
|
|
|
|
|
|
|
if ($INC{'Test/More.pm'}) { |
|
35
|
|
|
|
|
|
|
|
|
36
|
28
|
|
|
28
|
|
150
|
no warnings qw(redefine); |
|
|
28
|
|
|
|
|
43
|
|
|
|
28
|
|
|
|
|
13759
|
|
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
*Test::More::plan = \&plan; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub import { |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# this is why the warnings pragma sucks - I know better |
|
44
|
|
|
|
|
|
|
# than Exporter whether the warnings it is about to throw |
|
45
|
|
|
|
|
|
|
# are ok or not, but |
|
46
|
|
|
|
|
|
|
# no warnings qw(redefine); |
|
47
|
|
|
|
|
|
|
# doesn't work here by design. |
|
48
|
29
|
|
|
29
|
|
664
|
local $^W=0; |
|
49
|
|
|
|
|
|
|
|
|
50
|
29
|
100
|
|
|
|
35053
|
shift->export_to_level(1, undef, @_ ? @_ : @EXPORT); |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
#--------------------------------------------------------------------- |
|
55
|
|
|
|
|
|
|
# plan() intelligently. essentially a combination of |
|
56
|
|
|
|
|
|
|
# Apache::Test::plan() and Test::More::plan() |
|
57
|
|
|
|
|
|
|
#--------------------------------------------------------------------- |
|
58
|
|
|
|
|
|
|
sub plan { |
|
59
|
|
|
|
|
|
|
|
|
60
|
24
|
|
|
24
|
1
|
8216
|
my @plan = @_; |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# Apache::Test::plan() |
|
63
|
24
|
100
|
|
|
|
141
|
if (@plan % 2) { |
|
64
|
|
|
|
|
|
|
|
|
65
|
21
|
|
|
|
|
49
|
my $condition = pop @plan; |
|
66
|
21
|
|
|
|
|
60
|
my $ref = ref $condition; |
|
67
|
21
|
|
|
|
|
46
|
my $meets_condition = 0; |
|
68
|
|
|
|
|
|
|
|
|
69
|
21
|
100
|
|
|
|
77
|
if ($ref) { |
|
70
|
10
|
100
|
|
|
|
42
|
if ($ref eq 'CODE') { |
|
|
|
100
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# plan tests $n, \&foo; |
|
72
|
5
|
|
|
|
|
17
|
$meets_condition = $condition->(); |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
elsif ($ref eq 'ARRAY') { |
|
75
|
|
|
|
|
|
|
# plan tests $n, [qw(CGI Foo::Bar)]; |
|
76
|
4
|
|
|
|
|
18
|
$meets_condition = need_module($condition); |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
else { |
|
79
|
1
|
|
|
|
|
16
|
die "don't know how to handle a condition of type $ref"; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
else { |
|
83
|
|
|
|
|
|
|
# we have the verdict already: true/false |
|
84
|
11
|
100
|
|
|
|
42
|
$meets_condition = $condition ? 1 : 0; |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
20
|
100
|
|
|
|
131
|
unless ($meets_condition) { |
|
88
|
11
|
100
|
|
|
|
666
|
my $reason = join ', ', |
|
89
|
|
|
|
|
|
|
@SkipReasons ? @SkipReasons : ''; |
|
90
|
|
|
|
|
|
|
|
|
91
|
11
|
|
|
|
|
42
|
@SkipReasons = (); # reset |
|
92
|
|
|
|
|
|
|
|
|
93
|
11
|
|
|
|
|
122
|
$Test->plan(skip_all => $reason); |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
# this will not be reached except in tests, since |
|
96
|
|
|
|
|
|
|
# Test::Builder::plan() calls exit(); |
|
97
|
3
|
|
|
|
|
16
|
return; |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
|
|
101
|
12
|
|
|
|
|
92
|
$Test->plan(@plan); |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
#--------------------------------------------------------------------- |
|
106
|
|
|
|
|
|
|
# very similar to Apache::Test::need_module() except that it doesn't |
|
107
|
|
|
|
|
|
|
# worry about Apache C modules for obvious reasons |
|
108
|
|
|
|
|
|
|
#--------------------------------------------------------------------- |
|
109
|
|
|
|
|
|
|
sub need_module { |
|
110
|
|
|
|
|
|
|
|
|
111
|
6
|
|
|
|
|
27
|
my @modules = grep defined $_, |
|
112
|
28
|
100
|
|
28
|
1
|
10741
|
ref($_[0]) eq 'ARRAY' ? @{ $_[0] } : @_; |
|
113
|
|
|
|
|
|
|
|
|
114
|
28
|
|
|
|
|
59
|
my @reasons = (); |
|
115
|
28
|
|
|
|
|
70
|
for (@modules) { |
|
116
|
34
|
|
|
|
|
2253
|
eval "require $_"; |
|
117
|
34
|
100
|
|
|
|
169563
|
if ($@) { |
|
118
|
14
|
|
|
|
|
62
|
push @reasons, "cannot find module '$_'"; |
|
119
|
|
|
|
|
|
|
} |
|
120
|
|
|
|
|
|
|
} |
|
121
|
28
|
100
|
|
|
|
96
|
if (@reasons) { |
|
122
|
12
|
|
|
|
|
32
|
push @SkipReasons, @reasons; |
|
123
|
12
|
|
|
|
|
65
|
return 0; |
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
else { |
|
126
|
16
|
|
|
|
|
86
|
return 1; |
|
127
|
|
|
|
|
|
|
} |
|
128
|
|
|
|
|
|
|
} |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
#--------------------------------------------------------------------- |
|
132
|
|
|
|
|
|
|
# nearly identical to Apache::Test::need_min_perl_version() |
|
133
|
|
|
|
|
|
|
# as of 1.21. here no version means any version and we trap |
|
134
|
|
|
|
|
|
|
# non-numeric warnings |
|
135
|
|
|
|
|
|
|
#--------------------------------------------------------------------- |
|
136
|
|
|
|
|
|
|
sub need_min_perl_version { |
|
137
|
8
|
|
|
8
|
1
|
9385
|
my $version = shift; |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
# no version means any version |
|
140
|
8
|
100
|
|
|
|
29
|
return 1 unless defined $version; |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
{ |
|
143
|
28
|
|
|
28
|
|
680
|
no warnings qw(numeric); |
|
|
28
|
|
|
|
|
56
|
|
|
|
28
|
|
|
|
|
3630
|
|
|
|
6
|
|
|
|
|
28
|
|
|
144
|
6
|
100
|
|
|
|
33
|
return 1 if $] >= $version; |
|
145
|
|
|
|
|
|
|
} |
|
146
|
|
|
|
|
|
|
|
|
147
|
2
|
|
|
|
|
9
|
push @SkipReasons, "perl >= $version is required"; |
|
148
|
2
|
|
|
|
|
7
|
return 0; |
|
149
|
|
|
|
|
|
|
} |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
#--------------------------------------------------------------------- |
|
153
|
|
|
|
|
|
|
# nearly identical to Apache::Test::need_min_module_version() |
|
154
|
|
|
|
|
|
|
# as of 1.21. here no version means any version |
|
155
|
|
|
|
|
|
|
#--------------------------------------------------------------------- |
|
156
|
|
|
|
|
|
|
sub need_min_module_version { |
|
157
|
7
|
|
|
7
|
1
|
5110
|
my($module, $version) = @_; |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
# need_module requires the perl module |
|
160
|
7
|
100
|
|
|
|
22
|
return 0 unless need_module($module); |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
# no version means any version |
|
163
|
6
|
100
|
|
|
|
21
|
return 1 unless defined $version; |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
# support dev versions like 0.18_01 |
|
166
|
|
|
|
|
|
|
return 1 |
|
167
|
28
|
100
|
|
28
|
|
366
|
if eval { no warnings qw(numeric); $module->VERSION($version) }; |
|
|
28
|
|
|
|
|
58
|
|
|
|
28
|
|
|
|
|
21069
|
|
|
|
4
|
|
|
|
|
6
|
|
|
|
4
|
|
|
|
|
88
|
|
|
168
|
|
|
|
|
|
|
|
|
169
|
1
|
|
|
|
|
6
|
push @SkipReasons, "$module version $version or higher is required"; |
|
170
|
1
|
|
|
|
|
21
|
return 0; |
|
171
|
|
|
|
|
|
|
} |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
#--------------------------------------------------------------------- |
|
175
|
|
|
|
|
|
|
# identical to Apache::Test::need_perl_iolayers() as of 1.21 |
|
176
|
|
|
|
|
|
|
#--------------------------------------------------------------------- |
|
177
|
|
|
|
|
|
|
sub need_perl_iolayers { |
|
178
|
5
|
100
|
|
5
|
1
|
2780
|
if (my $ext = $Config{extensions}) { |
|
179
|
|
|
|
|
|
|
#XXX: better test? might need to test patchlevel |
|
180
|
|
|
|
|
|
|
#if support depends bugs fixed in bleedperl |
|
181
|
3
|
|
|
|
|
3428
|
return $ext =~ m:PerlIO/scalar:; |
|
182
|
|
|
|
|
|
|
} |
|
183
|
2
|
|
|
|
|
9
|
0; |
|
184
|
|
|
|
|
|
|
} |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
#--------------------------------------------------------------------- |
|
188
|
|
|
|
|
|
|
# identical to Apache::Test::config_enabled() as of 1.21 |
|
189
|
|
|
|
|
|
|
# not exported, so don't use it (it should be marked as private) |
|
190
|
|
|
|
|
|
|
#--------------------------------------------------------------------- |
|
191
|
|
|
|
|
|
|
sub config_enabled { |
|
192
|
9
|
|
|
9
|
0
|
9807
|
my $key = shift; |
|
193
|
9
|
100
|
|
|
|
1143
|
defined $Config{$key} and $Config{$key} eq 'define'; |
|
194
|
|
|
|
|
|
|
} |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
#--------------------------------------------------------------------- |
|
198
|
|
|
|
|
|
|
# nearly identical to Apache::Test::need_perl() as of 1.21 |
|
199
|
|
|
|
|
|
|
#--------------------------------------------------------------------- |
|
200
|
|
|
|
|
|
|
sub need_perl { |
|
201
|
5
|
|
100
|
5
|
1
|
2023
|
my $thing = shift || ''; |
|
202
|
|
|
|
|
|
|
#XXX: $thing could be a version |
|
203
|
5
|
|
|
|
|
7
|
my $config; |
|
204
|
|
|
|
|
|
|
|
|
205
|
5
|
|
|
|
|
7
|
my $have = \&{"need_perl_$thing"}; |
|
|
5
|
|
|
|
|
19
|
|
|
206
|
5
|
100
|
|
|
|
12
|
if (defined &$have) { |
|
207
|
2
|
100
|
|
|
|
11
|
return 1 if $have->(); |
|
208
|
|
|
|
|
|
|
} |
|
209
|
|
|
|
|
|
|
else { |
|
210
|
3
|
|
|
|
|
7
|
for my $key ($thing, "use$thing") { |
|
211
|
6
|
100
|
|
|
|
3785
|
if (exists $Config{$key}) { |
|
212
|
2
|
|
|
|
|
11
|
$config = $key; |
|
213
|
2
|
100
|
|
|
|
5
|
return 1 if config_enabled($key); |
|
214
|
|
|
|
|
|
|
} |
|
215
|
|
|
|
|
|
|
} |
|
216
|
|
|
|
|
|
|
} |
|
217
|
|
|
|
|
|
|
|
|
218
|
3
|
100
|
|
|
|
94
|
push @SkipReasons, $config ? |
|
219
|
|
|
|
|
|
|
"Perl was not built with $config enabled" : |
|
220
|
|
|
|
|
|
|
"$thing is not available with this version of Perl"; |
|
221
|
|
|
|
|
|
|
|
|
222
|
3
|
|
|
|
|
8
|
return 0; |
|
223
|
|
|
|
|
|
|
} |
|
224
|
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
#--------------------------------------------------------------------- |
|
227
|
|
|
|
|
|
|
# similar Apache::Test::need_threads() as of 1.21 |
|
228
|
|
|
|
|
|
|
# except we don't check APR |
|
229
|
|
|
|
|
|
|
#--------------------------------------------------------------------- |
|
230
|
|
|
|
|
|
|
sub need_threads { |
|
231
|
3
|
|
|
3
|
1
|
1628
|
my $status = 1; |
|
232
|
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
# check Perl's useithreads |
|
234
|
3
|
|
|
|
|
23
|
my $key = 'useithreads'; |
|
235
|
3
|
100
|
66
|
|
|
851
|
unless (exists $Config{$key} and config_enabled($key)) { |
|
236
|
2
|
|
|
|
|
4
|
$status = 0; |
|
237
|
2
|
|
|
|
|
8
|
push @SkipReasons, "Perl was not built with 'ithreads' enabled"; |
|
238
|
|
|
|
|
|
|
} |
|
239
|
|
|
|
|
|
|
|
|
240
|
3
|
|
|
|
|
13
|
return $status; |
|
241
|
|
|
|
|
|
|
} |
|
242
|
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
#--------------------------------------------------------------------- |
|
245
|
|
|
|
|
|
|
# identical to Apache::Test::under_construction as of 1.21 |
|
246
|
|
|
|
|
|
|
#--------------------------------------------------------------------- |
|
247
|
|
|
|
|
|
|
sub under_construction { |
|
248
|
2
|
|
|
2
|
1
|
1079
|
push @SkipReasons, "This test is under construction"; |
|
249
|
2
|
|
|
|
|
6
|
return 0; |
|
250
|
|
|
|
|
|
|
} |
|
251
|
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
#--------------------------------------------------------------------- |
|
254
|
|
|
|
|
|
|
# identical to Apache::Test::skip_reason() as of 1.21 |
|
255
|
|
|
|
|
|
|
#--------------------------------------------------------------------- |
|
256
|
|
|
|
|
|
|
sub skip_reason { |
|
257
|
3
|
|
100
|
3
|
1
|
996
|
my $reason = shift || 'no reason specified'; |
|
258
|
3
|
|
|
|
|
6
|
push @SkipReasons, $reason; |
|
259
|
3
|
|
|
|
|
10
|
return 0; |
|
260
|
|
|
|
|
|
|
} |
|
261
|
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
#--------------------------------------------------------------------- |
|
264
|
|
|
|
|
|
|
# identical to Apache::Test::need() as of 1.21 |
|
265
|
|
|
|
|
|
|
#--------------------------------------------------------------------- |
|
266
|
|
|
|
|
|
|
sub need { |
|
267
|
5
|
|
|
5
|
1
|
344
|
my $need_all = 1; |
|
268
|
5
|
|
|
|
|
37
|
for my $cond (@_) { |
|
269
|
9
|
50
|
|
|
|
47
|
if (ref $cond eq 'HASH') { |
|
|
|
50
|
|
|
|
|
|
|
270
|
0
|
|
|
|
|
0
|
while (my($reason, $value) = each %$cond) { |
|
271
|
0
|
0
|
|
|
|
0
|
$value = $value->() if ref $value eq 'CODE'; |
|
272
|
0
|
0
|
|
|
|
0
|
next if $value; |
|
273
|
0
|
|
|
|
|
0
|
push @SkipReasons, $reason; |
|
274
|
0
|
|
|
|
|
0
|
$need_all = 0; |
|
275
|
|
|
|
|
|
|
} |
|
276
|
|
|
|
|
|
|
} |
|
277
|
|
|
|
|
|
|
elsif ($cond =~ /^(0|1)$/) { |
|
278
|
9
|
100
|
|
|
|
26
|
$need_all = 0 if $cond == 0; |
|
279
|
|
|
|
|
|
|
} |
|
280
|
|
|
|
|
|
|
else { |
|
281
|
0
|
0
|
|
|
|
0
|
$need_all = 0 unless need_module($cond); |
|
282
|
|
|
|
|
|
|
} |
|
283
|
|
|
|
|
|
|
} |
|
284
|
5
|
|
|
|
|
13
|
return $need_all; |
|
285
|
|
|
|
|
|
|
} |
|
286
|
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
1; |
|
288
|
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
__END__ |