Subject: | Crash when computing pod coverage on a module that does pod parsing |
If a program uses Pod::Parser::parse_from_file() internally with an
IO::String instance as the receiver, then when Devel::Cover uses that
same function later as part of Pod::Coverage computations, it will crash
with an IO::String error.
Attached are files composing a minimal test case (derived from an actual
crash case in Perl::Critic::Violation):
Foo.pm is a simple module that invokes Pod::Parser
test.pl is a short tester for that module
Running via:
perl test.pl
yields a success
Running via:
perl -MDevel::Cover test.pl
yields the following error:
ok 1 - use Foo;
ok 2
Can't locate object method "OPEN" via package "IO::String" at
/Users/chris/perl/System/Library/Perl/5.8.6/Pod/Parser.pm line 1239.
at /Users/chris/perl/System/Library/Perl/5.8.6/Pod/Parser.pm line 1239
Pod::Parser::parse_from_file('Pod::Coverage::Extractor=HASH(0x1a0dbe0)',
'./Foo.pm', '/dev/null') called at
/Users/chris/perl/lib/darwin-thread-multi-2level/Pod/Coverage.pm line 324
Pod::Coverage::_get_pods('Pod::Coverage::CountParents=HASH(0x1a14c70)')
called at
/Users/chris/perl/lib/darwin-thread-multi-2level/Pod/Coverage/CountParents.pm
line 19
Pod::Coverage::CountParents::_get_pods('Pod::Coverage::CountParents=HASH(0x1a14c70)')
called at
/Users/chris/perl/lib/darwin-thread-multi-2level/Pod/Coverage.pm line 123
Pod::Coverage::coverage('Pod::Coverage::CountParents=HASH(0x1a14c70)')
called at
/Users/chris/perl/lib/darwin-thread-multi-2level/Pod/Coverage.pm line 197
Pod::Coverage::covered('Pod::Coverage::CountParents=HASH(0x1a14c70)')
called at
/Users/chris/perl/lib/perl5/site_perl/5.8.6/darwin-thread-multi-2level/Devel/Cover.pm
line 1095
Devel::Cover::get_cover('B::CV=SCALAR(0x1a005a8)') called at
/Users/chris/perl/lib/perl5/site_perl/5.8.6/darwin-thread-multi-2level/Devel/Cover.pm
line 615
Devel::Cover::report() called at
/Users/chris/perl/lib/perl5/site_perl/5.8.6/darwin-thread-multi-2level/Devel/Cover.pm
line 223
Devel::Cover::last_end() called at test.pl line 0
eval {...} called at test.pl line 0
END failed--call queue aborted.
at test.pl line 0
Subject: | Foo.pm |
package Foo;
use Pod::PlainText;
use IO::String;
sub pod_extract
{
my $pkg = shift;
my $file = shift;
my $pod_string = $EMPTY;
my $handle = IO::String->new( \$pod_string );
my $parser = Pod::PlainText->new();
$parser->select('DESCRIPTION');
$parser->parse_from_file( $file, $handle );
return $pod_string;
}
1;
__END__
=head1 NAME
Foo
=head1 DESCRIPTION
blah blah
=head1 AUTHOR
Me!
Subject: | test.pl |
use Carp;
$SIG{__DIE__} = \&Carp::confess;
use Test::More tests => 2;
use lib qw(.);
use_ok('Foo');
is(Foo->pod_extract('Foo.pm'), <<'EOF');
DESCRIPTION
blah blah
EOF