You are viewing a plain text version of this content. The canonical link for it is here.
Posted to test-dev@httpd.apache.org by Stas Bekman <st...@stason.org> on 2003/10/11 08:17:21 UTC

Re: A::T blib vs lib

[Boris, in the future please post all the questions regarding A::T to this 
list, as it's not my personal project. Thanks.]

Boris Zentner wrote:
> Hi Stas,
> 
> I would like to release something that should use A::T but dire need to 
> install/use/test the content from blib NOT from lib.
> 
> I can not find a good solution for this and here is the ugliest part ever from 
> my t/TEST.PL.
> 
> Please advice me a better way, if you know one.

Yes, yes, I'm going to work on this asap (hopefuly the first few days of the 
next week), unless someone beats me to it.

We discussed with Boris offline that we want to change the current behavior of 
A::T, where it puts lib/ as the first entry in @INC. We agreed to have a 
special maintainer mode (Env var/option) which will turn on the current 
behavior, and by default blib/ dirs are to be first in @INC.

> thanks
> 
> ##################### TEST.PL #####################
> #!perl
> use FindBin;
> 
> # it is not enough to set only PERL5LIB then blib/lib is tested after lib
> $ENV{PERL5LIB} = "$FindBin::Bin/../blib/lib";
> 
> package My::TestRun;
> use base 'Apache::TestRun';
> use Apache::TestConfig;
> sub Apache::TestConfig::add_inc {
>     my $self = shift;
>     return if $ENV{MOD_PERL}; #already setup by mod_perl
>     require lib;
>     # we need blib/lib before lib -- what sense has blib else??? 
>     lib::->import(map "$self->{vars}->{top_dir}/$_",
>                   qw(blib/lib blib/arch lib ));
> }
> 
> 1;
> package main;
> 
> # do more
> 
> My::TestRun->new->run(@ARGV);
> 


-- 


__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


Re: A::T blib vs lib

Posted by Boris Zentner <bo...@ambient-entertainment.de>.
Hi,

Am Dienstag, 21. Oktober 2003 09:00 schrieb Stas Bekman:
> Boris Zentner wrote:
> > Hi,
> >
> > A test against my project show's no real difference at all. I applied the
> > patch against Apache-Test-1.04 and I verified that my
> > t/conf/modperl_inc.pl contain the desired lines.
> >
> > use lib '/tmp/ap_ex/blib/arch';
> > use lib '/tmp/ap_ex/blib/lib';
> > 1;
>
> Perfect. You are now talking about a different issue. If you look at
> t/conf/httpd.conf, t/conf/extra.conf is loaded before
> t/conf/modperl_startup.pl (which loads t/conf/modperl_inc.pl and
> t/conf/modperl_inc.pl) that's why you have this problem. What you want to
> do is to move all the code from the <Perl> sections in t/conf/extra.conf.in
> into t/conf/modperl_extra.pl, which is loaded after t/conf/modperl_inc.pl
> and you will be alright.

Ok, I moved the code to modperl_extra.pl.in. But no success. A look into the 
generated httpd.conf shows that modperl_extra.pl is loaded before 
modperl_startup which load modperl_extra again and modperl_inc.

If I remove the perlrequire modperl_extra.pl line and run ./t/TEST, I load 
Apache::PageKit again from ./lib 

 waiting for server to start: ok (waited 0 secs)
server localhost:8529 started
1_dummy....Can't locate Text/Iconv.pm in @INC (@INC contains: /tmp/ap_ex/
Apache-Test/lib /tmp/ap_ex/lib /tmp/ap_ex/blib/lib /tmp/ap_ex/blib/arch /
home/ptest/lib/perl5/5.8.1/i686-linux-thread-multi /home/ptest/lib/
perl5/5.8.1/i686-linux-thread-multi /home/ptest/lib/perl5/5.8.1 /home/ptest/
lib/perl5/site_perl/5.8.1/i686-linux-thread-multi /home/ptest/lib/perl5/
site_perl/5.8.1/i686-linux-thread-multi /home/ptest/lib/perl5/
site_perl/5.8.1 /home/ptest/lib/perl5/site_perl/5.8.1/
i686-linux-thread-multi /home/ptest/lib/perl5/site_perl/5.8.1 /home/ptest/
lib/perl5/site_perl . /home/ptest/lib/perl5/5.8.1/i686-linux-thread-multi /
home/ptest/lib/perl5/5.8.1 /home/ptest/lib/perl5/site_perl/5.8.1/
i686-linux-thread-multi /home/ptest/lib/perl5/site_perl/5.8.1 /home/ptest/
lib/perl5/site_perl .) at /tmp/ap_ex/lib/Apache/PageKit.pm line 21.

Another point is that if I move the code out of the extra.conf this change 
conditional, that I have to move it out of its context. I can workaround 
this but others may not.

here is a little example:

<Location /xyz>
SetHandler perl-script
PerlSetVar PKIT_ROOT @ServerRoot@/../xyz
PerlSetVar PKIT_SERVER staging
PerlHandler +Apache::PageKit
<Perl>
use Apache::PageKit;
Apache::PageKit->startup;
</Perl>
</Location>

<Location /abc>
SetHandler perl-script
PerlSetVar PKIT_ROOT @ServerRoot@/../abc
PerlSetVar PKIT_SERVER production
PerlHandler +Apache::PageKit
<Perl>
use Apache::PageKit;
Apache::PageKit->startup;
</Perl>
</Location>

in my example above I call Apache::PageKit->startup two times but both get 
different PKIT_ROOT and PKIT_SERVER values from the server. This change, if I 
move it out of the Location directive.

>
> __________________________________________________________________
> Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
> http://stason.org/     mod_perl Guide ---> http://perl.apache.org
> mailto:stas@stason.org http://use.perl.org http://apacheweek.com
> http://modperlbook.org http://apache.org   http://ticketmaster.com

-- 
Boris


Re: A::T blib vs lib

Posted by Stas Bekman <st...@stason.org>.
Boris Zentner wrote:

[Finally the kind moderator let your messages through ;) Thank you!]

> In short lib is searched before blib/lib. I had a workaround that overwrites 
> some routines in Apache::Test but it is really uggly and may not work taht 
> long. Im happy that Stas is now looking into the problem.
> 
> my  modperl_onc.pl contains this lines:
> ###### modperl_inc.pl
> 
> use lib '/tmp/ap_ex/blib/arch';
> use lib '/tmp/ap_ex/blib/lib';
> 1;

which shows that '/tmp/ap_ex/lib' is no longer hardcoded in the server setup. 
But...

> ##### extra.last.conf.in
> <Location />
> SetHandler perl-script
> PerlSetVar PKIT_ROOT @ServerRoot@/../eg
> PerlSetVar PKIT_SERVER staging
> PerlHandler +Apache::PageKit
> <Perl>
> use Apache::PageKit;
>  Apache::PageKit->startup('@ServerRoot@/../eg','staging');
> </Perl>
> </Location>
> 
> and here is my @INC as you can see loaded from lib and not from blib/lib as 
> desired.
> 
> Can't locate Text/Iconv.pm in @INC (@INC contains: /tmp/ap_ex/Apache-Test/
> lib /tmp/ap_ex/lib /tmp/ap_ex/blib/lib /tmp/ap_ex/blib/arch /home/ptest/lib/
> perl5/5.8.1/i686-linux-thread-multi /home/ptest/lib/perl5/5.8.1/
> i686-linux-thread-multi /home/ptest/lib/perl5/5.8.1 /home/ptest/lib/perl5/
> site_perl/5.8.1/i686-linux-thread-multi /home/ptest/lib/perl5/
> site_perl/5.8.1/i686-linux-thread-multi /home/ptest/lib/perl5/
> site_perl/5.8.1 /home/ptest/lib/perl5/site_perl/5.8.1/
> i686-linux-thread-multi /home/ptest/lib/perl5/site_perl/5.8.1 /home/ptest/
> lib/perl5/site_perl . /home/ptest/lib/perl5/5.8.1/i686-linux-thread-multi /
> home/ptest/lib/perl5/5.8.1 /home/ptest/lib/perl5/site_perl/5.8.1/
> i686-linux-thread-multi /home/ptest/lib/perl5/site_perl/5.8.1 /home/ptest/
> lib/perl5/site_perl .) at /tmp/ap_ex/lib/Apache/PageKit.pm line 21.

Found it. The autogenerated t/TEST was also pushing lib into @INC, will fix 
that shortly.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


Re: A::T blib vs lib

Posted by Stas Bekman <st...@stason.org>.
Geoffrey Young wrote:
> 
>> That leads to different version of Apache:PageKit in the lib and 
>> blib/lib directories. With the current version of Apache::Test the 
>> version in lib is tested. But 'make install' installs the version from 
>> blib/lib. And depending from your perl they are different.
> 
> 
> so you want Apache-Test to test _only_ the version in blib and _never_ 
> the version in lib, right?
> 
> this kinda confirms my suspicion that stas
> 
>     % env APACHE_TEST_LIVE_DEV=1 t/TEST -conf
> 
> patch does exactly the opposite of what you wanted.

No, my patch does the right thing. It does not add 'lib' by default. It adds 
it only if APACHE_TEST_LIVE_DEV=1 is there.

>> I reported that to Stas and he explaind that the lib path is hardcoded 
>> to make development easier. 
> 
> 
> for the record, I need to re-iterate how much I dislike that idea in the 
> first place :)

For the record, it's that idea is now optional, so unfortunately you there is 
not much left to dislike ;)

>> As a solution he suggest a ENV var that when set prefer the lib dir 
>> for development.
> 
> 
> so, what I gather is that what APACHE_TEST_LIVE_DEV=1 ought to do is not 
> add lib to @INC, but rather ensure that lib is not used at all, thus 
> forcing the tests to use blib (as is the standard practice everywhere I 
> know about except Apache-Test).  does that sound right?

Forget the APACHE_TEST_LIVE_DEV=1 option. I added it for myself and others who 
want to develop against 'lib'. By default you don't need to do anything and 
you never get 'lib' autoinserted for you.


__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


Re: A::T blib vs lib

Posted by Geoffrey Young <ge...@modperlcookbook.org>.
> That leads to different 
> version of Apache:PageKit in the lib and blib/lib directories. With the 
> current version of Apache::Test the version in lib is tested. But 'make 
> install' installs the version from blib/lib. And depending from your perl 
> they are different.

so you want Apache-Test to test _only_ the version in blib and _never_ the 
version in lib, right?

this kinda confirms my suspicion that stas

     % env APACHE_TEST_LIVE_DEV=1 t/TEST -conf

patch does exactly the opposite of what you wanted.

> 
> I reported that to Stas and he explaind that the lib path is hardcoded to make 
> development easier. 

for the record, I need to re-iterate how much I dislike that idea in the 
first place :)

> As a solution he suggest a ENV var that when set prefer 
> the lib dir for development.

so, what I gather is that what APACHE_TEST_LIVE_DEV=1 ought to do is not add 
lib to @INC, but rather ensure that lib is not used at all, thus forcing the 
tests to use blib (as is the standard practice everywhere I know about 
except Apache-Test).  does that sound right?

--Geoff


Re: A::T blib vs lib

Posted by Boris Zentner <bo...@ambient-entertainment.de>.
Hi Geoffrey,

Am Dienstag, 21. Oktober 2003 15:09 schrieb Geoffrey Young:
> > That was a very good hint. It allows me to keep the perl part into the
> > apache directives as desired. But my @INC path is still wrong.
>
> hmm.
>
> ok, how about you show us a few things, like all of modperl_inc.pl, then
> what directories you would like included that are missing.  and also show
> us your @INC.

My problem is if have a large project ( Apache::PageKit ) that works currently 
with perl < 5.6.1, perl > 5.6.1 but < 5.8 and perl >= 5.8. Thats no problem, 
but a newbie can not install it propper. So my intent is a installation 
process that does a the right thing for the installed version of perl. Since 
I prefer a automatic solution I test the version of perl and apply all needed 
patches to Apache::PageKit during the 'make' phase. That leads to different 
version of Apache:PageKit in the lib and blib/lib directories. With the 
current version of Apache::Test the version in lib is tested. But 'make 
install' installs the version from blib/lib. And depending from your perl 
they are different.

I reported that to Stas and he explaind that the lib path is hardcoded to make 
development easier. As a solution he suggest a ENV var that when set prefer 
the lib dir for development.

Then Stas kindly produce a patch that I tested today against Apache::Test 
1.04.

>
> if the libraries are properly specified in modperl_inc.pl but not in @INC,
> that's one thing.  if they are not in modperl_inc.pl that's another.  right
> now, I'm unclear as to what the problem is exactly.
>

In short lib is searched before blib/lib. I had a workaround that overwrites 
some routines in Apache::Test but it is really uggly and may not work taht 
long. Im happy that Stas is now looking into the problem.

my  modperl_onc.pl contains this lines:
###### modperl_inc.pl

use lib '/tmp/ap_ex/blib/arch';
use lib '/tmp/ap_ex/blib/lib';
1;

##### extra.last.conf.in
<Location />
SetHandler perl-script
PerlSetVar PKIT_ROOT @ServerRoot@/../eg
PerlSetVar PKIT_SERVER staging
PerlHandler +Apache::PageKit
<Perl>
use Apache::PageKit;
 Apache::PageKit->startup('@ServerRoot@/../eg','staging');
</Perl>
</Location>

and here is my @INC as you can see loaded from lib and not from blib/lib as 
desired.

Can't locate Text/Iconv.pm in @INC (@INC contains: /tmp/ap_ex/Apache-Test/
lib /tmp/ap_ex/lib /tmp/ap_ex/blib/lib /tmp/ap_ex/blib/arch /home/ptest/lib/
perl5/5.8.1/i686-linux-thread-multi /home/ptest/lib/perl5/5.8.1/
i686-linux-thread-multi /home/ptest/lib/perl5/5.8.1 /home/ptest/lib/perl5/
site_perl/5.8.1/i686-linux-thread-multi /home/ptest/lib/perl5/
site_perl/5.8.1/i686-linux-thread-multi /home/ptest/lib/perl5/
site_perl/5.8.1 /home/ptest/lib/perl5/site_perl/5.8.1/
i686-linux-thread-multi /home/ptest/lib/perl5/site_perl/5.8.1 /home/ptest/
lib/perl5/site_perl . /home/ptest/lib/perl5/5.8.1/i686-linux-thread-multi /
home/ptest/lib/perl5/5.8.1 /home/ptest/lib/perl5/site_perl/5.8.1/
i686-linux-thread-multi /home/ptest/lib/perl5/site_perl/5.8.1 /home/ptest/
lib/perl5/site_perl .) at /tmp/ap_ex/lib/Apache/PageKit.pm line 21.


> --Geoff

-- 
Boris


Re: A::T blib vs lib

Posted by Geoffrey Young <ge...@modperlcookbook.org>.
> 
> That was a very good hint. It allows me to keep the perl part into the apache 
> directives as desired. But my @INC path is still wrong.

hmm.

ok, how about you show us a few things, like all of modperl_inc.pl, then 
what directories you would like included that are missing.  and also show us 
your @INC.

if the libraries are properly specified in modperl_inc.pl but not in @INC, 
that's one thing.  if they are not in modperl_inc.pl that's another.  right 
now, I'm unclear as to what the problem is exactly.

--Geoff


Re: A::T blib vs lib

Posted by Boris Zentner <bo...@ambient-entertainment.de>.
Hi,
Am Dienstag, 21. Oktober 2003 14:19 schrieb Geoffrey Young:
> Stas Bekman wrote:
> > Boris Zentner wrote:
> >> Hi,
> >>
> >> A test against my project show's no real difference at all. I applied
> >> the patch against Apache-Test-1.04 and I verified that my
> >> t/conf/modperl_inc.pl contain the desired lines.
> >>
> >> use lib '/tmp/ap_ex/blib/arch';
> >> use lib '/tmp/ap_ex/blib/lib';
> >> 1;
> >
> > Perfect. You are now talking about a different issue. If you look at
> > t/conf/httpd.conf, t/conf/extra.conf is loaded before
> > t/conf/modperl_startup.pl (which loads t/conf/modperl_inc.pl and
> > t/conf/modperl_inc.pl) that's why you have this problem. What you want
> > to do is to move all the code from the <Perl> sections in
> > t/conf/extra.conf.in into t/conf/modperl_extra.pl, which is loaded after
> > t/conf/modperl_inc.pl and you will be alright.
>
> or use t/conf/extra.last.conf.in instead of t/conf/extra.conf.in, which is
> probably an easier solution, as it allows you to maintain a httpd.conf
> style config.

That was a very good hint. It allows me to keep the perl part into the apache 
directives as desired. But my @INC path is still wrong.

Thanks for the Tip.
>
> --Geoff

-- 
Boris


Re: A::T blib vs lib

Posted by Boris Zentner <bo...@ambient-entertainment.de>.
Hi Stas,

It works fine. Thanks.

>
> There were two more places where lib was unconditionally pushed. And
> removing lib, affected mod_perl 2, so I had to fix that as well. I haven't
> thoroughly tested this change yet, but please try this patch:
[...]
> __________________________________________________________________
> Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
> http://stason.org/     mod_perl Guide ---> http://perl.apache.org
> mailto:stas@stason.org http://use.perl.org http://apacheweek.com
> http://modperlbook.org http://apache.org   http://ticketmaster.com

-- 
Boris


Re: A::T blib vs lib

Posted by Boris Zentner <bo...@ambient-entertainment.de>.
Hi,

Am Dienstag, 21. Oktober 2003 23:24 schrieb Stas Bekman:
> Stas Bekman wrote:

> Please verify that it works for you Boris and we will make a new release.
> Geoff has volunteered to be the release manager for this release. ;)

Ok, I tested cvs-version 1.05-dev against my project with mp1 and it works 
fine out of the box.

Thank you.

-- 
Boris


Re: A::T blib vs lib

Posted by Stas Bekman <st...@stason.org>.
Stas Bekman wrote:
> Geoffrey Young wrote:


>> tests fine for me on mp2 and my 3rd party apps.

Thanks Geoff.

> There are problems if you remove previously installed modperl. I'm 
> looking at it.

Apparently mod_perl 2.0's distro must have 'lib' pushed onto @INC from t/TEST. 
That was the problem. Now committed with the special case for mod_perl build.

Please verify that it works for you Boris and we will make a new release. 
Geoff has volunteered to be the release manager for this release. ;)

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


Re: A::T blib vs lib

Posted by Stas Bekman <st...@stason.org>.
Geoffrey Young wrote:
> 
> 
> Stas Bekman wrote:
> 
>>  I haven't thoroughly tested this change yet, but please try this patch:
> 
> 
> tests fine for me on mp2 and my 3rd party apps.
> 
> nice work.

There are problems if you remove previously installed modperl. I'm looking at it.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


Re: A::T blib vs lib

Posted by Geoffrey Young <ge...@modperlcookbook.org>.

Stas Bekman wrote:
>  I 
> haven't thoroughly tested this change yet, but please try this patch:

tests fine for me on mp2 and my 3rd party apps.

nice work.

--Geoff


Re: A::T blib vs lib

Posted by Stas Bekman <st...@stason.org>.
Boris Zentner wrote:
> Hi,
> 
> im subscribed!

And someone has let your previous posts through ;)

> All your hints and tips bring me a step forward, but I stuck on the @INC 
> again. Even with the patch.
> 
> The only thing that pass my brief tests is to change the order of the included 
> path inside TestConfig.pm
> 
> --- TestConfig.pm.orig  2003-10-21 20:49:53.000000000 +0200
> +++ TestConfig.pm       2003-10-21 20:51:20.000000000 +0200
> @@ -1441,7 +1441,7 @@
>      # followed by modperl-2.0/lib (or some other project's lib/),
>      # followed by blib/ and finally system-wide libs.
>      lib::->import(map "$self->{vars}->{top_dir}/$_",
> -                  qw(Apache-Test/lib lib blib/lib blib/arch));
> +                  qw(Apache-Test/lib blib/arch blib/lib lib));
>      #print join "\n", "add_inc", @INC, "";
>  }

There were two more places where lib was unconditionally pushed. And removing 
lib, affected mod_perl 2, so I had to fix that as well. I haven't thoroughly 
tested this change yet, but please try this patch:

Index: lib/Apache/TestConfig.pm
===================================================================
RCS file: 
/home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestConfig.pm,v
retrieving revision 1.179
diff -u -r1.179 TestConfig.pm
--- lib/Apache/TestConfig.pm	20 Oct 2003 22:48:58 -0000	1.179
+++ lib/Apache/TestConfig.pm	21 Oct 2003 19:28:50 -0000
@@ -120,7 +120,7 @@
  sub server { shift->{server} }

  sub modperl_2_inc_fixup {
-    (IS_MOD_PERL_2 && !IS_MOD_PERL_2_BUILD) ? "use Apache2;\n" : '';
+    (IS_MOD_PERL_2 ) ? "use Apache2;\n" : '';
  }

  sub modperl_build_config {
@@ -780,13 +780,19 @@

      require FindBin;

-    # the live 'lib/' dir of the distro (e.g. modperl-2.0/ModPerl-Registry/lib)
-    my @dirs = canonpath catdir $FindBin::Bin, "lib";
+    my @dirs = ();

-    # the live dir of the top dir if any  (e.g. modperl-2.0/lib)
-    if (-e catfile($FindBin::Bin, "..", "Makefile.PL") &&
-        -d catdir($FindBin::Bin, "..", "lib") ) {
-        push @dirs, canonpath catdir $FindBin::Bin, "..", "lib";
+    if ($ENV{APACHE_TEST_LIVE_DEV}) {
+        # the live 'lib/' dir of the distro
+        # (e.g. modperl-2.0/ModPerl-Registry/lib)
+        my $dir = canonpath catdir $FindBin::Bin, "lib";
+        push @dirs, $dir if -d $dir;
+
+        # the live dir of the top dir if any  (e.g. modperl-2.0/lib)
+        if (-e catfile($FindBin::Bin, "..", "Makefile.PL")) {
+            my $dir = canonpath catdir $FindBin::Bin, "..", "lib";
+            push @dirs, $dir if -d $dir;
+        }
      }

      for (qw(. ..)) {
@@ -1442,8 +1448,18 @@
      # make sure that Apache-Test/lib will be first in @INC,
      # followed by modperl-2.0/lib (or some other project's lib/),
      # followed by blib/ and finally system-wide libs.
-    lib::->import(map "$self->{vars}->{top_dir}/$_",
-                  qw(Apache-Test/lib lib blib/lib blib/arch));
+    my $top_dir = $self->{vars}->{top_dir};
+    my @dirs = map { catdir $top_dir, "blib", $_ } qw(lib arch);
+
+    my $apache_test_dir = catdir $top_dir, "Apache-Test";
+    unshift @dirs, $apache_test_dir if -d $apache_test_dir;
+
+    if ($ENV{APACHE_TEST_LIVE_DEV}) {
+        my $lib_dir = catdir $top_dir, "lib";
+        push @dirs, $lib_dir if -d $lib_dir;
+    }
+
+    lib::->import(@dirs);
      #print join "\n", "add_inc", @INC, "";
  }

Index: lib/Apache/TestConfigPerl.pm
===================================================================
RCS file: 
/home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestConfigPerl.pm,v
retrieving revision 1.78
diff -u -r1.78 TestConfigPerl.pm
--- lib/Apache/TestConfigPerl.pm	20 Oct 2003 20:22:56 -0000	1.78
+++ lib/Apache/TestConfigPerl.pm	21 Oct 2003 19:28:50 -0000
@@ -153,7 +153,6 @@
      if (my $inc = $self->{inc}) {
          my $include_pl = catfile $self->{vars}->{t_conf}, 'modperl_inc.pl';
          my $fh = $self->genfile($include_pl);
-        # make sure that the dev libs come before blib
          for (reverse @$inc) {
              print $fh "use lib '$_';\n";
          }

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


Re: A::T blib vs lib

Posted by Boris Zentner <bo...@ambient-entertainment.de>.
Hi,

im subscribed!

All your hints and tips bring me a step forward, but I stuck on the @INC 
again. Even with the patch.

The only thing that pass my brief tests is to change the order of the included 
path inside TestConfig.pm

--- TestConfig.pm.orig  2003-10-21 20:49:53.000000000 +0200
+++ TestConfig.pm       2003-10-21 20:51:20.000000000 +0200
@@ -1441,7 +1441,7 @@
     # followed by modperl-2.0/lib (or some other project's lib/),
     # followed by blib/ and finally system-wide libs.
     lib::->import(map "$self->{vars}->{top_dir}/$_",
-                  qw(Apache-Test/lib lib blib/lib blib/arch));
+                  qw(Apache-Test/lib blib/arch blib/lib lib));
     #print join "\n", "add_inc", @INC, "";
 }

Am Dienstag, 21. Oktober 2003 18:12 hast Du geschrieben:
> Geoffrey Young wrote:
> > Stas Bekman wrote:
> >> Boris Zentner wrote:
> >>> Hi,
> >>>
> >>> A test against my project show's no real difference at all. I applied
> >>> the patch against Apache-Test-1.04 and I verified that my
> >>> t/conf/modperl_inc.pl contain the desired lines.
> >>>
> >>> use lib '/tmp/ap_ex/blib/arch';
> >>> use lib '/tmp/ap_ex/blib/lib';
> >>> 1;
> >>
> >> Perfect. You are now talking about a different issue. If you look at
> >> t/conf/httpd.conf, t/conf/extra.conf is loaded before
> >> t/conf/modperl_startup.pl (which loads t/conf/modperl_inc.pl and
> >> t/conf/modperl_inc.pl) that's why you have this problem. What you want
> >> to do is to move all the code from the <Perl> sections in
> >> t/conf/extra.conf.in into t/conf/modperl_extra.pl, which is loaded
> >> after t/conf/modperl_inc.pl and you will be alright.
> >
> > or use t/conf/extra.last.conf.in instead of t/conf/extra.conf.in, which
> > is probably an easier solution, as it allows you to maintain a
> > httpd.conf style config.
>
> Yes, sorry, that's the right advise.
>
> Boris, do you mind subscribing to test-dev? otherwise we see only replies
> and never your posts unless they are addressed to one of us. I don't know
> what happened to the moderators and why posts aren't making through :(
> Please send email to test-dev-subscribe@httpd.apache.org
>
>
> __________________________________________________________________
> Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
> http://stason.org/     mod_perl Guide ---> http://perl.apache.org
> mailto:stas@stason.org http://use.perl.org http://apacheweek.com
> http://modperlbook.org http://apache.org   http://ticketmaster.com

-- 
Boris


Re: A::T blib vs lib

Posted by Stas Bekman <st...@stason.org>.
Geoffrey Young wrote:
> 
> 
> Stas Bekman wrote:
> 
>> Boris Zentner wrote:
>>
>>> Hi,
>>>
>>> A test against my project show's no real difference at all. I applied 
>>> the patch against Apache-Test-1.04 and I verified that my 
>>> t/conf/modperl_inc.pl contain the desired lines.
>>>
>>> use lib '/tmp/ap_ex/blib/arch';
>>> use lib '/tmp/ap_ex/blib/lib';
>>> 1;
>>
>>
>>
>> Perfect. You are now talking about a different issue. If you look at
>> t/conf/httpd.conf, t/conf/extra.conf is loaded before 
>> t/conf/modperl_startup.pl (which loads t/conf/modperl_inc.pl and 
>> t/conf/modperl_inc.pl) that's why you have this problem. What you want 
>> to do is to move all the code from the <Perl> sections in 
>> t/conf/extra.conf.in into t/conf/modperl_extra.pl, which is loaded 
>> after t/conf/modperl_inc.pl and you will be alright.
> 
> 
> or use t/conf/extra.last.conf.in instead of t/conf/extra.conf.in, which 
> is probably an easier solution, as it allows you to maintain a 
> httpd.conf style config.

Yes, sorry, that's the right advise.

Boris, do you mind subscribing to test-dev? otherwise we see only replies and 
never your posts unless they are addressed to one of us. I don't know what 
happened to the moderators and why posts aren't making through :(
Please send email to test-dev-subscribe@httpd.apache.org


__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


Re: A::T blib vs lib

Posted by Geoffrey Young <ge...@modperlcookbook.org>.

Stas Bekman wrote:
> Boris Zentner wrote:
> 
>> Hi,
>>
>> A test against my project show's no real difference at all. I applied 
>> the patch against Apache-Test-1.04 and I verified that my 
>> t/conf/modperl_inc.pl contain the desired lines.
>>
>> use lib '/tmp/ap_ex/blib/arch';
>> use lib '/tmp/ap_ex/blib/lib';
>> 1;
> 
> 
> Perfect. You are now talking about a different issue. If you look at
> t/conf/httpd.conf, t/conf/extra.conf is loaded before 
> t/conf/modperl_startup.pl (which loads t/conf/modperl_inc.pl and 
> t/conf/modperl_inc.pl) that's why you have this problem. What you want 
> to do is to move all the code from the <Perl> sections in 
> t/conf/extra.conf.in into t/conf/modperl_extra.pl, which is loaded after 
> t/conf/modperl_inc.pl and you will be alright.

or use t/conf/extra.last.conf.in instead of t/conf/extra.conf.in, which is 
probably an easier solution, as it allows you to maintain a httpd.conf style 
config.

--Geoff


Re: A::T blib vs lib

Posted by Stas Bekman <st...@stason.org>.
Boris Zentner wrote:
> Hi,
> 
> A test against my project show's no real difference at all. I applied the 
> patch against Apache-Test-1.04 and I verified that my t/conf/modperl_inc.pl 
> contain the desired lines.
> 
> use lib '/tmp/ap_ex/blib/arch';
> use lib '/tmp/ap_ex/blib/lib';
> 1;

Perfect. You are now talking about a different issue. If you look at
t/conf/httpd.conf, t/conf/extra.conf is loaded before 
t/conf/modperl_startup.pl (which loads t/conf/modperl_inc.pl and 
t/conf/modperl_inc.pl) that's why you have this problem. What you want to do 
is to move all the code from the <Perl> sections in t/conf/extra.conf.in into 
t/conf/modperl_extra.pl, which is loaded after t/conf/modperl_inc.pl and you 
will be alright.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


Re: A::T blib vs lib

Posted by Boris Zentner <bo...@ambient-entertainment.de>.
Hi,

A test against my project show's no real difference at all. I applied the 
patch against Apache-Test-1.04 and I verified that my t/conf/modperl_inc.pl 
contain the desired lines.

use lib '/tmp/ap_ex/blib/arch';
use lib '/tmp/ap_ex/blib/lib';
1;

my error message is the following:

...
/home/ptest/httpd/bin/httpd -X -d /tmp/ap_ex/t -f /tmp/ap_ex/t/conf/httpd.conf 
-DAPACHE1 -DPERL_USEITHREADS
using Apache/1.3.28

waiting for server to start: .Syntax error on line 35 of /tmp/ap_ex/t/conf/
extra.conf:
Can't locate Apache/PageKit.pm in @INC (@INC contains: /home/ptest/lib/
perl5/5.8.1/i686-linux-thread-multi /home/ptest/lib/perl5/5.8.1 /home/ptest/
lib/perl5/site_perl/5.8.1/i686-linux-thread-multi /home/ptest/lib/perl5/
site_perl/5.8.1 /home/ptest/lib/perl5/site_perl . /tmp/ap_ex/t/ /tmp/ap_ex/t/
lib/perl) at /tmp/ap_ex/t/conf/extra.conf line 33.
BEGIN failed--compilation aborted at /tmp/ap_ex/t/conf/extra.conf line 33.

!!!
server has died with status 255 (t/logs/error_log wasn't created, start the 
server in the debug mode)


my t/conf/extra.conf.in contains
###### t/conf/extra.conf.in ############
<Location />
SetHandler perl-script
PerlSetVar PKIT_ROOT @ServerRoot@/../eg
PerlSetVar PKIT_SERVER staging
PerlHandler +Apache::PageKit
<Perl>
# CPAN Modules required for pagekit
use Apache::URI ();
use Apache::Cookie ();
use Apache::Request ();
use Apache::SessionX ();
use Apache::Util ();
use Compress::Zlib ();
use File::Find ();
use HTML::FillInForm ();
use HTML::Parser ();
use HTML::Template ();
use XML::LibXML ();

use Apache::PageKit;
        Apache::PageKit->startup('@ServerRoot@/../eg','staging');
</Perl>
</Location>


Am Montag, 20. Oktober 2003 05:36 schrieb Stas Bekman:
> Stas Bekman wrote:
> > We discussed with Boris offline that we want to change the current
> > behavior of A::T, where it puts lib/ as the first entry in @INC. We
> > agreed to have a special maintainer mode (Env var/option) which will
> > turn on the current behavior, and by default blib/ dirs are to be first
> > in @INC.
>
> Sorry for taking that long. Please try the patch at the end of this
> message.
>
> Is everybody happy with the name of the env var APACHE_TEST_LIVE_DEV, when
> when set to 1, will prepend the project/lib directory to @INC and otherwise
> won't do anything special about it. e.g. in the new Apache::VMonitor dir:
>
>    % env t/TEST -conf
>
> produces t/conf/modperl_inc.pl:
>
> use lib '/home/stas/work/modules/Apache-VMonitor-2.0/blib/arch';
> use lib '/home/stas/work/modules/Apache-VMonitor-2.0/blib/lib';
> use Apache2;
> 1;
>
> and:
>
> % env APACHE_TEST_LIVE_DEV=1 t/TEST -conf
>
> produces t/conf/modperl_inc.pl:
>
> use lib '/home/stas/work/modules/Apache-VMonitor-2.0/blib/arch';
> use lib '/home/stas/work/modules/Apache-VMonitor-2.0/blib/lib';
> use Apache2;
> use lib '/home/stas/work/modules/Apache-VMonitor-2.0/lib';
> 1;
>
> (It was broken before anyway, since 'use Apache2' was loaded last, pushing
> 'lib' down.)
>
> Index: lib/Apache/TestConfigPerl.pm
> ===================================================================
> RCS file:
> /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestConfigPerl.p
>m,v retrieving revision 1.77
> diff -u -r1.77 TestConfigPerl.pm
> --- lib/Apache/TestConfigPerl.pm	7 Oct 2003 17:44:58 -0000	1.77
> +++ lib/Apache/TestConfigPerl.pm	20 Oct 2003 04:29:28 -0000
> @@ -81,9 +81,8 @@
>       my $top = $self->{vars}->{top_dir};
>
>       my $inc = $self->{inc};
> -    my @trys = (catfile($top, 'lib'),
> -                catfile($top, qw(blib lib)),
> -                catfile($top, qw(blib arch)));
> +    my @trys = (catdir($top, qw(blib lib)),
> +                catdir($top, qw(blib arch)));
>
>       for (@trys) {
>           push @$inc, $_ if -d $_;
> @@ -160,6 +159,14 @@
>           }
>           my $fixup = Apache::TestConfig->modperl_2_inc_fixup();
>           print $fh $fixup;
> +
> +        # if Apache::Test is used to develop a project, we want the
> +        # project/lib directory to be first in @INC (loaded last)
> +        if ($ENV{APACHE_TEST_LIVE_DEV}) {
> +            my $dev_lib = catdir $self->{vars}->{top_dir}, "lib";
> +            print $fh "use lib '$dev_lib';\n" if -d $dev_lib;
> +        }
> +
>           print $fh "1;\n";
>       }
>
> __________________________________________________________________
> Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
> http://stason.org/     mod_perl Guide ---> http://perl.apache.org
> mailto:stas@stason.org http://use.perl.org http://apacheweek.com
> http://modperlbook.org http://apache.org   http://ticketmaster.com

-- 
Boris


Re: A::T blib vs lib

Posted by Stas Bekman <st...@stason.org>.
Geoffrey Young wrote:
> 
>>
>> Is everybody happy with the name of the env var APACHE_TEST_LIVE_DEV, 
>> when when set to 1, will prepend the project/lib directory to @INC and 
>> otherwise won't do anything special about it.
[...]
> sounds good.

So if Boris is happy, I'm planning to do one more tweak on the smoking side 
and we can make a new release candidate.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


Re: A::T blib vs lib

Posted by Geoffrey Young <ge...@modperlcookbook.org>.
> 
> Is everybody happy with the name of the env var APACHE_TEST_LIVE_DEV, 
> when when set to 1, will prepend the project/lib directory to @INC and 
> otherwise won't do anything special about it. e.g. in the new 
> Apache::VMonitor dir:
> 
>   % env t/TEST -conf
> 
> produces t/conf/modperl_inc.pl:
> 
> use lib '/home/stas/work/modules/Apache-VMonitor-2.0/blib/arch';
> use lib '/home/stas/work/modules/Apache-VMonitor-2.0/blib/lib';
> use Apache2;
> 1;
> 
> and:
> 
> % env APACHE_TEST_LIVE_DEV=1 t/TEST -conf
> 
> produces t/conf/modperl_inc.pl:
> 
> use lib '/home/stas/work/modules/Apache-VMonitor-2.0/blib/arch';
> use lib '/home/stas/work/modules/Apache-VMonitor-2.0/blib/lib';
> use Apache2;
> use lib '/home/stas/work/modules/Apache-VMonitor-2.0/lib';
> 1;
> 

sounds good.

--Geoff


Re: A::T blib vs lib

Posted by Stas Bekman <st...@stason.org>.
Stas Bekman wrote:

> We discussed with Boris offline that we want to change the current 
> behavior of A::T, where it puts lib/ as the first entry in @INC. We 
> agreed to have a special maintainer mode (Env var/option) which will 
> turn on the current behavior, and by default blib/ dirs are to be first 
> in @INC.

Sorry for taking that long. Please try the patch at the end of this message.

Is everybody happy with the name of the env var APACHE_TEST_LIVE_DEV, when 
when set to 1, will prepend the project/lib directory to @INC and otherwise 
won't do anything special about it. e.g. in the new Apache::VMonitor dir:

   % env t/TEST -conf

produces t/conf/modperl_inc.pl:

use lib '/home/stas/work/modules/Apache-VMonitor-2.0/blib/arch';
use lib '/home/stas/work/modules/Apache-VMonitor-2.0/blib/lib';
use Apache2;
1;

and:

% env APACHE_TEST_LIVE_DEV=1 t/TEST -conf

produces t/conf/modperl_inc.pl:

use lib '/home/stas/work/modules/Apache-VMonitor-2.0/blib/arch';
use lib '/home/stas/work/modules/Apache-VMonitor-2.0/blib/lib';
use Apache2;
use lib '/home/stas/work/modules/Apache-VMonitor-2.0/lib';
1;

(It was broken before anyway, since 'use Apache2' was loaded last, pushing 
'lib' down.)

Index: lib/Apache/TestConfigPerl.pm
===================================================================
RCS file: 
/home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestConfigPerl.pm,v
retrieving revision 1.77
diff -u -r1.77 TestConfigPerl.pm
--- lib/Apache/TestConfigPerl.pm	7 Oct 2003 17:44:58 -0000	1.77
+++ lib/Apache/TestConfigPerl.pm	20 Oct 2003 04:29:28 -0000
@@ -81,9 +81,8 @@
      my $top = $self->{vars}->{top_dir};

      my $inc = $self->{inc};
-    my @trys = (catfile($top, 'lib'),
-                catfile($top, qw(blib lib)),
-                catfile($top, qw(blib arch)));
+    my @trys = (catdir($top, qw(blib lib)),
+                catdir($top, qw(blib arch)));

      for (@trys) {
          push @$inc, $_ if -d $_;
@@ -160,6 +159,14 @@
          }
          my $fixup = Apache::TestConfig->modperl_2_inc_fixup();
          print $fh $fixup;
+
+        # if Apache::Test is used to develop a project, we want the
+        # project/lib directory to be first in @INC (loaded last)
+        if ($ENV{APACHE_TEST_LIVE_DEV}) {
+            my $dev_lib = catdir $self->{vars}->{top_dir}, "lib";
+            print $fh "use lib '$dev_lib';\n" if -d $dev_lib;
+        }
+
          print $fh "1;\n";
      }

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com