forked from Perl-Toolchain-Gang/CPAN-Meta
/
no-index.t
89 lines (74 loc) · 1.76 KB
/
no-index.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
use strict;
use warnings;
use Test::More 0.88;
use CPAN::Meta;
delete $ENV{$_} for qw/PERL_JSON_BACKEND PERL_YAML_BACKEND/; # use defaults
my %distmeta = (
name => 'Module-Billed',
abstract => 'inscrutable',
version => '1',
author => [ 'Joe' ],
release_status => 'stable',
license => [ 'perl_5' ],
'meta-spec' => {
version => '2',
url => 'http://search.cpan.org/perldoc?CPAN::Meta::Spec',
},
dynamic_config => 1,
generated_by => 'Module::Build version 0.36',
);
{
my $meta = CPAN::Meta->new({ %distmeta });
ok(
$meta->should_index_package('Foo::Bar::Baz'),
'we index any old package, without a no_index rule'
);
ok(
$meta->should_index_file('lib/Foo/Bar/Baz.pm'),
'we index any old file, without a no_index rule'
);
}
{
my $meta = CPAN::Meta->new({
%distmeta,
no_index => {
package => [ 'Foo::Bar' ],
namespace => [ 'Foo::Bar::Baz' ],
}
});
ok(
! $meta->should_index_package('Foo::Bar'),
'exclude a specific package'
);
ok(
$meta->should_index_package('Foo::Bar::Baz'),
'namespace X does not exclude package X'
);
ok(
! $meta->should_index_package('Foo::Bar::Baz::Quux'),
'exclude something under a namespace'
);
}
{
my $meta = CPAN::Meta->new({
%distmeta,
no_index => {
file => [ 'lib/Foo/Bar.pm' ],
directory => [ 'lib/Foo/Bar/Baz' ],
}
});
ok(
! $meta->should_index_file('lib/Foo/Bar.pm'),
'exclude a specific file'
);
ok(
$meta->should_index_file('lib/Foo/Bar/Baz.pm'),
'do not exclude a file with a name like an excluded dir',
);
ok(
! $meta->should_index_file('lib/Foo/Bar/Baz/Quux.pm'),
'exclude something under a directory'
);
}
done_testing;
# vim: ts=2 sts=2 sw=2 et :