Revision: 48
Author: phred_moyer
Date: 2006-07-22 00:04:21 -0700 (Sat, 22 Jul 2006)
ViewCVS: http://svn.sourceforge.net/apache-dispatch/?rev=48&view=rev
Log Message:
-----------
- Implemented the MY:: overrides so that the build behaves well when
Apache::Test is not present. Example drawn from WebService::CaptchasDotNet,
however Apache::TestMM::generate_script was used instead of
Apache::TestRun->generate_script to get it working in this implementation.
Modified Paths:
--------------
trunk/Makefile.PL
Modified: trunk/Makefile.PL
===================================================================
--- trunk/Makefile.PL 2006-06-22 06:42:07 UTC (rev 47)
+++ trunk/Makefile.PL 2006-07-22 07:04:21 UTC (rev 48)
@@ -3,8 +3,63 @@
require 5.005;
use strict;
-use warnings FATAL => 'all';
+use constant HAS_APACHE_TEST => eval {
+ require Apache::Test;
+ require Apache::TestMM;
+
+ Apache::TestMM->import(qw(test clean));
+ Apache::TestMM::filter_args();
+
+ my %args = @Apache::TestMM::Argv;
+
+ die 'suitable httpd required'
+ unless ( $args{apxs}
+ or $args{httpd}
+ or $ENV{APACHE_TEST_HTTPD}
+ or $ENV{APACHE_TEST_APXS});
+
+ Apache::TestMM::generate_script('t/TEST');
+
+ return Apache::TestMM->test;
+};
+
+warn $@ if $@;
+
+sub MY::test {
+
+ my $test = shift->MM::test(@_);
+
+ eval { require Test::More } or return <<EOF;
+test::
+\t\@echo sorry, cannot run tests without Test::More
+EOF
+
+ return HAS_APACHE_TEST if HAS_APACHE_TEST;
+
+ if (eval { require Devel::Cover }) {
+ $test .= <<EOF;
+testcover ::
+ cover -delete
+ HARNESS_PERL_SWITCHES=-MDevel::Cover make test
+ cover
+EOF
+ }
+
+ return $test;
+}
+
+sub MY::clean {
+
+ if (HAS_APACHE_TEST) {
+ require Apache::TestMM;
+
+ return Apache::TestMM::clean(@_);
+ }
+
+ return shift->MM::clean(@_);
+}
+
## which mp version ( 1.2x or 2.0.x)
my ($mp_wanted, $mp_ver) = &get_mp_ver();
@@ -12,25 +67,11 @@
my %prereq = ('Apache::Test' => "1.23");
-my %makefile_params = (
- 'VERSION' => '0.10',
- );
+my %makefile_params = ('VERSION' => '0.10',);
-# enable "make test"
-require Apache::TestMM;
-Apache::TestMM->import(qw(test clean));
-
-# accept configs from command line.
-Apache::TestMM::filter_args();
-
-my @scripts = qw(t/TEST);
-Apache::TestMM::generate_script(@scripts);
-
-$makefile_params{clean} = {FILES => "@scripts"};
-
if ($mp_wanted == 2) { # mod_perl2 specific makefile
$prereq{'mod_perl2'} = 1.99023; # this covers the naming change
- $makefile_params{'NAME'} = 'Apache2::Dispatch';
+ $makefile_params{'NAME'} = 'Apache2::Dispatch';
$makefile_params{'PREREQ_PM'} = \%prereq;
require ModPerl::MM;
@@ -48,34 +89,34 @@
if ($@ || $ENV{DISPATCH_PUREPERL}) {
print
-"\nBuilding without Custom Apache Directives, use 'PerlSetVar' for configuration.\n\n";
+"Building without Custom Apache Directives, use 'PerlSetVar' for configuration.\n\n";
$makefile_params{'PL_FILES'} = {'set_pureperl.PL' => '1'};
$makefile_params{'C'} = [];
}
else {
- print "\nBuilding with Custom Apache Directives ('DispatchPrefix'). You
+ print "Building with Custom Apache Directives ('DispatchPrefix'). You
will need a C compiler and Apache/mod_perl sources.\n\n";
- $makefile_params{'PL_FILES'} = {'set_pureperl.PL' => '0'};
- $makefile_params{'clean'} = {FILES => '*.xs*'};
+ $makefile_params{'PL_FILES'} = {'set_pureperl.PL' => '0'};
+ $makefile_params{'clean'} = {FILES => '*.xs*'};
import Apache::ExtUtils qw(command_table);
require Apache::Dispatch::Util;
- my @directives = Apache::Dispatch::Util->directives();
+ my @directives = Apache::Dispatch::Util->directives();
command_table(\@directives);
-
- my $inc = Apache::src->new->inc;
+
+ my $inc = Apache::src->new->inc;
die "Can't find mod_perl header files installed" unless $inc;
$makefile_params{'INC'} = $inc;
- }
- $makefile_params{'PREREQ_PM'} = {mod_perl => 1.2401};
+ }
+ $makefile_params{'PREREQ_PM'} = {mod_perl => 1.2401};
require ExtUtils::MakeMaker;
ExtUtils::MakeMaker::WriteMakefile(
- NAME => __PACKAGE__,
+ NAME => __PACKAGE__,
PREREQ_PM => \%prereq,
- %makefile_params,
+ %makefile_params,
);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|