|P is for Practical|
Re: What is your development process for Perl modules and apps?by jwest (Friar)
|on Aug 09, 2002 at 21:42 UTC||Need Help??|
I typically edit in a development area. Almost without exception, this is a working copy of the project from CVS.
To answer the second question, I always use h2xs to generate the framework for my modules. So, in the general case, I can put all of my test code in test.pl (or t/whatever.pl, depending on how I'm feeling that day) and running 'make test' takes care of any library path issues for me.
The caveat to this is when the library in question requires the presence of another module in the project currently under development to be tested adequately. In this case, I've been known to take several approaches.
First, I might temporarily adjust the Makefile to have it include the apropriate paths in my library path. I like this solution because it's clean - running 'perl Makefile.PL' undoes whatever damage I did to the Makefile. I dislike this solution for the same reason. I rarely use this method for any project on which I'll be spending more than four hours.
Second, I might set up a better test.pl to convince the module I'm testing that it's got all the bits it needs. chromatic has written an excellent module for this purpose, called Test::MockObject. I like this approach because it feels like the right thing to do - it gives me the satisfaction of a job well done. I dislike this approach because doing the right thing often requires more effort than I really want to expend.
The third method I use for getting around this problem is writing the installation script for the package that I know I'll have to write anyway. Since I only modify the script from project to project, it's no longer as big of a hassle. So, I'll check out the project into another working directory, install it, and run it there for testing. I like this method because all the effort is eventually recycled into making sure my installation procedure is working. On the downside, it requires a lot of extra work - especially for incremental fixes. Checking that your module is at least compilable with perl -c is critical when you use this approach. I almost never use this approach unless I'm fixing a piece of code that's already been released. I never use this approach if I've been good and gone with the second option.
-><- -><- -><- -><- -><- All things are Perfect To every last Flaw And bound in accord With Eris's Law - HBT; The Book of Advice, 1:7