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: 17215
Status: open
Priority: 0/
Queue: Devel-Cover

People
Owner: Nobody in particular
Requestors: CRAKRJACK [...] cpan.org
Cc: jkeenan [...] cpan.org
AdminCc:

Bug Information
Severity: Critical
Broken in: 0.55
Fixed in: (no value)



Subject: Devel::Cover considers code that failed to compile "covered"
If you attempt to use / require a package and it's compilation fails, Devel::Cover sees everything up to the failing statement as run, and does not consider that there was code that failed to compile in it's assessment. This makes a file that has a syntax error in it appear as if it has successfully attained 100% code coverage. Because all of the other statements weren't compiled, I understand you can not count them, and therefore you can not get a percentage of total statements actually run. Could we instead say that 0% of the statements were covered because the package never compiled successfully?
From: JKEENAN [...] cpan.org
On Sun Jan 22 20:03:58 2006, CRAKRJACK wrote: Show quoted text
> If you attempt to use / require a package and it's compilation fails, > Devel::Cover sees everything up to the failing statement as run, and > does not consider that there was code that failed to compile in it's > assessment. This makes a file that has a syntax error in it appear as if > it has successfully attained 100% code coverage. >
I cannot reproduce your results. See the 3 files attached. As failure.pl ends in a statement which evaluates false, require-ing it will always fail. If I place all 3 files in the same directory, then call: PERL5OPT=-MDevel::Cover prove -v simpletest.pl "$@" ... I get the following result: simpletest....Devel::Cover: Can't open -e for MD5 digest: No such file or directory failure.pl did not return a true value at simpletest.pl line 16. # Looks like your test died just after 1. ok 1 - Got expected number of array elements 1..1 dubious Test returned status 255 (wstat 65280, 0xff00) after all the subtests completed successfully Failed Test Stat Wstat Total Fail List of Failed ------------------------------------------------------------------------------ - simpletest.pl 255 65280 1 0 ?? Failed 1/1 test scripts. 0/1 subtests failed. Files=1, Tests=1, 5 wallclock secs ( 4.01 cusr + 0.41 csys = 4.42 CPU) Failed 1/1 test programs. 0/1 subtests failed. So where am I supposed to see the 100% coverage? Can you provide an example? (Otherwise, I think ticket can be closed.) Jim Keenan
#!/usr/local/bin/perl use strict; use Carp; our (@EXPORT_OK); @EXPORT_OK = qw( count_array_elements count_hash_elements ); sub count_array_elements { my $ref = shift; croak "Must supply array ref" unless ref($ref) eq 'ARRAY'; return scalar(@$ref); } sub count_hash_elements { my $ref = shift; croak "Must supply hash ref" unless ref($ref) eq 'HASH'; return scalar(keys %$ref); }
#!/usr/local/bin/perl use strict; use warnings; use Test::More qw(no_plan); use lib ("."); use Simple qw( count_array_elements count_hash_elements ); our $somevar; my $arrayref = [ 0 .. 10 ]; my $hashref = { alpha => 'beta', gamma => 'delta' }; is(11, count_array_elements($arrayref), "Got expected number of array elements"); my $file = q{failure.pl}; require $file; is(2, count_hash_elements($hashref), "Got expected number of hash elements");
$somevar = q[foobar]; 0;
CC: CRAKRJACK [...] cpan.org
Subject: Re: [rt.cpan.org #17215] Devel::Cover considers code that failed to compile "covered"
Date: Mon, 1 Oct 2007 10:46:08 -0700
To: via RT <bug-Devel-Cover [...] rt.cpan.org>
From: Tyler MacDonald <tyler [...] yi.org>
Hi, Add the following line to Simple.pm, at line 7: gfoo0gsjlfsdlfkjsdflksdjskl!; Here's the output of prove: $ PERL5OPT=-MDevel::Cover prove -v simpletest.pl "$@" simpletest....Devel::Cover: Can't open -e for MD5 digest: No such file or directory syntax error at Simple.pm line 7, near "gfoo0gsjlfsdlfkjsdflksdjskl!" Compilation failed in require at simpletest.pl line 6. BEGIN failed--compilation aborted at simpletest.pl line 6. # Looks like your test died before it could output anything. dubious Test returned status 255 (wstat 65280, 0xff00) FAILED--1 test script could be run, alas--no output ever seen Run "cover". "cover_db/Simple-pm.html" shows 100% code coverage, both in "coverage.html" on the summary, and in the actual file. Cheers, Tyler
On Mon Oct 01 13:47:03 2007, tyler@yi.org wrote: Show quoted text
> Hi, > > Add the following line to Simple.pm, at line 7: > > gfoo0gsjlfsdlfkjsdflksdjskl!; > > Here's the output of prove: > > $ PERL5OPT=-MDevel::Cover prove -v simpletest.pl "$@" > simpletest....Devel::Cover: Can't open -e for MD5 digest: No such file or > directory > syntax error at Simple.pm line 7, near "gfoo0gsjlfsdlfkjsdflksdjskl!" > Compilation failed in require at simpletest.pl line 6. > BEGIN failed--compilation aborted at simpletest.pl line 6. > # Looks like your test died before it could output anything. > dubious > Test returned status 255 (wstat 65280, 0xff00) > FAILED--1 test script could be run, alas--no output ever seen > > Run "cover". "cover_db/Simple-pm.html" shows 100% code coverage, both in > "coverage.html" on the summary, and in the actual file. > > Cheers, > Tyler >
Confirmed. And more to the point, cover_db/Simple-pm.html shows 100% statement coverage in its summary, though it's also clear that none of the code is exercised.