Skip to content

Commit 4e3843a

Browse files
committed
explicitly fail if the compile failed
Fix and tests by Gareth Tunley
1 parent d34c3c9 commit 4e3843a

File tree

4 files changed

+25
-3
lines changed

4 files changed

+25
-3
lines changed

lib/Pod/Coverage.pm

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,11 @@ sub coverage {
151151

152152
my %symbols = map { $_ => 0 } $self->_get_syms($package);
153153

154+
if (!%symbols && $self->{why_unrated}) {
155+
# _get_syms failed violently
156+
return;
157+
}
158+
154159
print "tying shoelaces\n" if TRACE_ALL;
155160
for my $pod (@$pods) {
156161
$symbols{$pod} = 1 if exists $symbols{$pod};
@@ -301,8 +306,11 @@ sub _get_syms {
301306

302307
print "requiring '$package'\n" if TRACE_ALL;
303308
eval qq{ require $package };
304-
print "require failed with $@\n" if TRACE_ALL and $@;
305-
return if $@;
309+
if ($@) {
310+
print "require failed with $@\n" if TRACE_ALL;
311+
$self->{why_unrated} = "requiring '$package' failed";
312+
return;
313+
}
306314

307315
print "walking symbols\n" if TRACE_ALL;
308316
my $syms = Devel::Symdump->new($package);

t/02simple.t

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/perl -w
22
use strict;
3-
use Test::More tests => 33;
3+
use Test::More tests => 36;
44
use lib 't/lib';
55

66
BEGIN {
@@ -70,6 +70,12 @@ isa_ok( $obj, 'Pod::Coverage' );
7070
is( $obj->coverage, undef, "can't deduce for Simple8" );
7171
is( $obj->why_unrated, 'no public symbols defined', 'why is correct' );
7272

73+
$obj = Pod::Coverage->new(package => 'Simple9');
74+
isa_ok($obj, 'Pod::Coverage');
75+
76+
is($obj->coverage, undef, 'Simple9 has no coverage');
77+
is($obj->why_unrated, "requiring 'Simple9' failed", 'why is correct');
78+
7379
$obj = Pod::Coverage->new( package => 'Earle' );
7480
is( $obj->coverage, 1, "earle is covered" );
7581
is( scalar $obj->covered, 2 );

t/lib/Simple8.pm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
package Simple8;
2+
1;
23

34
=item docs
45

t/lib/Simple9.pm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package Simple9;
2+
3+
use Foo::Invalid;
4+
5+
=item docs
6+
7+
=cut

0 commit comments

Comments
 (0)