Matthew Pressly wrote:

> If module A depends on module B (uses methods or subroutines from module 
> B), is there a good way to test that module A loads module B (i.e. has a 
> "use" statement)?  I frequently run into the following scenario:
> 
> 1. Write one or more new modules plus a handler that uses them.
> 2. One or more of those modules is dependent on other existing modules.
> 3. One of those modules is missing a "use" statement for one of the 
> existing modules that it makes method/sub calls to.
> 4. The handler works in the development environment because some other 
> handler loaded that module previously in response to a previous http 
> request. (The brunt of the handler code is "require"-ed on demand 
> currently).
> 5. Promote code from development server to production server.
> 6. Restart apache on production server.
> 7. Handler fails on production server in response to an access that 
> exercises the section of code where the missing "use" was needed 
> (i.e.subroutine or method call to module that wasn't loaded).


there are a few things I could suggest (others may have more ideas)

   - use Apache::Test to write a test suite for your modules. 
Apache::Test is very easy to use and very convenient.  I don't do any 
more module development without it.

   - always preload your modules with via PerlModule/startup.pl.  if 
you're missing a use() somewhere the module probably won't load and 
the server won't start.  it's a good idea anyway, for performance reasons.

   - $ perl -cw MyLib.pm

HTH

--Geoff


Reply via email to