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

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

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



Subject: Reading constant code references invalidates statement coverage
Reading a constant coderef seems to invalidate the statement coverage figures. It looks like one statement is skipped from the top of the module for each read ("$x = Wut::A") added to the test. If A is just a plain scalar, the problem goes away, as well as the "Devel::Cover: ignoring extra statement" warnings. Test distribution attached. I can reproduce it with 5.8.8 and 5.10.0. $ cat lib/Wut.pm package Wut; use constant A => sub { 0 }; 1; $ cat t/zlork.t #!perl -T use Wut; my $x = Wut::A; $x = Wut::A; $x = Wut::A; $x = Wut::A; $ cover -test Deleting database /home/vince/perl/bugs/coverconstants/cover_db cover: running make test OPTIMIZE=-O0\ -fprofile-arcs\ -ftest-coverage OTHERLDFLAGS=-fprofile-arcs\ -ftest-coverage cp lib/Wut.pm blib/lib/Wut.pm PERL_DL_NONLAZY=1 /usr/bin/perl5.8.8 "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t t/zlork.... No subtests run Test Summary Report ------------------- t/zlork (Wstat: 0 Tests: 0 Failed: 0) Parse errors: No plan found in TAP output Files=1, Tests=0, 4 wallclock secs ( 0.05 usr 0.00 sys + 3.67 cusr 0.05 csys = 3.77 CPU) Result: FAIL Failed 1/1 test programs. 0/0 subtests failed. make: *** [test_dynamic] Error 255 Reading database from /home/vince/perl/bugs/coverconstants/cover_db Devel::Cover: ignoring extra statement Devel::Cover: ignoring extra statement ---------------------------- ------ ------ ------ ------ ------ ------ ------ File stmt bran cond sub pod time total ---------------------------- ------ ------ ------ ------ ------ ------ ------ blib/lib/Wut.pm 0.0 n/a n/a 100.0 n/a 100.0 20.0 Total 0.0 n/a n/a 100.0 n/a 100.0 20.0 ---------------------------- ------ ------ ------ ------ ------ ------ ------ Writing HTML output to /home/vince/perl/bugs/coverconstants/cover_db/coverage.html ... done.
Subject: coverconstants.tar.bz2
Download coverconstants.tar.bz2
application/octet-stream 6.3k

Message body not shown because it is not plain text.

On Tue Oct 28 09:43:06 2008, VPIT wrote: Show quoted text
> Reading a constant coderef seems to invalidate the statement coverage > figures. It looks like one statement is skipped from the top of the > module for each read ("$x = Wut::A") added to the test. If A is just a > plain scalar, the problem goes away, as well as the "Devel::Cover: > ignoring extra statement" warnings. > > Test distribution attached. I can reproduce it with 5.8.8 and 5.10.0. > > $ cat lib/Wut.pm > package Wut; > > use constant A => sub { 0 }; > > 1; > > $ cat t/zlork.t > #!perl -T > > use Wut; > > my $x = Wut::A; > $x = Wut::A; > $x = Wut::A; > $x = Wut::A; > > $ cover -test > Deleting database /home/vince/perl/bugs/coverconstants/cover_db > cover: running make test OPTIMIZE=-O0\ -fprofile-arcs\ -ftest-coverage > OTHERLDFLAGS=-fprofile-arcs\ -ftest-coverage > cp lib/Wut.pm blib/lib/Wut.pm > PERL_DL_NONLAZY=1 /usr/bin/perl5.8.8 "-MExtUtils::Command::MM" "-e" > "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t > t/zlork.... No subtests run > > Test Summary Report > ------------------- > t/zlork (Wstat: 0 Tests: 0 Failed: 0) > Parse errors: No plan found in TAP output > Files=1, Tests=0, 4 wallclock secs ( 0.05 usr 0.00 sys + 3.67 cusr > 0.05 csys = 3.77 CPU) > Result: FAIL > Failed 1/1 test programs. 0/0 subtests failed. > make: *** [test_dynamic] Error 255 > Reading database from /home/vince/perl/bugs/coverconstants/cover_db > Devel::Cover: ignoring extra statement > Devel::Cover: ignoring extra statement > > > ---------------------------- ------ ------ ------ ------ ------ ------ > ------ > File stmt bran cond sub pod time > total > ---------------------------- ------ ------ ------ ------ ------ ------ > ------ > blib/lib/Wut.pm 0.0 n/a n/a 100.0 n/a 100.0 > 20.0 > Total 0.0 n/a n/a 100.0 n/a 100.0 > 20.0 > ---------------------------- ------ ------ ------ ------ ------ ------ > ------ > > > Writing HTML output to > /home/vince/perl/bugs/coverconstants/cover_db/coverage.html ... > done.
I find I get better (though probably not perfect) results when I actually invoke the constant: $ cover -delete Deleting database /Users/jimk/Documents/AAAPerl/Devel-Cover/40454/cover_db $ cat lib/Wut.pm package Wut; use constant A => sub { 0 }; 1; $ cat t/call_the_constant.t use Wut; my $x = Wut::A; &$x; $ perl -MDevel::Cover -Ilib t/call_the_constant.t 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/40454/cover_db/runs/1364776645.18936.38812 Devel::Cover: ignoring extra statement Devel::Cover: ignoring extra statement ---------------------------- ------ ------ ------ ------ ------ ------ ------ File stmt bran cond sub pod time total ---------------------------- ------ ------ ------ ------ ------ ------ ------ lib/Wut.pm 75.0 n/a n/a 100.0 n/a 0.0 80.0 t/call_the_constant.t 100.0 n/a n/a 100.0 n/a 100.0 100.0 Total 87.5 n/a n/a 100.0 n/a 100.0 90.0 ---------------------------- ------ ------ ------ ------ ------ ------ ------ $ cover -report=text > 40454_amended_coverage.txt Devel::Cover: ignoring extra statement Devel::Cover: ignoring extra statement
Subject: 40454_amended_coverage.txt
Reading database from /Users/jimk/Documents/AAAPerl/Devel-Cover/40454/cover_db ---------------------------- ------ ------ ------ ------ ------ ------ ------ File stmt bran cond sub pod time total ---------------------------- ------ ------ ------ ------ ------ ------ ------ lib/Wut.pm 75.0 n/a n/a 100.0 n/a 0.0 80.0 t/call_the_constant.t 100.0 n/a n/a 100.0 n/a 100.0 100.0 Total 87.5 n/a n/a 100.0 n/a 100.0 90.0 ---------------------------- ------ ------ ------ ------ ------ ------ ------ Run: t/call_the_constant.t Perl version: 5.16.0 OS: darwin Start: Mon Apr 1 00:37:25 2013 Finish: Mon Apr 1 00:37:25 2013 lib/Wut.pm line err stmt bran cond sub pod time code 1 package Wut; 2 1 1 0 use constant A => sub { 0 }; *** 0 0 1 28 1 4 3 1; Covered Subroutines ------------------- Subroutine Count Location ---------- ----- ------------ BEGIN 1 lib/Wut.pm:2 t/call_the_constant.t line err stmt bran cond sub pod time code 1 1 1 8 use Wut; 1 150946 2 1 265114 my $x = Wut::A; 3 2 31596 &$x; Covered Subroutines ------------------- Subroutine Count Location ---------- ----- ----------------------- BEGIN 1 t/call_the_constant.t:1