this patch allow's mod_perl's Makefile.PL to detect if Apache::Test is 
installed and switch over to if for it's tests.  It means apxs/dso builds 
can now make tests like everything else.

I suspect this would also kinda work under win32 (possibly with small tweaks).

If Apache::Test isn't found, it just tells the users about the goodness of Apache::Test
and reverts back to the old mechanism.

Index: Makefile.PL
===================================================================
RCS file: /home/cvs/modperl/Makefile.PL,v
retrieving revision 1.216
diff -b -B -u -r1.216 Makefile.PL
--- Makefile.PL 19 Aug 2003 05:07:44 -0000      1.216
+++ Makefile.PL 22 Aug 2003 23:41:21 -0000
@@ -25,6 +25,15 @@
 use Cwd;
 use File::Copy qw(cp);
 
+#We need to check early
+eval {
+    require Apache::TestMM;
+    require Apache::TestRunPerl;
+};
+if(!$@) { 
+    $APACHE_TEST++ 
+}
+
 #use Apache::ExtUtils qw(%Config);
 
 unless (%Config) {
@@ -168,7 +177,7 @@
 
 gen_script("t/net/perl/cgi.pl");
 gen_script("t/report");
-gen_script("t/TEST");
+gen_script("t/TEST") unless $APACHE_TEST;
 gen_script("apaci/find_source");
 gen_script("apaci/apxs_cflags");
 gen_script("apaci/perl_config", "$PWD/lib");
@@ -914,7 +923,7 @@
        push @test_pre_init, 
        "\t", '$(CP) t/conf/mod_perl_srm.conf t/conf/srm.conf', "\n";
     }
-    unless ($USE_APXS) {
+    unless ($USE_APXS && !$APACHE_TEST) {
        unless (-l "t/httpd" or $Is_Win32) {
            system "$Config{lns} $APACHE_SRC/httpd t/httpd";
        }
@@ -1183,6 +1192,18 @@
     }
 }
 
+    print "Checking for Apache::Test........";
+    if (!$APACHE_TEST) {
+       print "failed\n";
+       print <<EOT;
+The Apache::Test package is not installed. It is not needed to run the test suite, 
+BUT installing it will improve the underlying test suite.
+EOT
+    sleep(2);  # Don't hurry too much
+    } else {
+       print "ok\n";
+    }
+
 sub is_ssl {
     my $d = shift || $APACHE_SRC;
     for (keys %SSL) {
@@ -1304,6 +1325,27 @@
 
 cleanup_for_static();
 
+if ($APACHE_TEST) {
+    require File::Spec;
+
+    my @server;
+
+    my @documentroot = ('-documentroot', 
File::Spec->rel2abs(File::Spec->catdir(File::Spec->curdir, 't','docs')));
+    my @libmodperl = ('-libmodperl', 
File::Spec->rel2abs(File::Spec->catdir(File::Spec->curdir, 'apaci', 'libperl.so')));
+    if($USE_APXS) {
+        @server = ('-apxs', File::Spec->rel2abs($WITH_APXS));
+    }
+    else {
+        @server = ('-httpd', 
File::Spec->rel2abs(File::Spec->catfile($APACHE_SRC,$TARGET)));
+    }
+
+    local @ARGV = (@server, @documentroot, @libmodperl);
+
+    use Data::Dumper; print Dumper [EMAIL PROTECTED];
+    Apache::TestMM::filter_args();
+    Apache::TestRunPerl->generate_script();
+}
+
 sub MY::dist_basics {
     my $self = shift;
     my $string = $self->MM::dist_basics;
@@ -1466,6 +1508,7 @@
     my $self = shift;
     my $test = $self->MM::test;
     my $mmn = magic_number($APACHE_SRC);
+    unless($APACHE_TEST) {
     return <<'EOF' if $USE_APXS and not $Is_dougm;
 test:
        @echo "Can't make test with APXS (yet)"
@@ -1474,6 +1517,7 @@
 test:
        @echo "Can't make test with DSO (yet)"
 EOF
+    }
 
     my $script = "t/TEST";
     $script .= ".win32" if $Is_Win32;
@@ -1491,39 +1535,56 @@
     my $have_so = $USE_DSO || ($APACI_ARGS =~ /--enable-shared=/); 
     push @test_pre_init, "\t", 
     './apaci/load_modules.pl $(APACHE_SRC)', "\n" if $have_so;
+    my ($start_httpd, $stop_httpd, $run_tests);
+    if($APACHE_TEST) {
+        $start_httpd = '$(FULLPERL) $(MP_TEST_SCRIPT) -verbose=$(TEST_VERBOSE) 
-start';
+        $stop_httpd = '$(FULLPERL) $(MP_TEST_SCRIPT) -verbose=$(TEST_VERBOSE) -stop';
+        $run_tests = '$(FULLPERL) $(MP_TEST_SCRIPT) -ping && $(FULLPERL) 
$(MP_TEST_SCRIPT) -run -verbose=$(TEST_VERBOSE)';
+    }
+    else {
+        $start_httpd = <<'EOF';
+       @(cd t/conf; test -f httpd.conf || cp httpd.conf-dist httpd.conf)
+       @(cd t/net; test -f config.pl || cp config.pl.dist config.pl)
+       @$(TOUCH) t/conf/srm.conf
+       $(APACHE_SRC)/$(HTTPD) -f `pwd`/t/conf/httpd.conf -X -d `pwd`/t &
+       @echo httpd listening on port $(PORT)
+       @echo will write error_log to: t/logs/error_log
+       @echo "letting apache warm up...\c"
+       @sleep 2
+       @echo done
+EOF
+        $stop_httpd = <<'EOF';
+       kill `cat t/logs/httpd.pid`
+       @$(RM_F) t/conf/srm.conf
+       @$(RM_F) t/logs/mod_perl.lock*
+       $(RM_F) t/logs/httpd.pid
+       $(RM_F) t/logs/error_log  
+EOF
+        $run_tests = <<'EOF';
+       $(FULLPERL) $(MP_TEST_SCRIPT) $(TEST_VERBOSE)
+EOF
+    }
  
     join '', @test_pre_init,
     qq(
 MP_TEST_SCRIPT=$script
 ),
-    q(
+    qq(
 TEST_VERBOSE=0
 
 kill_httpd:
-       kill `cat t/logs/httpd.pid`
-       @$(RM_F) t/conf/srm.conf
-       @$(RM_F) t/logs/mod_perl.lock*
-       $(RM_F) t/logs/httpd.pid
-       $(RM_F) t/logs/error_log
+       $stop_httpd
 
 start_httpd: test_pre_init
-       @(cd t/conf; test -f httpd.conf || cp httpd.conf-dist httpd.conf)
-       @(cd t/net; test -f config.pl || cp config.pl.dist config.pl)
-       @$(TOUCH) t/conf/srm.conf
-       $(APACHE_SRC)/$(HTTPD) -f `pwd`/t/conf/httpd.conf -X -d `pwd`/t &
-       @echo httpd listening on port $(PORT)
-       @echo will write error_log to: t/logs/error_log
-       @echo "letting apache warm up...\c"
-       @sleep 2
-       @echo done
+       $start_httpd
 
 start_httpd_fork:
-       $(APACHE_SRC)/$(HTTPD) -f `pwd`/t/conf/httpd.conf -d `pwd`/t
+       $stop_httpd
 
 rehttpd:   kill_httpd start_httpd
 
 run_tests:
-       $(FULLPERL) $(MP_TEST_SCRIPT) $(TEST_VERBOSE)
+       $run_tests
 
 ),
 

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to