here is a small 

doc i wrote up for 
doing the mod perl test

i dunno if its useful but 
i thought i should pass it around

i wanted to re write out the docs as i did an
example

i think this worked out good

anyways lemme know if there is anything glaringly wrong

stas: if you want to includeany of this in the main docs go ahead!
how to for 
modperl test harness

resources:
http://httpd.apache.org/test/

Anonymous CVS access (via pserver) is available. "anoncvs" is the password. 

 % cvs -d :pserver:[EMAIL PROTECTED]:/home/cvspublic login
 % cvs -d :pserver:[EMAIL PROTECTED]:/home/cvspublic co httpd-test

 % cvs -d :pserver:[EMAIL PROTECTED]:/home/cvspublic co modperl-docs

[if you try the flood package lemme know how you fair 
i had no luck]

you will only need to use the perl-framework stuffs
and in there you will find 
you will have to at the very least install Apache-Test

i mention the modperl-docs because there is a pertinent doc in there:
./src/devel/writing_tests/writing_tests.pod

[this is a work in prog and as i find typos and probs
i have been following up to stas and the [EMAIL PROTECTED]
maillist to improve the overall quality]

there is mention that upgrading to 5.6.1 would be beneficial

here is my computer stats relative to this
madrake 7.2
apache 1.3.12
perl 5.6.0 
and modperl 1.25

ok now lets get started making our tests!
-==-=-
h2xs -AXn Apache::Foo

Writing Apache/Foo/Foo.pm
Writing Apache/Foo/Makefile.PL
Writing Apache/Foo/test.pl
Writing Apache/Foo/Changes
Writing Apache/Foo/MANIFEST

-----
next is to modify the perl module

what you need to add to Foo.pm is

use Apache::Constants qw(:common);

sub handler {

my $r=shift;
$r->send_http_header('text/plain');
$r->print('Foo!');
return Apache::OK;
}

----
the Makefile.PL has to also be 
modified a little here and there

youll need to add

#this actually doesnt seem to work more on that later...
use lib qw (../blib/lib ./);

use Apache::TestMM qw(test clean);


my %require=
(
"Apache::Test"=>"0.01",
);

#accept the configs from command line
Apache::TestMM::filter_args();
Apache::TestMM::generate_script('t/TEST');


sub clean_files {
return [EMAIL PROTECTED];
}

and then youll have to modify the 
WriteMakefile call
adjust/add these:


  'PREREQ_PM'           => \%require, # e.g., Module::Name => 1.1
    'clean'             => {
                            FILES => "@{clean_files()}",
                           },
    'dist'              => {
                            PREOP => 'pod2text Foo.pm >README', #make sure to 
touch README!
                           }

=-=-=-=-
make these dirs
t/
t/conf 


t/TEST.PL needs to be made like this:
#!/usr/bin/perl

use strict;
use warning FATAL => 'all';

#i think this borkes out too more later...again
use lib qw(lib);

use Apache::TestRunPerl ();

Apache::TestRunPerl->new->run(@ARGV);
-==--==-
now you must make extra.conf.in in 
./t/conf/
ive had to modified 
the example stas had

PerlModule Apache::Foo
<Location /test/foo>
SetHandler perl-script
PerlHandler Apache::Foo
</Location>

-==-

alright now we can make a test!

use strict;

#use warnings FATAL=>'all';

use Apache::Foo;
use Apache::Test;
use Apache::TestUtil;
plan tests =>2;

ok 1;

my $config=Apache::Test::config();
my $url='/test/funky';
my $data=$config->http_raw_get($url);

ok t_cmp(
"Foo!",
$data,
"basic test",
);

-==-=-=-=-
now we can run this!
perl Makefile.PL apxs /usr/local/apache/bin/apxs  
make
make install 
make test or 
./t/TEST 
{refer to perl-framework/README and perl-framework/Apache-Test/README
for more info on using ./t/TEST}



the reason for installing before 
is because the lib handling
is not working correctly 

Reply via email to