Skip to content

Commit fb24a66

Browse files
committed
exclude modules defined under a test directory from the index
1 parent 52e17f7 commit fb24a66

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

lib/MetaCPAN/Document/File.pm

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,15 @@ does not include any modules, the L</indexed> property is true.
670670

671671
sub set_indexed {
672672
my ( $self, $meta ) = @_;
673+
674+
if ( $self->in_test_directory() ) {
675+
foreach my $mod ( @{ $self->module } ) {
676+
$mod->indexed(0);
677+
}
678+
$self->indexed(0);
679+
return;
680+
}
681+
673682
foreach my $mod ( @{ $self->module } ) {
674683
$mod->indexed(
675684
$meta->should_index_package( $mod->name )

t/document/file.t

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,18 @@ END
142142
is( $file->level, 2 );
143143
}
144144

145+
{
146+
my $file = MetaCPAN::Document::File->new(
147+
%stub,
148+
path => 'foo/t/locker',
149+
module => { name => 'BAR::Locker' }
150+
);
151+
152+
$file->set_indexed( CPAN::Meta->new( { name => 'null', version => 0 } ) );
153+
is( $file->module->[0]->indexed,
154+
0, 'Module in test directory is not indexed' );
155+
}
156+
145157
{
146158
my $content = <<'END';
147159
package

0 commit comments

Comments
 (0)