> > what do you mean? That's the point of my question :) If I put +Parent I
> > don't have these inhereted, that's why I had to manually add each of these.
>
> PerlSwitches is inherited, unless your vhost declares a PerlSwitches.
Nope, there aren't. I've tried to do:
require_test.pl
-----------------
use lib qw(lib/vh);
use PerlModuleTest;
1;
and in the TestModules/PerlRequire.pm (see below):
__END__
<VirtualHost TestModules::PerlRequire>
PerlOptions +Parent
PerlRequire conf/modperl_extra.pl
PerlRequire conf/require_test.pl
<Location /TestModules::PerlRequire>
SetHandler modperl
PerlResponseHandler TestModules::PerlRequire
</Location>
</VirtualHost>
But it couldn't find none of the required files, since PerlOptions +Parent
had reset the @INC completely. So currently I've "hardcoded" all the
required PerlSwitches, which is not nice at all.
Anyway, here is the PerlRequire test patch. PerlModule test will be almost
identical. Is it ok to have two of them separated or is it better to write
some more complicated test and have both tested from the same file, since
they setup an identical vh?
Also please see a few questions after the patch.
Index: Apache-Test/lib/Apache/TestConfig.pm
===================================================================
RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestConfig.pm,v
retrieving revision 1.14
diff -u -r1.14 TestConfig.pm
--- Apache-Test/lib/Apache/TestConfig.pm 2001/08/07 16:18:32 1.14
+++ Apache-Test/lib/Apache/TestConfig.pm 2001/08/10 09:52:13
@@ -733,3 +733,6 @@
<Location /server-status>
SetHandler server-status
</Location>
+
+PerlSwitches -Mlib=@serverroot@/lib/parent
+PerlRequire "PerlRequireTest.pm"
--- /dev/null Sat Apr 14 19:06:21 2001
+++ t/lib/parent/PerlRequireTest.pm Fri Aug 10 17:37:30 2001
@@ -0,0 +1,6 @@
+package PerlRequireTest;
+
+$PerlRequireTest::MAGIC = 'Loaded by Parent';
+
+1;
+__END__
--- /dev/null Sat Apr 14 19:06:21 2001
+++ t/lib/vh/PerlRequireTest.pm Fri Aug 10 17:37:50 2001
@@ -0,0 +1,6 @@
+package PerlRequireTest;
+
+$PerlRequireTest::MAGIC = 'Loaded by Virtual Host';
+
+1;
+__END__
--- /dev/null Sat Apr 14 19:06:21 2001
+++ t/response/TestModules/PerlRequire.pm Fri Aug 10 17:53:22 2001
@@ -0,0 +1,34 @@
+package TestModules::PerlRequire;
+
+use strict;
+use warnings FATAL => 'all';
+
+sub handler {
+ my $r = shift;
+
+ $r->content_type('text/plain');
+ $r->write($PerlRequireTest::MAGIC||'');
+
+ 0;# Apache::OK;
+}
+
+1;
+__END__
+<VirtualHost TestModules::PerlRequire>
+
+ PerlOptions +Parent
+ PerlSwitches -Mlib=@serverroot@
+ PerlSwitches -Mblib=@serverroot@
+ PerlSwitches -Mlib=@serverroot@/hooks
+ PerlSwitches -Mlib=@serverroot@/response
+ PerlRequire conf/modperl_extra.pl
+
+ PerlSwitches -Mlib=@serverroot@/lib/vh
+ PerlRequire "PerlRequireTest.pm"
+
+ #PerlRequire conf/require_test.pl
+ <Location /TestModules::PerlRequire>
+ SetHandler modperl
+ PerlResponseHandler TestModules::PerlRequire
+ </Location>
+</VirtualHost>
--- /dev/null Sat Apr 14 19:06:21 2001
+++ t/modules/PerlRequire.t Fri Aug 10 17:52:05 2001
@@ -0,0 +1,28 @@
+# this test tests PerlRequire configuration directive
+########################################################################
+
+use Apache::Test;
+use Apache::TestRequest ();
+use Apache::TestConfig ();
+
+my %checks =
+ (
+ 'default' => 'Loaded by Parent',
+ 'TestModules::PerlRequire' => 'Loaded by Virtual Host',
+ );
+
+plan tests => scalar keys %checks;
+
+for my $module (sort keys %checks) {
+ local $Apache::TestRequest::Module = $module;
+ $Apache::TestRequest::Module ||= $module; #-w
+
+ my $config = Apache::TestConfig->thaw;
+ my $hostport = Apache::TestRequest::hostport($config);
+ print "connecting to $hostport\n";
+
+ $res = $config->http_raw_get("/TestModules::PerlRequire") || '';
+ print "expecting: $checks{$module}\n";
+ print "getting : $res\n";
+ ok $res eq $checks{$module};
+}
It'd be nice to place, these two lines:
+
+PerlSwitches -Mlib=@serverroot@/lib/parent
+PerlRequire "PerlRequireTest.pm"
from Apache-Test/lib/Apache/TestConfig.pm
inside t/response/TestModules/PerlRequire.pm. Otherwise the bits of the
test are getting scattered around too many files and later on it'll be
very hard to understand where all the bits are stored. But I couldn't add
it outside of the <virtualhost ...> section, as it'd try to engulf these
directives inside a configuration container. Any ideas?
_____________________________________________________________________
Stas Bekman JAm_pH -- Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide http://perl.apache.org/guide
mailto:[EMAIL PROTECTED] http://apachetoday.com http://eXtropia.com/
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]