line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::DirectoryLayout; |
2
|
|
|
|
|
|
|
$Test::DirectoryLayout::VERSION = '0.002'; # TRIAL |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
#ABSTRACT: Test directory layout for standard compliance |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
70822
|
use strict; |
|
1
|
|
|
|
|
10
|
|
|
1
|
|
|
|
|
28
|
|
7
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
5
|
use base qw(Test::Builder::Module); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
557
|
|
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
|
9047
|
return \@allowed_dirs; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub set_allowed_dirs { |
24
|
2
|
|
|
2
|
1
|
667
|
my ($dirs) = @_; |
25
|
2
|
|
|
|
|
9
|
@allowed_dirs = @$dirs; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub directory_layout_ok { |
30
|
3
|
|
|
3
|
1
|
22320
|
my ($dir) = @_; |
31
|
3
|
50
|
|
|
|
11
|
$dir = '.' unless $dir; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# clean up diagnostics from prior tests |
34
|
3
|
|
|
|
|
7
|
undef @diags; |
35
|
|
|
|
|
|
|
|
36
|
3
|
|
|
|
|
5
|
my $description = 'directory layout'; |
37
|
3
|
|
|
|
|
8
|
my $directories_ok = _directories_ok($dir); |
38
|
|
|
|
|
|
|
|
39
|
3
|
|
|
|
|
31
|
$Tester->ok( $directories_ok, $description ); |
40
|
3
|
100
|
|
|
|
1352
|
unless ($directories_ok) { |
41
|
1
|
|
|
|
|
4
|
unshift @diags, "Found the following problems:"; |
42
|
1
|
|
|
|
|
10
|
$Tester->diag( join( "\n ", @diags ) ); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
3
|
|
|
|
|
167
|
return $directories_ok; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub _directories_ok { |
49
|
3
|
|
|
3
|
|
7
|
my ($dir) = @_; |
50
|
|
|
|
|
|
|
|
51
|
3
|
|
|
|
|
5
|
my $ok = 1; |
52
|
3
|
|
|
|
|
7
|
my $allowed_dirs = get_allowed_dirs; |
53
|
|
|
|
|
|
|
|
54
|
3
|
50
|
|
|
|
103
|
opendir( my $dh, $dir ) || die "Can't opendir $dir: $!"; |
55
|
3
|
100
|
|
|
|
81
|
my @dirs = grep { !/^\./ && -d "$dir/$_" } readdir($dh); |
|
20
|
|
|
|
|
225
|
|
56
|
3
|
|
|
|
|
38
|
closedir $dh; |
57
|
3
|
|
|
|
|
9
|
for my $dir (@dirs) { |
58
|
14
|
|
|
|
|
170
|
my $allowed = grep ( /^$dir$/, @$allowed_dirs ); |
59
|
14
|
100
|
|
|
|
42
|
unless ($allowed) { |
60
|
1
|
|
|
|
|
10
|
$ok = 0; |
61
|
1
|
|
|
|
|
5
|
push @diags, qq{Directory '$dir' is not allowed}; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
3
|
|
|
|
|
14
|
return $ok; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
__END__ |