On Fri Apr 11 16:30:50 2008, markhamnr wrote:
Show quoted text> Devel::Cover seems to have problems with POD coverage. In the trivial
> example I attach, perl -MDevel::Cover foo.pl indicates 'n/a' under pod
> for Foo.pm, but perl -MPod::Coverage=Foo prints "Foo has a Pod::Coverage
> rating of 1".
>
> Noticed this with Devel::Cover 0.59, Perl 5.8.8.
> `uname`=Linux nmarkham 2.6.20-16-generic #2 SMP Tue Feb 12 02:11:24 UTC
> 2008 x86_64 GNU/Linux
My hunch is that this is not a problem with Devel::Cover per se, but is instead a side effect of the interaction between the modules that Devel::Cover relies upon for POD coverage (such as Test::Pod::Coverage) and the fact that the package in which your POD appears is *not* the first package that appears in the file Foo.pm.
Customarily, the 'package' declaration is the first statement in a file. In the absence of a 'package' declaration as the first statement, the first package seen in the file is 'package main'.
In the file you supplied, Foo.pm, the first statement is 'use strict'. That means your file starts in 'package main'. If, however, you remove the 'use strict' line, then the first package found within Foo.pm is 'package Foo'. And when I then run Devel::Cover on that, I get the POD coverage of Foo.pm you are interested in.
##########
$ cat Foo.pm
package Foo;
=item foo()
=cut
sub foo { }
1;
$ perl -MDevel::Cover foo.pl "$@"
Devel::Cover 1.00: Collecting coverage data for branch, condition, pod, statement, subroutine and time.
Selecting packages matching:
Ignoring packages matching:
/Devel/Cover[./]
Ignoring packages in:
/usr/local/lib/perl5/site_perl/5.16.0/darwin-2level
/usr/local/lib/perl5/site_perl/5.16.0
/usr/local/lib/perl5/5.16.0/darwin-2level
/usr/local/lib/perl5/5.16.0
/usr/local/lib/perl5/site_perl/5.14.2
/usr/local/lib/perl5/site_perl/5.14.0
/usr/local/lib/perl5/site_perl/5.12.0
/usr/local/lib/perl5/site_perl/5.10.1
/usr/local/lib/perl5/site_perl/5.10.0
/usr/local/lib/perl5/site_perl
Devel::Cover: Writing coverage database to /Users/jimk/Documents/AAAPerl/Devel-Cover/34888/cover_db/runs/1365774603.670.61098
---------------------------- ------ ------ ------ ------ ------ ------ ------
File stmt bran cond sub pod time total
---------------------------- ------ ------ ------ ------ ------ ------ ------
Foo.pm 100.0 n/a n/a 100.0 100.0 n/a 100.0
foo.pl 100.0 n/a n/a 100.0 n/a 100.0 100.0
Total 100.0 n/a n/a 100.0 100.0 100.0 100.0
---------------------------- ------ ------ ------ ------ ------ ------ ------
$ cover -report=text
Reading database from /Users/jimk/Documents/AAAPerl/Devel-Cover/34888/cover_db
---------------------------- ------ ------ ------ ------ ------ ------ ------
File stmt bran cond sub pod time total
---------------------------- ------ ------ ------ ------ ------ ------ ------
Foo.pm 100.0 n/a n/a 100.0 100.0 n/a 100.0
foo.pl 100.0 n/a n/a 100.0 n/a 100.0 100.0
Total 100.0 n/a n/a 100.0 100.0 100.0 100.0
---------------------------- ------ ------ ------ ------ ------ ------ ------
Run: foo.pl
Perl version: 5.16.0
OS: darwin
Start: Fri Apr 12 13:50:02 2013
Finish: Fri Apr 12 13:50:02 2013
Foo.pm
line err stmt bran cond sub pod time code
1 package Foo;
2
3 =item foo()
4
5 =cut
6
7 1 1 1 sub foo { }
8
9 1;
Covered Subroutines
-------------------
Subroutine Count Pod Location
---------- ----- --- --------
foo 1 1 Foo.pm:7
foo.pl
line err stmt bran cond sub pod time code
1 1 1 74111 use Foo;
1 14
1 130064
2
3 1 271999 Foo::foo;
Covered Subroutines
-------------------
Subroutine Count Location
---------- ----- --------
BEGIN 1 foo.pl:1
###########
While I cannot rule out the possibility of a Devel::Cover bug here, I can demonstrate that if you code your file in a more standard manner, you get the POD coverage you want.
I recommend this ticket be closed.
Thank you very much.
Jim Keenan