Apache-Test
view release on metacpan or search on metacpan
lib/Apache/TestConfigParse.pm view on Meta::CPAN
my $dir = dirname $result;
# $file might not exist (e.g. if it's a glob pattern like
# "conf/*.conf" but what we care about here is to check whether
# the base dir was successfully resolved. we don't check whether
# the file exists at all. it's the responsibility of the caller to
# do this check
if (defined $dir && -e $dir && -d _) {
if (-e $result) {
debug "$file successfully resolved to existing file $result";
}
else {
debug "base dir of '$file' successfully resolved to $dir";
}
}
else {
$dir ||= '';
warning "dir '$dir' does not exist (while resolving '$file')";
# old behavior was to return the resolved but non-existent
# file. preserve that behavior and return $result anyway.
}
return $result;
}
sub server_file {
my $f = shift->server_file_rel2abs(@_);
return qq("$f");
}
sub inherit_directive_var {
my($self, $c, $directive) = @_;
$self->{vars}->{"inherit_\L$directive"} = $c->{$directive};
}
sub inherit_server_file {
my($self, $c, $directive) = @_;
$self->spec_add_config($directive,
$self->server_file($c->{$directive}));
}
#so we have the same names if these modules are linked static or shared
my %modname_alias = (
'mod_pop.c' => 'pop_core.c',
'mod_proxy_ajp.c' => 'proxy_ajp.c',
'mod_proxy_http.c' => 'proxy_http.c',
'mod_proxy_ftp.c' => 'proxy_ftp.c',
'mod_proxy_balancer.c' => 'proxy_balancer.c',
'mod_proxy_connect.c' => 'proxy_connect.c',
'mod_modperl.c' => 'mod_perl.c',
);
# Block modules which inhibit testing:
# - mod_jk requires JkWorkerFile or JkWorker to be configured
# skip it for now, tomcat has its own test suite anyhow.
# - mod_casp2 requires other settings in addition to LoadModule
# - mod_bwshare and mod_evasive20 block fast requests that tests are doing
# - mod_fcgid causes https://rt.cpan.org/Public/Bug/Display.html?id=54476
# - mod_modnss.c and mod_rev.c require further configuration
my @autoconfig_skip_module = qw(mod_jk.c mod_casp2.c mod_bwshare.c
mod_fcgid.c mod_evasive20.c mod_modnss.c mod_rev.c);
# add modules to be not inherited from the existing config.
# e.g. prevent from LoadModule perl_module to be included twice, when
# mod_perl already configures LoadModule and it's certainly found in
# the existing httpd.conf installed system-wide.
sub autoconfig_skip_module_add {
push @autoconfig_skip_module, @_;
}
sub should_skip_module {
my($self, $name) = @_;
for (@autoconfig_skip_module) {
if (UNIVERSAL::isa($_, 'Regexp')) {
return 1 if $name =~ /$_/;
}
else {
return 1 if $name eq $_;
}
}
return 0;
}
#inherit LoadModule
sub inherit_load_module {
my($self, $c, $directive) = @_;
for my $args (@{ $c->{$directive} }) {
my $modname = $args->[0];
my $file = $self->server_file_rel2abs($args->[1]);
unless (-e $file) {
debug "$file does not exist, skipping LoadModule";
next;
}
my $name = basename $args->[1];
$name =~ s/\.(s[ol]|dll)$/.c/; #mod_info.so => mod_info.c
$name =~ s/^lib/mod_/; #libphp4.so => mod_php4.c
$name = $modname_alias{$name} if $modname_alias{$name};
# remember all found modules
$self->{modules}->{$name} = $file;
debug "Found: $modname => $name";
if ($self->should_skip_module($name)) {
debug "Skipping LoadModule of $name";
next;
}
debug "LoadModule $modname $name";
# sometimes people have broken system-wide httpd.conf files,
# which include LoadModule of modules, which are built-in, but
# won't be skipped above if they are found in the modules/
# directory. this usually happens when httpd is built once
# with its modules built as shared objects and then again with
# static ones: the old httpd.conf still has the LoadModule
# directives, even though the modules are now built-in
( run in 1.142 second using v1.01-cache-2.11-cpan-5735350b133 )