develooper Front page | perl.qa | Postings from April 2012

Re: Devel::Cover problem: getting analysis of .xs file but not of.pmfile

Thread Previous
From:
James E Keenan
Date:
April 26, 2012 17:54
Subject:
Re: Devel::Cover problem: getting analysis of .xs file but not of.pmfile
Message ID:
4F99EE3F.8050609@verizon.net
On 4/25/12 9:08 PM, James E Keenan wrote:
> Friends,
>
>
> Can anyone advise as to why I am getting coverage analysis of Util.xs
> but not of lib/Hash/Util.pm?
>

Locking %ENV frustrates Devel::Cover.

Starting at approximately line 172 of t/Util.t, we have a test which, 
after I've reformatted a few lines, looks like this:

lock_keys(%ENV);
eval { () = $ENV{I_DONT_EXIST} };
like(
     $@,
     qr/^Attempt to access disallowed key 'I_DONT_EXIST' in a restricted 
hash/,
     'locked %ENV'
);

I commented out all the tests in Util.t, then worked my way through 
un-commenting them and making sure that all tests still passed.  Until I 
got to the test above, I got favorable results calling:

   prove -vb t/Util.t
   cover -delete; harness; cover -summary

... where 'harness' simply calls:

   HARNESS_PERL_SWITCHES=-MDevel::Cover make test

... and "favorable results" means something like this:

---------------------- ------ ------ ------ ------ ------ ------ ------
File                     stmt   bran   cond    sub    pod   time  total
---------------------- ------ ------ ------ ------ ------ ------ ------
Util.xs                  88.2   58.3    n/a    n/a    n/a    n/a   70.7
blib/lib/Hash/Util.pm    82.9   59.1   11.1   87.5   92.0  100.0   78.8
Total                    83.6   58.7   11.1   87.5   92.0  100.0   77.4
---------------------- ------ ------ ------ ------ ------ ------ ------

But when I extended the uncommented lines to include the 'like' after 
lock_keys(%ENV), 'prove' still PASSed all tests but the line for 
'blib/lib/Hash/Util.pm' vanished.

When I kept the lock_keys lines commented out, but uncommented the 
balance of the file, both prove and cover DWIMmed.

Hence, these few lines were the cause of the problem.  So now this 
becomes an obscure bug in Devel::Cover:  Why does lock_keys(%ENV) cause 
reporting on a package to vanish -- but not affect the reporting on the 
XS file?

I'll leave that for others (read: pjcj) to ponder.  In the meantime, I 
hope to add tests to shore up the surprisingly poor coverage of 
Hash::Util by its test file.

Thank you very much.
Jim Keenan

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About