On Sat, Oct 02, 2004 at 11:20:05AM -0700, Kevin Scaldeferri wrote:

> On Sep 21, 2004, at 1:30 PM, Kevin Scaldeferri wrote:
> >
> >So, I don't expect anyone to try to figure out this stack trace stuff, 
> >but I'm curious if other people have seen stability problems like 
> >this?  Alternatively, if someone can tell me the exact logistics of 
> >how they get the coverage out in the end, I'd appreciate it.  Is there 
> >another way than 'kill'ing the apache process to get Devel::Cover to 
> >write its data?  It seems to do it at one point during startup, but 
> >after that it looks like it just stays in memory, which I end up 
> >losing when things go bad terminating the process.
> >
> 
> Sorry, to resurrect this, but I was hoping to hear from some other 
> people who are using Devel::Cover in mod_perl about just how they run 
> the tests, and get the results out.  Are people doing something other 
> than killing the server in order to get Devel::Cover to dump the data 
> out of memory to the disk?

You could try calling Devel::Cover::report() when you want to get to the
coverage data, but I've never tested that.  If it worked you would, at
the minimum, need to set the coverage criteria again in order to get any
further coverage.  It's probably better to stop and start the server.

>                             Could anyone give a cookbook type procedure 
> that they use to do this sort of data collection?

I work within the Apache::Test framework and add a bit of gumph for the
coverage stuff.  I'm very impressed with Apache::Test - it lets me do
what I want very easily.  For more information on Apache::Test see
http://perl.apache.org/docs/general/testing/testing.html

I add the following to t/conf/extra.conf.in:

    <IfDefine COVER>
        <Perl>
            use Devel::Cover qw(-select \.conf$);
        </Perl>
    </IfDefine>

And my Makefile.PL is as follows.  I'll include the whole thing so you
can see how everything fits together, though you won't necessarily need
it all.  And hopefully that means I won't break it trying to cut it
down.  Geoff may well be able recommend something better, but this setup
allows me to run:

  make test           # run all tests in a new server
  make restart        # restart server
  make stop           # stop server
  make cover          # collect and report coverage data on all tests
                        run in a new server and restart server to
                        collect more coverage
  make restart_cover  # stop server, collect and report on coverage, and
                        restart server to collect more coverage
  make clean          # as expected

And I even get coverage on the Perl parts of the conf files, which was a
pleasant surprise ;-)

[ Just before sending this I notice Geoff has recommended something
better, but I'll send this too as another WTDI. ]


#!/usr/bin/perl

# Copyright 2004, Paul Johnson ([EMAIL PROTECTED])

require 5.6.1;

use strict;
use warnings;

use ExtUtils::MakeMaker;
use ExtUtils::Manifest "maniread";

use Apache::TestMM qw(test clean);
Apache::TestMM::filter_args();
Apache::TestMM::generate_script('t/TEST');

$| = 1;

my $Version  = "0.03";
my $Date     = "29th September 2004";
my $Author   = '[EMAIL PROTECTED]';

my @perlbug  = ("perlbug", "-a", $Author,
                           "-s", "Installation of Retemps $Version");
my $Perlbug  = join " ", map { / / ? "'$_'" : $_ } @perlbug;

my @files    = sort keys %{maniread()};
my @versions = grep { $_ ne "README" && $_ ne "Makefile.PL" } @files;

mkdir "t/logs" or die "Can't mkdir t/logs: $!" unless -d "t/logs";

$ExtUtils::MakeMaker::Verbose = 0;

WriteMakefile
(
    NAME      => "Retemps",
    VERSION   => $Version,
    AUTHOR    => 'Paul Johnson ([EMAIL PROTECTED])',
    DIR       => [],
    EXE_FILES => [],
    PREREQ_PM => {
                     "Apache::Test" => 0,
                     "Template"     => 0,
                 },
    dist      => { COMPRESS => "gzip --best --force" },
    clean     => { FILES => join " ", "t/TEST", "cover_db",
                                      map "$_.version", @versions },
    realclean => {},
    depend    => { distdir => "@files" },
);

sub MY::libscan
{
    my ($self, $path) = @_;
    (my $p = $path) =~ s/^\$\(INST_LIB\)/lib/;  # 5.6.1
    $p =~ s|\\|/|g if $^O eq "MSWin32";
    # print "$path $p\n";
    my $wanted = -d $p;                         # 5.9.0
    for my $f (@files)
    {
        # print "$p - $f\n";
        last if $wanted ||= $p =~ /$f$/;
    }
    $wanted && $path;
}

sub MY::postamble
{
    qq[
SET_VERSION = \$(PERL) -pi.version \\
    -e 's/(^\\s*(?:our\\s+)\\\$\$VERSION = ")\\d+\\.\\d+(";)/\$\${1}$Version\$\$2/;' \\
    -e 's/(Version )\\d+\\.\\d+( - ).*/\$\${1}$Version\$\${2}$Date/;' \\
    -e 's/(Retemps Version )\\d+\\.\\d+/\$\${1}$Version/;' \\
    -e 's/(\\buse Retemps(?:::\\w+)*\\s+)\\d+\\.\\d+/\$\${1}$Version/;'

tags : @files
\t ptags @files

@versions : Makefile.PL
\t \$(SET_VERSION) @versions

README : lib/Retemps.pm
\t TERMCAP= COLUMNS=80 pod2text lib/Retemps.pm | \\
    \$(PERL) -n \\
    -e 'print if (/NAME/         ... /^[A-Z ]+\$\$/) =~ /^\\d+\$\$/;' \\
    -e 'print if (/SYNOPSIS/     ... /^[A-Z ]+\$\$/) =~ /^\\d+\$\$/;' \\
    -e 'print if (/DESCRIPTION/  ... /^[A-Z ]+\$\$/) =~ /^\\d+\$\$/;' \\
    -e 'print if (/REQUIREMENTS/ ... /^[A-Z ]+\$\$/) =~ /^\\d+\$\$/;' \\
    > README

restart : all
\t t/TEST -stop && t/TEST -start

restart_cover : all
\t t/TEST -stop && cover && t/TEST -defines COVER -start

stop : all
\t t/TEST -stop

cover : all
\t cover -delete && \\
   HARNESS_PERL_SWITCHES=-MDevel::Cover t/TEST -defines COVER && \\
   cover && \\
   t/TEST -defines COVER -start

ok :
\t [EMAIL PROTECTED] -okay  || echo "Please send your report manually to $Author"

nok :
\t [EMAIL PROTECTED] -nokay || echo "Please send your report manually to $Author"
    ]
}

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

Reply via email to