line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Requires; |
2
|
9
|
|
|
9
|
|
175473
|
use strict; |
|
9
|
|
|
|
|
16236
|
|
|
9
|
|
|
|
|
386
|
|
3
|
9
|
|
|
9
|
|
3620
|
use warnings; |
|
8
|
|
|
|
|
1384
|
|
|
8
|
|
|
|
|
271
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.08'; |
5
|
7
|
|
|
7
|
|
33
|
use base 'Test::Builder::Module'; |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
892
|
|
6
|
7
|
|
|
7
|
|
148
|
use 5.006000; |
|
7
|
|
|
|
|
22
|
|
|
7
|
|
|
|
|
480
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub import { |
9
|
7
|
|
|
7
|
|
44
|
my $class = shift; |
10
|
7
|
|
|
|
|
16
|
my $caller = caller(0); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# export methods |
13
|
|
|
|
|
|
|
{ |
14
|
7
|
|
|
7
|
|
49
|
no strict 'refs'; |
|
7
|
|
|
|
|
16
|
|
|
7
|
|
|
|
|
3282
|
|
|
7
|
|
|
|
|
13
|
|
15
|
7
|
|
|
|
|
16
|
*{"$caller\::test_requires"} = \&test_requires; |
|
7
|
|
|
|
|
36
|
|
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# test arguments |
19
|
7
|
100
|
100
|
|
|
69
|
if (@_ == 1 && ref $_[0] && ref $_[0] eq 'HASH') { |
|
|
|
66
|
|
|
|
|
20
|
1
|
|
|
|
|
2
|
while (my ($mod, $ver) = each %{$_[0]}) { |
|
1
|
|
|
|
|
7
|
|
21
|
1
|
|
|
|
|
3
|
test_requires($mod, $ver, $caller); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
} else { |
24
|
6
|
|
|
|
|
6760
|
for my $mod (@_) { |
25
|
1
|
|
|
|
|
3
|
test_requires($mod, undef, $caller); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub test_requires { |
31
|
10
|
|
|
10
|
0
|
843
|
my ( $mod, $ver, $caller ) = @_; |
32
|
10
|
50
|
|
|
|
58
|
return if $mod eq __PACKAGE__; |
33
|
10
|
100
|
|
|
|
48
|
if (@_ != 3) { |
34
|
8
|
|
|
|
|
21
|
$caller = caller(0); |
35
|
|
|
|
|
|
|
} |
36
|
10
|
|
100
|
|
|
59
|
$ver ||= ''; |
37
|
|
|
|
|
|
|
|
38
|
10
|
|
|
6
|
|
858
|
eval qq{package $caller; use $mod $ver}; ## no critic. |
|
6
|
|
|
|
|
2708
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
90
|
|
39
|
10
|
100
|
|
|
|
195
|
if (my $e = $@) { |
40
|
|
|
|
|
|
|
my $skip_all = sub { |
41
|
5
|
|
|
5
|
|
66
|
my $builder = __PACKAGE__->builder; |
42
|
|
|
|
|
|
|
|
43
|
5
|
100
|
|
|
|
81
|
if (not defined $builder->has_plan) { |
|
|
100
|
|
|
|
|
|
44
|
2
|
|
|
|
|
29
|
$builder->skip_all(@_); |
45
|
|
|
|
|
|
|
} elsif ($builder->has_plan eq 'no_plan') { |
46
|
2
|
|
|
|
|
53
|
$builder->skip(@_); |
47
|
2
|
50
|
33
|
|
|
1463
|
if ( $builder->can('parent') && $builder->parent ) { |
48
|
0
|
|
|
|
|
0
|
die bless {} => 'Test::Builder::Exception'; |
49
|
|
|
|
|
|
|
} |
50
|
2
|
|
|
|
|
330
|
exit 0; |
51
|
|
|
|
|
|
|
} else { |
52
|
1
|
|
|
|
|
20
|
for (1..$builder->has_plan) { |
53
|
10
|
|
|
|
|
2888
|
$builder->skip(@_); |
54
|
|
|
|
|
|
|
} |
55
|
1
|
50
|
33
|
|
|
286
|
if ( $builder->can('parent') && $builder->parent ) { |
56
|
0
|
|
|
|
|
0
|
die bless {} => 'Test::Builder::Exception'; |
57
|
|
|
|
|
|
|
} |
58
|
1
|
|
|
|
|
125
|
exit 0; |
59
|
|
|
|
|
|
|
} |
60
|
5
|
|
|
|
|
33
|
}; |
61
|
|
|
|
|
|
|
|
62
|
5
|
|
|
|
|
17
|
my $msg = "$e"; |
63
|
5
|
100
|
|
|
|
33
|
if ( $e =~ /^Can't locate/ ) { |
64
|
4
|
|
|
|
|
16
|
$msg = "Test requires module '$mod' but it's not found"; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
5
|
50
|
|
|
|
30
|
if ($ENV{RELEASE_TESTING}) { |
68
|
0
|
|
|
|
|
0
|
__PACKAGE__->builder->BAIL_OUT($msg); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
else { |
71
|
5
|
|
|
|
|
19
|
$skip_all->($msg); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |
77
|
|
|
|
|
|
|
__END__ |