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