Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Writing tests for a module

by Ovid (Cardinal)
on Jun 05, 2001 at 22:14 UTC ( #85922=perlquestion: print w/replies, xml ) Need Help??
Ovid has asked for the wisdom of the Perl Monks concerning the following question:

Working on a proper distribution package for a module and was thinking about the tests that need to be written. I've pretty much stuck to standard modules for the module, but I've repeatedly seen new Monks say things like "We don't have [insert ubiquitous module name here] installed on our server. Is it overkill to write tests to see if they are there?

Cheers,
Ovid

Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

Replies are listed 'Best First'.
Re: Writing tests for a module
by bikeNomad (Priest) on Jun 05, 2001 at 22:21 UTC
    I don't bother checking in my modules, but it's reasonable to check in your Makefile.PL so they know when installing it (or CPAN.pm knows) that they need something else. I even check for standard modules. If you use ExtUtils::MakeMaker, just add a PREREQ_PM hash arg to the arguments to WriteMakefile. From Archive-Zip's Makefile.PL:

    WriteMakefile( #snip PREREQ_PM => { 'Compress::Zlib' => 1.06, 'Carp' => 0, 'File::Path' => 0, 'File::Find' => 0, 'File::Basename' => 0, }, #snip );

    If you have PREREQ_PM set, CPAN.pm will use it to load prerequisites. Also, the .PPD file (used by PPM) will have the dependency information, which will allow PPM to load the required modules.

    update: added explanation at end

Re: Writing tests for a module
by Daddio (Chaplain) on Jun 06, 2001 at 01:42 UTC

    There are a couple of good scripts on the List of installed modules node, specifically one I tried from cianoz. Don't know if that helps or not, but that one does work.

    D a d d i o

Re: Writing tests for a module
by John M. Dlugosz (Monsignor) on Jun 05, 2001 at 23:16 UTC
    No less reasonable than handling tech support manually. For people unfamiliar with Perl (customers want to run the program, not learn the language), a simple checker works wonders. For a set of perl scripts used by developers for certain testing, I included a check_setup script as well that makes sure it can find everything and explains about paths etc.
Re: Writing tests for a module
by traveler (Parson) on Jun 06, 2001 at 01:08 UTC
    It would sure be nice if you'd set it up so that CPAN.pm's shell would install all needed modules when installing your new module. I've not investigated how to do that (no need, yet), but it is very handy when downloading new modules!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://85922]
Approved by root
help
Chatterbox?
[erix]: they've stuck nuclear missiles in Kaliningrad - they can just reach Berlin :)
[LanX]: naaah! Putin wouldn't nuke all the Russians in Berlin
[Your Mother]: Putin is a bad guy but heís not that kind of bad guy. (Who would launch.)
[erix]: fortunately, Putin seems to be ill -- or at least, they're building a hospital for him and his cronies in Moscow
[erix]: nobody knows what kind it takes :)
[erix]: I say his seems a face that launches a thousand missiles :)
[Your Mother]: I say I do. :P
[Your Mother]: Missiles would be an idiotís play. Putin is many things but he is not an idiot.
[erix]: I like the idea of the trumps troup of imbeciles growing slightly nervous now their incompetence will be tested
[erix]: you seem forget there is another idiot coming :)

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (8)
As of 2017-01-20 00:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (173 votes). Check out past polls.