perl-test-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <>
Subject [rfc] a function to adjust @INC for live modules
Date Wed, 14 Sep 2005 23:42:56 GMT
When you develop several independent modules which are using each other, 
it's usually a pain to always run 'make install' in all of them to get the 
latest changes in, while working on the current module. I usually try to 
add the lib subdirs to @INC so that I can test against liv, un-installed 
dirs. Things get more complicated when you have .xs modules, since now you 
have to include blib as well, but lib must come before blib. Moreover you 
need to deal with -T, so I've come up with the following sub:

sub adjust_INC {
     require lib;
     require blib;

     # untaint dir names
     my @dirs = map { (/(.*)/) } @_;

     # test against the source lib first for easier dev
     do { blib->import($_) }
         for grep { -d $_ } map { "$_/blib" } @dirs;

     do { lib->import($_) }
         for grep { -d $_ } map { "$_/lib"  } @dirs;

Now let's say you have a layout of:


you can now include them all in @INC as following (e.g. from t/TEST.PL or 

use Apache::Test ();
use File::Basename 'dirname';
use File::Spec::Functions 'catdir';

my @projects = qw(

my $top_dir = dirname Apache::Test::vars('top_dir');
adjust_INC(map { catdir $top_dir, $_ } @projects);

I was thinking to add this to Apache::TestUtil. If you like it, we should 
come up with an intuitive name, as adjust_INC is just a temp name I use in 
my project.

Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker     mod_perl Guide --->

View raw message