line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::DirectoryLayout; |
2
|
|
|
|
|
|
|
$Test::DirectoryLayout::VERSION = '0.003'; # TRIAL |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
#ABSTRACT: Test directory layout for standard compliance |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
61506
|
use strict; |
|
1
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
24
|
|
7
|
1
|
|
|
1
|
|
21
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
4
|
use base qw(Test::Builder::Module); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
514
|
|
10
|
|
|
|
|
|
|
our @EXPORT = qw(directory_layout_ok get_allowed_dirs set_allowed_dirs); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my @diags; |
13
|
|
|
|
|
|
|
my $CLASS = __PACKAGE__; |
14
|
|
|
|
|
|
|
my $Tester = $CLASS->builder; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
{ |
17
|
|
|
|
|
|
|
my @allowed_dirs = qw(bin blib lib config doc t); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub get_allowed_dirs { |
20
|
6
|
|
|
6
|
1
|
7897
|
return \@allowed_dirs; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub set_allowed_dirs { |
24
|
2
|
|
|
2
|
1
|
643
|
my ($dirs) = @_; |
25
|
2
|
|
|
|
|
9
|
@allowed_dirs = @$dirs; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub directory_layout_ok { |
30
|
3
|
|
|
3
|
1
|
19072
|
my ($dir) = @_; |
31
|
3
|
50
|
|
|
|
10
|
$dir = '.' unless $dir; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# clean up diagnostics from prior tests |
34
|
3
|
|
|
|
|
5
|
undef @diags; |
35
|
|
|
|
|
|
|
|
36
|
3
|
|
|
|
|
4
|
my $description = 'directory layout'; |
37
|
3
|
|
|
|
|
8
|
my $directories_ok = _directories_ok($dir); |
38
|
|
|
|
|
|
|
|
39
|
3
|
|
|
|
|
28
|
$Tester->ok( $directories_ok, $description ); |
40
|
3
|
100
|
|
|
|
1148
|
unless ($directories_ok) { |
41
|
1
|
|
|
|
|
2
|
unshift @diags, "Found the following problems:"; |
42
|
1
|
|
|
|
|
9
|
$Tester->diag( join( "\n ", @diags ) ); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
3
|
|
|
|
|
134
|
return $directories_ok; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub _directories_ok { |
49
|
3
|
|
|
3
|
|
4
|
my ($dir) = @_; |
50
|
|
|
|
|
|
|
|
51
|
3
|
|
|
|
|
7
|
my $ok = 1; |
52
|
3
|
|
|
|
|
5
|
my $allowed_dirs = get_allowed_dirs; |
53
|
|
|
|
|
|
|
|
54
|
3
|
50
|
|
|
|
92
|
opendir( my $dh, $dir ) || die "Can't opendir $dir: $!"; |
55
|
3
|
100
|
|
|
|
73
|
my @dirs = grep { !/^\./ && -d "$dir/$_" } readdir($dh); |
|
20
|
|
|
|
|
206
|
|
56
|
3
|
|
|
|
|
31
|
closedir $dh; |
57
|
3
|
|
|
|
|
10
|
for my $dir (@dirs) { |
58
|
14
|
|
|
|
|
147
|
my $allowed = grep ( /^$dir$/, @$allowed_dirs ); |
59
|
14
|
100
|
|
|
|
35
|
unless ($allowed) { |
60
|
1
|
|
|
|
|
9
|
$ok = 0; |
61
|
1
|
|
|
|
|
5
|
push @diags, qq{Directory '$dir' is not allowed}; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
3
|
|
|
|
|
12
|
return $ok; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
__END__ |