Apache-Test
view release on metacpan or search on metacpan
lib/Apache/TestConfig.pm view on Meta::CPAN
$obj;
}
1;
EOF
close $fh or die "failed to write $file: $!";
}
sub as_string {
my $cfg = '';
my $command = '';
# httpd opts
my $test_config = Apache::TestConfig->new({thaw=>1});
# XXX: need to run httpd config to get the value of httpd
if (my $httpd = $test_config->{vars}->{httpd}) {
$httpd = shell_ready($httpd);
$command = "$httpd -V";
$cfg .= "\n*** $command\n";
$cfg .= qx{$command};
$cfg .= ldd_as_string($httpd);
}
else {
$cfg .= "\n\n*** The httpd binary was not found\n";
}
# perl opts
my $perl = shell_ready($^X);
$command = "$perl -V";
$cfg .= "\n\n*** $command\n";
$cfg .= qx{$command};
return $cfg;
}
sub ldd_as_string {
my $httpd = shift;
my $command;
if (OSX) {
my $otool = which('otool');
$command = "$otool -L $httpd" if $otool;
}
elsif (!WIN32) {
my $ldd = which('ldd');
$command = "$ldd $httpd" if $ldd;
}
my $cfg = '';
if ($command) {
$cfg .= "\n*** $command\n";
$cfg .= qx{$command};
}
return $cfg;
}
# make a string suitable for feed to shell calls (wrap in quotes and
# escape quotes)
sub shell_ready {
my $arg = shift;
$arg =~ s!\\?"!\\"!g;
return qq["$arg"];
}
1;
=head1 NAME
Apache::TestConfig -- Test Configuration setup module
=head1 SYNOPSIS
use Apache::TestConfig;
my $cfg = Apache::TestConfig->new(%args)
my $fh = $cfg->genfile($file);
$cfg->writefile($file, $content);
$cfg->gendir($dir);
...
=head1 DESCRIPTION
C<Apache::TestConfig> is used in creating the C<Apache::Test>
configuration files.
=head1 FUNCTIONS
=over
=item genwarning()
my $warn = $cfg->genwarning($filename)
genwarning() returns a warning string as a comment, saying that the
file was autogenerated and that it's not a good idea to modify this
file. After the warning a perl trace of calls to this this function is
appended. This trace is useful for finding what code has created the
file.
my $warn = $cfg->genwarning($filename, $from_filename)
If C<$from_filename> is specified it'll be used in the warning to tell
which file it was generated from.
genwarning() automatically recognizes the comment type based on the
file extension. If the extension is not recognized, the default C<#>
style is used.
Currently it support C<E<lt>!-- --E<gt>>, C</* ... */> and C<#>
styles.
=item genfile()
my $fh = $cfg->genfile($file);
genfile() creates a new file C<$file> for writing and returns a file
handle.
( run in 0.563 second using v1.01-cache-2.11-cpan-39bf76dae61 )