Some quick cheat notes on Perl packaging.
Set up a PM
$ h2xs -AXn Package::Module
- -A omits Autoloader code
- -X omits eXternal Subroutine (e.g. C library) elements
- -n specifies module name
To prepare archive for shipping:
$ perl Makefile.PL; make; make dist;
Writing tests
- Remember to update
use Test::More tests => 2; to number of expected tests
- Start with a
use_ok('Package::Module') test for the module
- Then actually call
use Package::Module(qw(fcn1 fcn2)); (functions required if no autoloaded fcns exist).
- Standard test format:
ok(CONDITION, DESCRIPTION) e.g. ok(do_print('hello') =~ /hello/, 'Valid output returned');
- Execute tests with
cd Package-Module && make test for basic summary or cd Package-Module/lib && perl ../t/Package-Module.t for more descriptive execution of individual test file
Use "carp" instead of "warn"
- Gives the offending line of an error in user's file context
|