Chapter 4
Listing 4 9. MANIFEST Generated by h2xs.
Changes
Makefile.PL
MANIFEST
Counter.pm
README
test.pl
Exploring the Distribution
Like most things Perl, there's more than one way to build a module distribution.
The module skeleton generated by h2xs is designed to be simple and generic
enough to be useful for all sorts of modules. It's a great place to start, but there are
some modifications that will be helpful for you to know. I'll also explore some of
the useful things that the build system can do for you without any modifications
at all.
Testing
The test script generated by h2xs is simply a Perl script that uses the Test module to
run tests. Adding a new test is very simple just add a few lines to the script that
call ok() and update the plan number accordingly. This works well for simple
modules, but a complicated module that uses this system will end up with a very
large test script. Also, some modules contain features that are difficult to test in a
single script.
Fortunately, ExtUtils::MakeMaker allows you to have as many separate test
scripts as you need. To use this functionality, create a directory in your module dis
tribution called t. Then create your test files, ending with the extension .t, inside
this directory. For example, a typical t directory might contain the files 01load.t,
02basic.t, and 03errors.t. The resulting directory structure is shown in Figure 4 2.
Using this layout, make test looks a little different.
$ make test
PERL_DL_NONLAZY=1 /usr/local/bin/perl Iblib/arch Iblib/lib \
I/usr/local/lib/perl5/5.6.1/i686 linux I/usr/local/lib/perl5/5.6.1 \
e use Test::Harness qw(&runtests $verbose); $verbose=0; runtests @ARGV; t/*.t
t/01load......ok
t/02basic.....ok
t/03errors....ok
All tests successful.
Files=3, Tests=6, 0 wallclock secs ( 0.20 cusr + 0.04 csys = 0.24 CPU)
112
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Inexpensive Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Jsp Hosting
Cheap Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved