On Fri, Feb 02, 2007 at 01:32:37PM -0600, Mike Malony wrote:

> I'm into testing, got some nice .t files, and prove tells me things I'd
> rather not hear.  So, my next step on the straight and narrow path of
> testing, is to gauge my testing coverage.
> 
> IN the doc, the synopsis suggests
>   "perl -MDevel::Cover yourprog args
>   cover"
> 
> But what can you use in 'yourprog'?
> 
>   .t and .pl files run, do the tests and have some extra messages implying
> that cover was running, but there are no stats printed.
> 
>  prove also runs my tests, and produces stats, but only for the installed
> modules.
> 
> Clearly I'm missing something.  As a self taught perler on a windows system,
> who knows what craziness I'm doing.  Any guidance appreciated (mild cheerful
> abuse expected)

I think you might just need to read a couple of lines further in the docs.

>From the sound of things, you have created a module in the standard format,
and so you want the next section, "To test an uninstalled module:"

  cover -delete
  HARNESS_PERL_SWITCHES=-MDevel::Cover make test
  cover

or perhaps you might prefer the newer, underdocumented alternative:

  cover -test

which does about the same thing, but also includes a little light magic to
try running gcov on your XS files, if you have both gcov and XS files.

But perhaps a part of the problem here is that you don't have "make"
available?  In that case, you should be able replace "make test" with your
"prove" command in the standard incantation.  So, something like:

  cover -delete
  HARNESS_PERL_SWITCHES=-MDevel::Cover prove [ prove options ... ]
  cover

I'm pretty sure that "prove" honours HARNESS_PERL_SWITCHES, but I'm even
more sure that someone will say so if it doesn't ;-)

As to your original question, "yourprog" is just any random perl program you
want to get coverage for.  If you're dealing with modules it's not really
applicable.  Perhaps I should try rearranging the docs somewhat.

> System info:
> Windows 2000 Server
> ActivePerl 5.6.? ( know it's not recommended ) if it really doesn't work,
> well part of the goal is to check coverage before I go through the upgrade)

I think things should still basically work on 5.6.[12], though some
constructs which should be shown as covered might not be.  This is primarily
due to bugs of deficiencies in perl itself which have been addressed ni
later releases.  I do test each release with 5.6.[12], though not on
windows.

> 30 *.t files
> 2,000+ tests
>    prove runs nicely
> 
> And thanks to advice here in these archives I was able to get a .ppm for
> Devel::Cover.

> -- Output from testing --
> 
> C:\blah>perl -MDevel::Cover commafy.t
> 1..8
> ok 1 - use archive_purge;
> Devel::Cover 0.59: Collecting coverage data for branch, condition, pod,
> statement, subroutine and time.
> Selecting packages matching:
> Ignoring packages matching:
>    /Devel/Cover[./]
> Ignoring packages in:
>    .
>    C:/Perl56/lib  (not actually where my perl code lives, so @INC is off?)

Correct.  This is also the reason why you are getting coverage for core
modules.  You might want to try playing with the -inc option to specify
where your core libraries are.  So we might be up to something like:

  cover -delete
  HARNESS_PERL_SWITCHES=-MDevel::Cover=-inc,C:/Perl/lib prove [ prove options 
... ]
  cover

How did you end up with the core modules somewhere other than where they
were expected to be?

>    C:/Perl56/site/lib
> 
> # COMMAFY Testing...
> 
> [snip ... messages showing my tests running]
> 
> Devel::Cover: Can't find file "blib\lib\Storable.pm": ignored.  (storable is
> installed, but not in blib ... in fact, there is no blib ... ???

Presumably because you have never run "make"?

This warning has been silenced in the latest release, 0.61, and can be
safely ignored in earlier releases.

> C:\blah>perl -MDevel::Cover commafy.t
> --- output from prove ---
> 
> Devel::Cover 0.59: Collecting coverage data for branch, condition,
> statement, subroutine and time.
>    Pod coverage is unvailable.  Please install Pod::Coverage from CPAN.
> Selecting packages matching:
> Ignoring packages matching:
>    /Devel/Cover[./]
> Ignoring packages in:
>    .
>    C:/Perl56/lib
>    C:/Perl56/site/lib
> .\Archive_Purge.....ok
> [snip list .t files running, some of which fail]
>                                                        1-23
> .\trailerlog_report.t                23   23 100.00%  1-23

This is something that mighti be fixed by upgrading your perl and/or
Devel::Cover installation.

But then again, it might not be.

> Devel::Cover: Writing coverage database to
> C:/blah/cover_db/runs/1170356783.2480.43668
> ----------------------------------- ------ ------ ------ ------ ------
> ------
> File                                  stmt   bran   cond    sub   time
> total
> ----------------------------------- ------ ------ ------ ------ ------
> ------
> /perl/bin/prove                       55.3   46.2   25.0   11.1  100.0
> 47.9
> C:/Perl/lib/AutoLoader.pm             52.4   31.6    n/a   66.7  100.0
> 45.2
> C:/Perl/lib/B.pm                       7.1   18.8   23.8    1.8  100.0
> 6.7
> 
> [snip list of installed modules]
> 
> Total                                  9.7    7.7    5.1    4.0  100.0
> 8.1
> ----------------------------------- ------ ------ ------ ------ ------
> ------

Fixing up a few of these things should bring those figures up a little too :)

Good luck.

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

Reply via email to