1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
# please insert nothing before this line: -*- mode: cperl; cperl-indent-level: 4; cperl-continued-statement-offset: 4; indent-tabs-mode: nil -*-
package TestDirective::perlrequire;
# Test whether vhost with 'PerlOptions +Parent', which doesn't inherit
# from the base, has its own INC and therefore can have a modules with
# the same namespace as the base, but different content.
#
# Also see the parallel TestDirective::perlmodule handler
use strict;
use warnings FATAL => 'all';
use Apache::Test ();
use Apache2::RequestRec ();
use Apache2::RequestIO ();
use File::Spec::Functions qw(catfile);
use Apache2::Const -compile => 'OK';
sub handler {
my $r = shift;
$r->content_type('text/plain');
$r->puts($ApacheTest::PerlRequireTest::MAGIC || '');
Apache2::Const::OK;
}
my %require_tests =
(
main => 'PerlRequired by Parent',
vh => 'PerlRequired by VirtualHost',
);
sub APACHE_TEST_CONFIGURE {
my ($class, $self) = @_;
my $vars = $self->{vars};
my $target_dir = catfile $vars->{documentroot}, 'testdirective';
# create two different PerlRequireTest.pm packages to be loaded by
# vh and main interpreters, on the fly before the tests start
while (my ($test, $magic) = each %require_tests) {
my $content = <<EOF;
package ApacheTest::PerlRequireTest;
\$ApacheTest::PerlRequireTest::MAGIC = '$magic';
1;
EOF
my $file = catfile $target_dir,
$test, 'ApacheTest', 'PerlRequireTest.pm';
$self->writefile($file, $content, 1);
}
}
1;
__END__
# APACHE_TEST_CONFIG_ORDER 940
<Base>
PerlSwitches -I@documentroot@/testdirective/main
PerlRequire "ApacheTest/PerlRequireTest.pm"
</Base>
<VirtualHost TestDirective::perlrequire>
<IfDefine PERL_USEITHREADS>
# a new interpreter pool
PerlOptions +Parent
PerlInterpStart 1
PerlInterpMax 1
PerlInterpMinSpare 1
PerlInterpMaxSpare 1
</IfDefine>
# use test system's @INC
PerlSwitches -I@serverroot@
PerlRequire "conf/modperl_inc.pl"
PerlSwitches -I@documentroot@/testdirective/vh
PerlRequire "ApacheTest/PerlRequireTest.pm"
<Location /TestDirective__perlrequire>
SetHandler modperl
PerlResponseHandler TestDirective::perlrequire
</Location>
</VirtualHost>
|