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:

$HOME/modules/Apache-Foo/lib
$HOME/modules/Apache-Foo/blib
$HOME/modules/Apache-Bar/lib
$HOME/modules/Apache-Tar/lib

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

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

my @projects = qw(
    Apache-Foo
    Apache-Bar
    Apache-Tar
);

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
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://mailchannels.com

Reply via email to