Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Devel-Cover CPAN distribution.

Report information
The Basics
Id: 34888
Status: resolved
Priority: 0/
Queue: Devel-Cover

People
Owner: Nobody in particular
Requestors: markhamnr [...] bigfoot.com
Cc: jkeenan [...] cpan.org
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.59
Fixed in: (no value)



Subject: POD coverage doesn't work for trivial case
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
Subject: foo.pl
use Foo; Foo::foo;
Subject: Foo.pm
use strict; package Foo; =item foo() =cut sub foo { } 1;
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
On 2013-04-12 14:52:54, JKEENAN wrote: Show quoted text
> My hunch is that this is not a problem with Devel::Cover per se
... Show quoted text
> I recommend this ticket be closed.
Jim, I recognise your helpfulness in providing a workaround but I disagree that this ticket should be closed: it clearly demonstrates a shortcoming of Devel::Cover that Pod::Coverage does not exhibit. As you state, Perl modules usually contain the "package" declaration in their first line. However, it's possible to mistype the word "package". Writing "use strict" as the first line makes errors like this easier to spot. I have seen intelligent, experienced colleagues in two separate workplaces do this and have adopted the approach myself. Sadly Devel::Cover does not currently support it. Try writing a module in the style suggested by the reporter. Write a stub Makefile.PL then run "perl Makefile.PL && make manifest". Next run "pod_cover", ensuring you have Pod::Coverage installed first. You will see that Pod::Coverage copes with this approach to writing modules and accuratly reports methods as documented or not. However, if you run that module through a test suite with Devel::Cover, Devel::Cover will report the POD coverage as "n/a". I appreciate your enthusiasm for cleaning up Devel::Cover's bug queue, but please don't recommend closing bug reports without proper investigation. Tom
This has now been fixed with 3cd5d98acddc97ee4e288f4ba184e336b111a1c4 It turns out that it was actually a bug in Devel::Cover. Thanks very much to Mark for the original report and to Jim and Tom for pushing things on. The fix will be in the next release.