Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion lib/Test/Pod/Coverage.pm
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ use 5.006;
use strict;
use warnings;

use File::Spec;
use Pod::Coverage;
use Test::Builder;

Expand Down Expand Up @@ -209,6 +210,10 @@ sub all_modules {
my @starters = @_ ? @_ : _starting_points();
my %starters = map {$_,1} @starters;

# Starters paths and their depths
my %starters_parts =
map { $_, scalar(File::Spec->splitdir($_)) } grep { -d $_ } @starters;

my @queue = @starters;

my @modules;
Expand All @@ -229,7 +234,13 @@ sub all_modules {
next unless $file =~ /\.pm$/;

my @parts = File::Spec->splitdir( $file );
shift @parts if @parts && exists $starters{$parts[0]};

# Deal with paths.. e.g blib/, lib/ or /foo/bar
my ($known_path) = grep { $file =~ m/^$_/ } keys %starters;
for (1..$starters_parts{$known_path}) {
shift @parts;
}

shift @parts if @parts && $parts[0] eq "lib";
$parts[-1] =~ s/\.pm$// if @parts;

Expand Down
19 changes: 19 additions & 0 deletions t/all_modules_absolute.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!perl -T

use strict;

use File::Spec;
use Test::More tests => 2;

BEGIN {
use_ok( "Test::Pod::Coverage" );
}

my @files = Test::Pod::Coverage::all_modules( File::Spec->rel2abs("blib") );

# The expected files have slashes, not File::Spec separators, because
# that's how File::Find does it.
my @expected = qw( Test::Pod::Coverage );
@files = sort @files;
@expected = sort @expected;
is_deeply( \@files, \@expected, "Got all the distro files" );