problem with a test exemple on the Phalanx web site

2003-10-04 Thread Dominic Letarte
on the page : http://qa.perl.org/phalanx/kwalitee.html

ok( unlink $filename, "Remove $filename" );

should be written:
ok( unlink( $filename), "Remove $filename" );  
unless you want Perl to take "Remove $filename" as an arg for unlink and 
not for ok.

Dominic






Re: Devel::Cover can't find loaded modules

2003-10-04 Thread Paul Johnson
On Fri, Oct 03, 2003 at 10:44:24AM -0700, Ovid wrote:

> Hi all,
> 
> I was running some test code with Devel::Cover and I've had no problem
> using it or generating pretty reports that make coworkers "ooh" and
> "ahh".  Unfortunately, I started running my test suite on a different
> set of tests and started getting some strange errors (formatted for
> clarity):
> 
>   Devel::Cover: Can't find file "blib/lib/Text/CSV.pm": ignored.
>   Can't locate object method "find_cv" via package "B::SPECIAL" 
> (perhaps you forgot to load "B::SPECIAL"?) at 
> /usr/local/stow/ASperl-5.6.1-629/lib/5.6.1/i686-linux/B.pm line 213.
> 
> To narrow down the problem, I tried running this on a smaller set of
> tests, only to get the above output, but with the following line
> prepended:
> 
>   Devel::Cover: Can't find file "blib/lib/Storable.pm": ignored.
> 
> I'm not sure how running fewer tests is generating more errors, but in
> digging through Devel::Cover, I can't even find a reference to
> Text::CSV

The message here is trying to say that Devel::Cover is wanting to
provide coverage information about Text::CSV and Storable, but is unable
to locate these modules.  That it is looking in blib/lib would suggest
when you ran the test perl picked up those modules from a blib
directory.  That seems a little strange to me, but I'm sure you have
your reasons.

It is likely that when this message is given you are in a different
directory and since the path is relative the module cannot be found.

Do you actually want coverage on these modules?  Normally you would not,
unless you were running their own test suites.  If you do not want the
coverage information you can simply ignore the warning, or better, use
-ignore +-inc and -select to narrow down the list of modules for which
you want coverage information.  This has the bonus of speeding up
runtime by not collecting data you don't want.

>nor has digging through B.pm shed any light (though I may
> require therapy now).

The find_cv error is a real bug.  It will be caused either my me using
the core B modules incorrectly (not handling the op tree correctly), or
by me using B::Deparse in a way it was not expecting.

> Googling has also been fruitless for me.
> 
> Has anyone seen any errors like this before and can you give me some
> guidance on what I can do to alleviate them?  I'm trying to create a
> small test case, but this has been pesky to narrow down.  In the
> meantime, I'm going to try to add signal handlers to dump stack traces
> and maybe even symlink a 'blib/lib' to the appropriate libraries (what
> a nasty hack!).

Right.  I don't think the blib problem is related to the find_cv one, so
either ignore it or deal with it as I mentioned above.  If you are able
to narrow the bug down at all I'd be very grateful for a test case.  And
a patch if you fancy.  Otherwise I'm slowly working through CPAN modules
using cpancover and trying to fix bugs like this as I go.  CPAN is my
test suite ;-)

If you just want to get some results from the thing, you could try
determining which of the coverage criteria is causing the problem,
though it may well be common to all the criteria.  You could also try
putting an eval around the deparse calls at the end of get_cover() in
Devel::Cover.pm, though this will likely reduce the reported coverage
where the error has occurred.

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net


Re: Devel::Cover can't find loaded modules

2003-10-04 Thread Paul Johnson
On Sat, Oct 04, 2003 at 07:23:09AM +1000, Andrew Savige wrote:

> Ovid wrote:
> > I was running some test code with Devel::Cover and I've had no problem using
> > it or generating pretty reports that make coworkers "ooh" and "ahh".
> > Unfortunately, I started running my test suite on a different set of
> > tests and started getting some strange errors...
> 
> I have no experience with Devel::Cover yet, but remember this post:
>   http://nntp.x.perl.org/group/perl.qa/2213
> which states that Devel::Cover cannot be run from the 't' directory

I don't think there is anything special about the t directory that
upsets Devel::Cover.  The problem is related to relative paths and
changing directories within the tests/test suite.

As a partial solution to the problem you can try giving an absolute path
to the database when Devel::Cover is run, eg

  perl -MDevel::Cover=-db,$PWD/cover_db ...

This particular problem seems to have hit the top of the most wanted
list so I'll see what I can do with it for the next release.

Who are these people who change directories and don't put things back
as they found them? ;-)

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net


Devel::Cover - what do the numbers mean ?

2003-10-04 Thread Gabor Szabo

I have just used Devel::Cover successfully for the first time.
I even got the HTML pages.

Great!

But what are those numbers and colors in the columns ?
I could not find in the documentation. Please point me to the
description if it is available somewhere.

thanks
  Gabor



Re: Devel::Cover can't find loaded modules

2003-10-04 Thread schwern
On Sat, Oct 04, 2003 at 09:38:11PM +0200, Paul Johnson wrote:
> Who are these people who change directories and don't put things back
> as they found them? ;-)

File::chdir


Re: Devel::Cover - what do the numbers mean ?

2003-10-04 Thread schwern
On Sat, Oct 04, 2003 at 11:00:33PM +0200, Gabor Szabo wrote:
> But what are those numbers and colors in the columns ?
> I could not find in the documentation. Please point me to the
> description if it is available somewhere.

Percentage of the code covered, I think.


Re: Devel::Cover - what do the numbers mean ?

2003-10-04 Thread Gabor Szabo
On Sat, 4 Oct 2003 [EMAIL PROTECTED] wrote:

> On Sat, Oct 04, 2003 at 11:00:33PM +0200, Gabor Szabo wrote:
> > But what are those numbers and colors in the columns ?
> > I could not find in the documentation. Please point me to the
> > description if it is available somewhere.
>
> Percentage of the code covered, I think.

That's what I thought and recalled from the presentation of Paul
and I understand the red 50 in branch and the red 33 in cond but
I don't understand the green 33 or the green 1 in stmt.
And the best is the green 108 stmt.

Sure I need some hand holding on this.

Gabor





Re: Devel::Cover - what do the numbers mean ?

2003-10-04 Thread Paul Johnson
On Sat, Oct 04, 2003 at 11:25:27PM +0200, Gabor Szabo wrote:
> On Sat, 4 Oct 2003 [EMAIL PROTECTED] wrote:
> 
> > On Sat, Oct 04, 2003 at 11:00:33PM +0200, Gabor Szabo wrote:
> > > But what are those numbers and colors in the columns ?
> > > I could not find in the documentation. Please point me to the
> > > description if it is available somewhere.
> >
> > Percentage of the code covered, I think.

Right, in general.

> That's what I thought and recalled from the presentation of Paul
> and I understand the red 50 in branch and the red 33 in cond but
> I don't understand the green 33 or the green 1 in stmt.
> And the best is the green 108 stmt.

Since a statement is either 0% covered or 100% covered I don't waste
space by reporting the coverage as a percentage.  Instead the statement
column tells you the number of times the statement was exectued.  Thus,
anything over 0 is OK, and coloured green.

The colours are just eye candy, they map to the numbers.  The idea being
that the red stuff is what you want to look at first.

I suspect that you are right, and this is probably not documented
anywhere.

> Sure I need some hand holding on this.

Sounds like you're basically there to me.

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net


Re: problem with a test exemple on the Phalanx web site

2003-10-04 Thread Andy Lester
At 1:01 PM -0400 10/4/03, Dominic Letarte wrote:
on the page : http://qa.perl.org/phalanx/kwalitee.html

ok( unlink $filename, "Remove $filename" );

should be written:
ok( unlink( $filename), "Remove $filename" );  unless you want Perl 
to take "Remove $filename" as an arg for unlink and not for ok.
Thanks.  I rewrote it as

is( unlink($filename), 1, "Remove $filename" );

Better to test for exactness than truth.

xoa



--
Andy Lester => [EMAIL PROTECTED] => www.petdance.com => AIM:petdance


Re: Devel::Cover - what do the numbers mean ?

2003-10-04 Thread Gabor Szabo
On Sat, 4 Oct 2003, Paul Johnson wrote:

> The colours are just eye candy, they map to the numbers.  The idea being
> that the red stuff is what you want to look at first.
>
> I suspect that you are right, and this is probably not documented
> anywhere.


Thanks for the answer !



Another question:

I am running coverage analyzis on the test suit of CGI::Application
with the intention of phalanxing it if Jesse (the author) agrees.

This module is used by sub-classing it. Devel::Cover collects information
and reports about each one of the sub-classes that are there to test only.
I wonder if it possible to to tell Devel::Cover not to waste time on the
coverage of these modules as they are not interesting ?


OK that was my original question but now I am not sure.
Maybe it is actually important to make sure each test sub-class is also
covered well within its tests ? Or maybe that's just the means of achieving
better testing of the real module ?

Gabor