line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Require::Module; |
2
|
2
|
|
|
2
|
|
421
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
58
|
|
3
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
53
|
|
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
11
|
use base 'Test2::Require'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
818
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.000155'; |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
13
|
use Test2::Util qw/pkg_to_file/; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
600
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub skip { |
12
|
5
|
|
|
5
|
0
|
115
|
my $class = shift; |
13
|
5
|
|
|
|
|
14
|
my ($module, $ver) = @_; |
14
|
|
|
|
|
|
|
|
15
|
5
|
100
|
|
|
|
15
|
return "Module '$module' is not installed" |
16
|
|
|
|
|
|
|
unless check_installed($module); |
17
|
|
|
|
|
|
|
|
18
|
4
|
100
|
|
|
|
27
|
return undef unless defined $ver; |
19
|
|
|
|
|
|
|
|
20
|
2
|
|
|
|
|
7
|
return check_version($module, $ver); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub check_installed { |
24
|
5
|
|
|
5
|
0
|
12
|
my ($mod) = @_; |
25
|
5
|
|
|
|
|
18
|
my $file = pkg_to_file($mod); |
26
|
|
|
|
|
|
|
|
27
|
5
|
100
|
|
|
|
83
|
return 1 if eval { require $file; 1 }; |
|
5
|
|
|
|
|
1549
|
|
|
4
|
|
|
|
|
98409
|
|
28
|
1
|
|
|
|
|
6
|
my $error = $@; |
29
|
|
|
|
|
|
|
|
30
|
1
|
50
|
|
|
|
26
|
return 0 if $error =~ m/Can't locate \Q$file\E in \@INC/; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# Some other error, rethrow it. |
33
|
0
|
|
|
|
|
0
|
die $error; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub check_version { |
37
|
2
|
|
|
2
|
0
|
7
|
my ($mod, $ver) = @_; |
38
|
|
|
|
|
|
|
|
39
|
2
|
100
|
|
|
|
4
|
return undef if eval { $mod->VERSION($ver); 1 }; |
|
2
|
|
|
|
|
59
|
|
|
1
|
|
|
|
|
12
|
|
40
|
1
|
|
|
|
|
11
|
my $have = $mod->VERSION; |
41
|
1
|
|
|
|
|
16
|
return "Need '$mod' version $ver, have $have."; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
__END__ |