Distributing Modules with Apache-Test

     

The previous lab, "Testing with Apache-Test," created a simple Apache module that you tested with Apache-Test. Suppose that the module is so handy, useful, and original that you want to share it with the world. How do you set up your tests in a module distribution?

This lab demonstrates how to set up a module distribution for use with Module::Build and the Apache-Test testing framework.

How do I do that?

Keep all of the files you created from the previous lab except for t/TEST ; Apache-Test will create it for you automatically. Save the following as Build.PL in the directory that contains both t/ and lib/ :

 #!perl          use Module::Build;          my $build_pkg =         eval { require Apache::TestMB } ? 'Apache::TestMB' : 'Module::Build';          my $build = $build_pkg->new(         module_name  => 'Thumbnail',         dist_version => 0.01,         license      => 'perl',         requires     => {             'Apache::Test' => 1.12,             'Imager'       => 0.40,         },     );          $build->create_build_script(  ); 

Then build and test like any other Module::Build -based distribution:

 $  perl Build.PL  Creating new 'Build' script for 'Thumbnail' version '0.01'     $  perl Build test  lib/Thumbnail.pm -> blib/lib/Thumbnail.pm     /usr/bin/perl -I /home/anu/thumbnail/blib/lib -I         /home/anu/thumbnail/blib/arch t/TEST -clean     [warning] setting ulimit to allow core files     ulimit -c unlimited; /usr/bin/perl /home/anu/thumbnail/t/TEST -clean     /usr/bin/perl -I /home/anu/thumbnail/blib/lib -I /home/anu/thumbnail/blib/arch         t/TEST -bugreport -verbose=0     [warning] setting ulimit to allow core files     ulimit -c unlimited; /usr/bin/perl /home/anu/thumbnail/t/TEST -bugreport         -verbose=0     /usr/sbin/apache-perl  -d /home/anu/thumbnail/t -f         /home/anu/thumbnail/t/conf/httpd.conf -D APACHE1 -D PERL_USEITHREADS     using Apache/1.3.33          waiting 60 seconds for server to start: .     waiting 60 seconds for server to start: ok (waited 0 secs)     server localhost:8529 started     t/thumbnail.............ok     All tests successful.     Files=1, Tests=1,  4 wallclock secs ( 0.67 cusr +  0.08 csys =  0.75 CPU)     [warning] server localhost:8529 shutdown 


Note: Did "Build test" fail? Check to see that Apache-Test has the correct path to the Apache executable.If it's not correct, set the APACHE_TEST_HTTPD environment variable to what you used in the previous lab .

Add documentation (if you haven't already) and some tweaking to Build.PL , and your distribution is ready to go!

What just happened ?

Apache::TestMB adds Apache-Test features to Module::Build , which, among other things, automatically create a TEST file for you. Running perl Build test prepares the distribution and runs the test suite using TEST .

Users who don't have Apache-Test installed when they run perl Build.PL will see a large warning about the missing prerequisite. However, they can still build and install the distribution.

What about...

Q:

What if I'm using ExtUtils::MakeMaker to distribute my modules?

A:

There's a little more syntax you'll need to have Apache-Test generate the t/TEST file automatically. The following Makefile.PL is similar to the Build.PL shown in the lab:

 #!perl          use ExtUtils::MakeMaker;     use Apache::TestMM qw(test clean);     use Apache::TestRun;          Apache::TestMM::filter_args(  );          Apache::TestRun->generate_script(  ); 



Perl Testing. A Developer's Notebook
Perl Testing: A Developers Notebook
ISBN: 0596100922
EAN: 2147483647
Year: 2003
Pages: 107

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net