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

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

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



Subject: Devel::Cover sets $DB::single to 0
Hello, Devel::Cover defines $DB::single and sets it to 0. Example: running: perl -e 'print "\$DB::single is: " . $DB::single' outputs: $DB::single is: ($DB::single is undefined) while running with Devel::Cover: perl -MDevel::Cover -e 'print "\$DB::single is: " . $DB::single' prints (among the other Devel::Cover related output): $DB::single is: 0 I was unable to find anywhere in the code where this was explicitly set. It's possible it was done by a module that Devel::Cover uses.
On Thu Oct 04 16:42:23 2012, BUBAFLUB wrote: Show quoted text
> Hello, > > Devel::Cover defines $DB::single and sets it to 0. Example: > > running: > > perl -e 'print "\$DB::single is: " . $DB::single' > > outputs: > > $DB::single is: > > ($DB::single is undefined) > > while running with Devel::Cover: > > perl -MDevel::Cover -e 'print "\$DB::single is: " . $DB::single' > > prints (among the other Devel::Cover related output): > > $DB::single is: 0 > > I was unable to find anywhere in the code where this was explicitly > set. It's possible it was > done by a module that Devel::Cover uses.
My hunch is that this is a problem which manifests itself only when Devel::Cover is used with a command-line program that does not exercise a file. First, I run a program at the command-line very similar to yours: ########## $ perl -w -MDevel::Cover -E 'say "\$DB::single is: <$DB::single>"' Devel::Cover: Can't find file "-e" (-e): ignored. 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 $DB::single is: <0> Devel::Cover: Writing coverage database to /Users/jimk/Documents/AAAPerl/Devel-Cover/80340/cover_db/runs/1365767158.479.13352 ---------------------------- ------ ------ ------ ------ ------ ------ ------ File stmt bran cond sub pod time total ---------------------------- ------ ------ ------ ------ ------ ------ ------ Total n/a n/a n/a n/a n/a n/a n/a ---------------------------- ------ ------ ------ ------ ------ ------ ------ ########## Note that Devel::Cover appears to be expecting to find a file, cannot do so, and throws out a warning. That's not entirely surprising, because there are no statements to be exercised. Later in the output, $DB::single is set to 0, as you reported. Now, I take a program found in another bug ticket in this rt.cpan.org queue and modify it by sticking in this one line just before the file exits: ########## $ cat 80340_simple.pl #!/usr/bin/perl use strict; use Test::More 'no_plan'; my @x = ('a'..'c'); my $foo; my $n = 0; foreach (@x) { $foo .= $_; } continue { $n++; } is $foo, 'abc'; is $n, 3; print STDERR '$DB::Single: ', $DB::Single, "\n"; __END__ ########## When I run this *without* Devel::Cover, it reports $DB::Single as undefined: ########## $ perl -w 80340_simple.pl Name "DB::Single" used only once: possible typo at 80340_simple.pl line 19. ok 1 ok 2 $DB::Single: Use of uninitialized value $DB::Single in print at 80340_simple.pl line 19. 1..2 ########## Next, I run the same program *with* Devel::Cover: ########## $ perl -w -MDevel::Cover 80340_simple.pl Name "DB::Single" used only once: possible typo at 80340_simple.pl line 19. 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 ok 1 ok 2 $DB::Single: Use of uninitialized value $DB::Single in print at 80340_simple.pl line 19. 1..2 Devel::Cover: Writing coverage database to /Users/jimk/Documents/AAAPerl/Devel-Cover/80340/cover_db/runs/1365767843.492.61503 ---------------------------- ------ ------ ------ ------ ------ ------ ------ File stmt bran cond sub pod time total ---------------------------- ------ ------ ------ ------ ------ ------ ------ 80340_simple.pl 100.0 n/a n/a 100.0 n/a 100.0 100.0 Total 100.0 n/a n/a 100.0 n/a 100.0 100.0 ---------------------------- ------ ------ ------ ------ ------ ------ ------ ########## It *still* reports $DB::Single as undefined. So when you use Devel::Cover as it presumably expects to be used (i.e., with a file), then it does not set $DB::single. When you use Devel::Cover in a way that it does not expect to be used, it sets $DB::single to 0. I don't think there's any bug here sufficient to warrant changes in Devel::Cover. I recommend that this ticket be closed. Thank you very much. Jim Keenan
On Fri Apr 12 08:00:38 2013, JKEENAN wrote: Show quoted text
> > My hunch is that this is a problem which manifests itself only when > Devel::Cover is used with a command-line program that does not > exercise a file. >
We saw this happen on production code. The snippet I gave was (what I thought) was the most simplified test case. Let me try and figure out a minimal test case for this that works on both the command-line and in a script.