OK, using the patch I've just sent for auto-mkpath and using all the
latest patches, makes the perlrequire test short and sweet:

--- /dev/null   Thu Jan  1 07:30:00 1970
+++ t/response/TestDirective/perlrequire.pm     Mon Sep 17 13:03:20 2001
@@ -0,0 +1,69 @@
+package TestDirective::perlrequire;
+
+use strict;
+use warnings FATAL => 'all';
+
+use Apache::Test ();
+use Apache::Const -compile => 'OK';
+use File::Spec::Functions qw(catfile);
+
+sub handler {
+    my $r = shift;
+
+    $r->content_type('text/plain');
+    $r->puts($My::PerlRequireTest::MAGIC || '');
+
+    Apache::OK;
+}
+
+sub APACHE_TEST_CONFIGURE {
+    my ($class, $self) = @_;
+
+    my $vars = $self->{vars};
+
+    my $main_mod = << 'EOF';
+package My::PerlRequireTest;
+$My::PerlRequireTest::MAGIC = 'Loaded by Parent';
+1;
+EOF
+
+    my $vh_mod = << 'EOF';
+package My::PerlRequireTest;
+$My::PerlRequireTest::MAGIC = 'Loaded by Virtual Host';
+1;
+EOF
+
+    # new dirs
+    my $target_dir = catfile $vars->{documentroot}, 'testdirective';
+    my $main_dir   = catfile $target_dir, "main";
+    my $vh_dir     = catfile $target_dir, "vh";
+
+    # write test modules
+    my $main_file   = catfile $main_dir, "PerlRequireTest.pm";
+    my $vh_file     = catfile $vh_dir,   "PerlRequireTest.pm";
+    $self->writefile($main_file,   $main_mod, 1);
+    $self->writefile($vh_file,     $vh_mod,   1);
+}
+
+1;
+__END__
+PerlSwitches -Mlib=@documentroot@/testdirective/main
+PerlRequire "PerlRequireTest.pm"
+
+<VirtualHost TestDirective::perlrequire>
+
+  # a new interpreter pool
+  PerlOptions +Parent
+
+  # use test system's @INC
+  PerlSwitches -Mlib=@serverroot@
+  PerlRequire "conf/modperl_startup.pl"
+
+  PerlSwitches -Mlib=@documentroot@/testdirective/vh
+  PerlRequire "PerlRequireTest.pm"
+
+  <Location /TestDirective::perlrequire>
+     SetHandler modperl
+     PerlResponseHandler TestDirective::perlrequire
+  </Location>
+</VirtualHost>

--- /dev/null   Thu Jan  1 07:30:00 1970
+++ t/directive/perlrequire.t   Sat Sep 15 17:37:43 2001
@@ -0,0 +1,31 @@
+# this test tests PerlRequire configuration directive
+########################################################################
+
+use strict;
+use warnings FATAL => 'all';
+
+use Apache::Test;
+use Apache::TestUtil;
+use Apache::TestRequest ();
+
+my %checks =
+    (
+     'default'                    => 'Loaded by Parent',
+     'TestDirective::perlrequire' => 'Loaded by Virtual Host',
+    );
+
+plan tests => scalar keys %checks;
+
+for my $module (sort keys %checks) {
+    Apache::TestRequest::module($module);
+
+    my $config   = Apache::Test::config();
+    my $hostport = Apache::TestRequest::hostport($config);
+    print "connecting to $hostport\n";
+
+    ok t_cmp(
+             $checks{$module},
+             $config->http_raw_get("/TestDirective::perlrequire", undef),
+             "testing PerlRequire in $module",
+            );
+}

_____________________________________________________________________
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]

Reply via email to