Apache-Test
view release on metacpan or search on metacpan
lib/Apache/TestServer.pm view on Meta::CPAN
$self->{name} = join ':',
map { $self->{config}->{vars}->{$_} } qw(servername port);
$self->{port_counter} = $self->{config}->{vars}->{port};
$self;
}
# call this when you already know where httpd is
sub post_config {
my($self) = @_;
$self->{version} = $self->{config}->httpd_version || '';
$self->{mpm} = $self->{config}->httpd_mpm || '';
# try to get the revision number from the standard Apache version
# string and various variations made by distributions which mangle
# that string
# Foo-Apache-Bar/x.y.z
($self->{rev}) = $self->{version} =~ m|/(\d)\.|;
if ($self->{rev}) {
debug "Matched Apache revision $self->{version} $self->{rev}";
}
else {
# guessing is not good as it'll only mislead users
# and we can't die since a config object is required
# during Makefile.PL's write_perlscript when path to httpd may
# be unknown yet. so default to non-existing version 0 for now.
# and let TestRun.pm figure out the required pieces
debug "can't figure out Apache revision, from string: " .
"'$self->{version}', using a non-existing revision 0";
$self->{rev} = 0; # unknown
}
($self->{revminor}) = $self->{version} =~ m|/\d\.(\d)|;
if ($self->{revminor}) {
debug "Matched Apache revminor $self->{version} $self->{revminor}";
}
else {
$self->{revminor} = 0;
}
$self;
}
sub version_of {
my($self, $thing) = @_;
die "Can't figure out what Apache server generation we are running"
unless $self->{rev};
$thing->{$self->{rev}};
}
my @apache_logs = qw(
error_log access_log httpd.pid
apache_runtime_status rewrite_log
ssl_engine_log ssl_request_log
cgisock
);
sub clean {
my $self = shift;
my $dir = $self->{config}->{vars}->{t_logs};
for (@apache_logs) {
my $file = catfile $dir, $_;
if (unlink $file) {
debug "unlink $file";
}
}
}
sub pid_file {
my $self = shift;
my $vars = $self->{config}->{vars};
return $vars->{t_pid_file} || catfile $vars->{t_logs}, 'httpd.pid';
}
sub dversion {
my $self = shift;
my $dv = "-D APACHE$self->{rev}";
if ($self->{rev} == 2 and $self->{revminor} == 4) {
$dv .= " -D APACHE2_4";
}
return $dv;
}
sub config_defines {
my $self = shift;
my @defines = ();
for my $item (qw(useithreads)) {
next unless $Config{$item} and $Config{$item} eq 'define';
push @defines, "-D PERL_\U$item";
}
if (my $defines = $self->{config}->{vars}->{defines}) {
push @defines, map { "-D $_" } split " ", $defines;
}
"@defines";
}
sub args {
my $self = shift;
my $vars = $self->{config}->{vars};
my $dversion = $self->dversion; #for .conf version conditionals
my $defines = $self->config_defines;
"-d $vars->{serverroot} -f $vars->{t_conf_file} $dversion $defines";
( run in 0.315 second using v1.01-cache-2.11-cpan-acf6aa7dc9e )