Module-Generic
view release on metacpan or search on metacpan
Makefile.PL view on Meta::CPAN
@scripts = qw( t/TEST );
# accept the configs from command line
Apache::TestMM::filter_args();
my $ref = {@Apache::TestMM::Argv};
$ref->{_HAS_APACHE_TEST} = 1;
my $config = Apache::TestConfig->thaw->httpd_config;
my( $has_ssl, $has_perl_ssl, $has_error ) = ( 0, '', 0 );
$ref->{_HAS_SSL} = 0;
# require Data::Pretty;
if( $MY_DEBUG > 2 )
{
require Data::Pretty;
print( STDERR "Apache::TestConfig->thaw->httpd_config yields: ", Data::Pretty::dump( $config ), "\n" );
}
if( ref( $config ) eq 'Apache::TestConfig' )
{
$has_ssl = $config->{modules}->{ $config->{vars}->{ssl_module} } ? 1 : 0;
my $apache_bin = $config->{vars}->{httpd};
if( !$apache_bin )
{
local $@;
eval
{
require File::Which;
};
if( !$@ )
{
for( qw( apache2 httpd ) )
{
if( $apache_bin = File::Which::which( $_ ) )
{
print( STDERR "Found Apache binary at $apache_bin" ) if( $MY_DEBUG );
last;
}
}
}
}
my $cmd = '';
if( $apache_bin )
{
print( STDERR "Checking Apache2 configuration with binary $apache_bin\n" ) if( $MY_DEBUG );
$cmd .= ". $config->{vars}->{conf_dir}/envvars; " if( $config->{vars}->{conf_dir} && -e( "$config->{vars}->{conf_dir}/envvars" ) );
$cmd .= $apache_bin;
open( my $io, "${cmd} -M 2>&1|" );
while( <$io> )
{
print( STDERR $_ ) if( $MY_DEBUG );
$has_ssl++, last if( /ssl/i );
if( /Syntax[[:blank:]]+error[[:blank:]]+(?:on|at)[[:blank:]]+line[[:blank:]]+(\d+)/i )
{
$has_error = $1;
}
}
close( $io );
print( STDERR "# Done\n" ) if( $MY_DEBUG );
}
warn( "[warning] You have syntax error in your Apache configuration file at line $has_error. You might want to do an apache2ctl configtest or (${cmd} -t)\n" ) if( $has_error );
print( STDERR "Checking for SSL modules IO::Socket::SSL or Net::SSL\n" ) if( $MY_DEBUG );
# IO::Socket::SSL or Net::SSL
local $@;
eval( 'require IO::Socket::SSL' );
if( $@ )
{
my $io_ssl_err = $@;
eval( 'require Net::SSL' );
unless( $@ )
{
$has_perl_ssl = 'Net::SSL';
}
}
else
{
$has_perl_ssl = 'IO::Socket::SSL';
}
if( $has_ssl && $has_perl_ssl )
{
print( STDERR "Found Apache module mod_ssl enabled and $has_perl_ssl module installed. Ok\n" ) if( $MY_DEBUG );
$ref->{_HAS_SSL} = 1;
}
elsif( $has_ssl && !$has_perl_ssl )
{
print( STDERR "Found Apache module mod_ssl enabled, but missing perl modules (either IO::Socket::SSL or Net::SSL)\n" ) if( $MY_DEBUG );
}
elsif( !$has_ssl && $has_perl_ssl )
{
print( STDERR "Apache module mod_ssl is not enabled, but found $has_perl_ssl\n" ) if( $MY_DEBUG );
}
else
{
print( STDERR "Apache module mod_ssl is not enabled and could not find either IO::Socket::SSL nor Net::SSL, deactivating the use of SSL for our tests.\n" ) if( $MY_DEBUG );
}
}
print( STDERR "apxs specified? ", ( $ref->{apxs} ? "yes at $ref->{apxs}" : 'no' ), "\n" ) if( $MY_DEBUG );
if( !$ref->{apxs} )
{
my $apxs;
local $@;
eval
{
require File::Spec;
};
if( $@ )
{
die( "You are missing somehow the core module File::Spec\n" );
}
eval
{
require File::Which;
};
if( $@ )
{
die( "You are missing somehow the core module File::Which\n" );
}
eval
{
require Apache2::BuildConfig;
};
# perl -MApache2::BuildConfig -MData::Pretty -lE 'my $c=Apache2::BuildConfig->new; say Data::Pretty::dump($c)'
if( !$@ )
{
my $build = Apache2::BuildConfig->new;
$apxs = File::Spec->catfile( $build->{APXS_BINDIR}, 'apxs' ) if( $build->{APXS_BINDIR} );
undef( $apxs ) unless( -e( $apxs ) );
print( STDERR "Found apxs at $apxs\n" ) if( $MY_DEBUG );
}
else
{
print( STDERR "Failed loading Apache2::BuildConfig: $@\n" ) if( $MY_DEBUG );
}
if( !$apxs )
{
print( STDERR "Trying to find apxs using File::Which...\n" ) if( $MY_DEBUG );
local $@;
eval
{
require File::Which;
};
if( !$@ && ( $apxs = File::Which::which( 'apxs' ) ) )
{
$ref->{apxs} = $apxs;
print( STDERR "Found apxs at $apxs" ) if( $MY_DEBUG );
}
}
if( $apxs )
{
( run in 2.895 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )