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