line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Stream::Plugin::SkipWithout; |
2
|
3
|
|
|
3
|
|
10
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
69
|
|
3
|
3
|
|
|
3
|
|
10
|
use warnings; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
342
|
|
4
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
13
|
use Test::Stream::Context qw/context/; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
16
|
|
6
|
3
|
|
|
3
|
|
10
|
use Test::Stream::Util qw/pkg_to_file/; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
69
|
|
7
|
3
|
|
|
3
|
|
11
|
use Scalar::Util qw/reftype/; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
118
|
|
8
|
|
|
|
|
|
|
|
9
|
3
|
|
|
3
|
|
10
|
use Test::Stream::Plugin qw/import/; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
12
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub load_ts_plugin { |
12
|
9
|
|
|
9
|
0
|
12
|
my $class = shift; |
13
|
9
|
|
|
|
|
8
|
my $caller = shift; |
14
|
9
|
|
|
|
|
14
|
for my $arg (@_) { |
15
|
9
|
100
|
|
|
|
27
|
if (ref $arg) { |
|
|
100
|
|
|
|
|
|
16
|
4
|
|
|
|
|
7
|
check_versions($caller, $arg); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
elsif ($arg =~ m/^v?\d/) { |
19
|
2
|
|
|
|
|
3
|
check_perl_version($caller, $arg); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
else { |
22
|
3
|
|
|
|
|
5
|
check_installed($caller, $arg); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub skip { |
28
|
5
|
|
|
5
|
0
|
9
|
my ($msg) = @_; |
29
|
5
|
|
|
|
|
11
|
my $ctx = context(); |
30
|
5
|
|
|
|
|
16
|
$ctx->plan(0, SKIP => $msg); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub check_installed { |
34
|
8
|
|
|
8
|
0
|
8
|
my ($caller, $mod) = @_; |
35
|
8
|
|
|
|
|
17
|
my $file = pkg_to_file($mod); |
36
|
8
|
100
|
|
|
|
11
|
return if eval { require $file; 1 }; |
|
8
|
|
|
|
|
184
|
|
|
6
|
|
|
|
|
21
|
|
37
|
2
|
|
|
|
|
5
|
my $error = $@; |
38
|
2
|
50
|
|
|
|
29
|
return skip("Module '$mod' is not installed") |
39
|
|
|
|
|
|
|
if $error =~ m/Can't locate \Q$file\E in \@INC/; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# Some other error, rethrow it. |
42
|
0
|
|
|
|
|
0
|
die $error; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub check_perl_version { |
46
|
2
|
|
|
2
|
0
|
4
|
my ($caller, $ver) = @_; |
47
|
2
|
100
|
|
1
|
|
108
|
return if eval "no warnings 'portable'; require $ver; 1"; |
|
1
|
|
|
1
|
|
4
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
33
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
24
|
|
48
|
1
|
|
|
|
|
3
|
my $error = $@; |
49
|
1
|
50
|
|
|
|
5
|
if ($error =~ m/^(Perl \S* required)/i) { |
50
|
1
|
|
|
|
|
2
|
return skip($1); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# Other Error |
54
|
0
|
|
|
|
|
0
|
die $error; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub check_versions { |
58
|
4
|
|
|
4
|
0
|
4
|
my ($caller, $ref) = @_; |
59
|
4
|
|
50
|
|
|
12
|
my $type = reftype($ref) || ""; |
60
|
4
|
50
|
|
|
|
8
|
die "'$ref' is not a valid import argument to " . __PACKAGE__ . " at $caller->[1] line $caller->[2].\n" |
61
|
|
|
|
|
|
|
unless $type eq 'HASH'; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# Sort so that the order is always the same in output |
64
|
4
|
|
|
|
|
12
|
for my $mod (sort keys %$ref) { |
65
|
5
|
|
|
|
|
6
|
my $ver = $ref->{$mod}; |
66
|
5
|
|
|
|
|
7
|
check_installed($caller, $mod); |
67
|
4
|
100
|
|
|
|
4
|
next if eval { $mod->VERSION($ver); 1 }; |
|
4
|
|
|
|
|
58
|
|
|
2
|
|
|
|
|
10
|
|
68
|
2
|
|
|
|
|
7
|
chomp(my $error = $@); |
69
|
2
|
|
|
|
|
10
|
$error =~ s/ at .*$//; |
70
|
2
|
|
|
|
|
2
|
skip($error); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
1; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
__END__ |