line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Requires::Env; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
6585
|
use strict; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
249
|
|
4
|
6
|
|
|
6
|
|
30
|
use warnings; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
211
|
|
5
|
6
|
|
|
6
|
|
6139
|
use parent qw(Test::Builder::Module); |
|
6
|
|
|
|
|
2247
|
|
|
6
|
|
|
|
|
30
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub import { |
10
|
6
|
|
|
6
|
|
47
|
my $class = shift; |
11
|
6
|
|
|
|
|
16
|
my $caller = caller(0); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# export methods |
14
|
|
|
|
|
|
|
{ |
15
|
6
|
|
|
6
|
|
530
|
no strict 'refs'; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
3069
|
|
|
6
|
|
|
|
|
12
|
|
16
|
6
|
|
|
|
|
13
|
*{"$caller\::test_environments"} = \&test_environments; |
|
6
|
|
|
|
|
46
|
|
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
6
|
100
|
|
|
|
5510
|
if ( @_ > 0 ) { |
20
|
2
|
|
|
|
|
5
|
test_environments(@_); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub test_environments { |
25
|
6
|
|
|
6
|
1
|
56
|
my @entries = @_; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my $skip_all = sub { |
28
|
4
|
|
|
4
|
|
52
|
my $builder = __PACKAGE__->builder; |
29
|
|
|
|
|
|
|
|
30
|
4
|
100
|
|
|
|
71
|
if ( not defined $builder->has_plan ) { |
|
|
100
|
|
|
|
|
|
31
|
2
|
|
|
|
|
25
|
$builder->skip_all(@_); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
elsif ( $builder->has_plan eq 'no_plan' ) { |
34
|
1
|
|
|
|
|
19
|
$builder->skip(@_); |
35
|
1
|
50
|
33
|
|
|
165
|
if ( $builder->can('parent') && $builder->parent ) { |
36
|
0
|
|
|
|
|
0
|
die bless {} => 'Test::Builder::Exception'; |
37
|
|
|
|
|
|
|
} |
38
|
1
|
|
|
|
|
97
|
exit 0; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
else { |
41
|
1
|
|
|
|
|
21
|
for ( 1 .. $builder->has_plan ) { |
42
|
1
|
|
|
|
|
13
|
$builder->skip(@_); |
43
|
|
|
|
|
|
|
} |
44
|
1
|
50
|
33
|
|
|
236
|
if ( $builder->can('parent') && $builder->parent ) { |
45
|
0
|
|
|
|
|
0
|
die bless {} => 'Test::Builder::Exception'; |
46
|
|
|
|
|
|
|
} |
47
|
1
|
|
|
|
|
139
|
exit 0; |
48
|
|
|
|
|
|
|
} |
49
|
6
|
|
|
|
|
38
|
}; |
50
|
|
|
|
|
|
|
|
51
|
6
|
|
|
|
|
15
|
for my $entry ( @entries ) { |
52
|
9
|
100
|
|
|
|
31
|
if ( ref $entry eq 'HASH' ) { |
53
|
2
|
|
|
|
|
6
|
for my $env_name ( keys %$entry ) { |
54
|
4
|
50
|
|
|
|
13
|
unless ( exists $ENV{$env_name} ) { |
55
|
0
|
|
|
|
|
0
|
$skip_all->( sprintf('%s environment is not existed', $env_name) ); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
4
|
100
|
|
|
|
11
|
if ( ref $entry->{$env_name} eq 'Regexp' ) { |
59
|
3
|
|
|
|
|
3
|
my $regex = $entry->{$env_name}; |
60
|
3
|
100
|
|
|
|
31
|
$ENV{$env_name} =~ m#$regex# |
61
|
|
|
|
|
|
|
or $skip_all->( sprintf('%s environment is not match by the pattern (pattern: %s)', $env_name, "$regex") ); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
else { |
64
|
1
|
50
|
|
|
|
4
|
( $ENV{$env_name} eq $entry->{$env_name} ) |
65
|
|
|
|
|
|
|
or $skip_all->( sprintf("%s environment is not equals %s", $env_name, $entry->{$env_name}) ); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
else { |
70
|
7
|
100
|
|
|
|
43
|
unless ( exists $ENV{$entry} ) { |
71
|
3
|
|
|
|
|
27
|
$skip_all->( sprintf('%s environment is not existed', $entry) ); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |
78
|
|
|
|
|
|
|
__END__ |