home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-perl-addon-1.4.9-installer.exe / TestRunPerl.pm < prev    next >
Encoding:
Perl POD Document  |  2004-08-05  |  3.0 KB  |  113 lines

  1. # Copyright 2001-2004 The Apache Software Foundation
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. #     http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. #
  15. package Apache::TestRunPerl;
  16.  
  17. use strict;
  18. use warnings FATAL => 'all';
  19.  
  20. use Apache::TestRun ();
  21. use Apache::TestConfigParse ();
  22. use Apache::TestTrace;
  23.  
  24. use vars qw($VERSION);
  25. $VERSION = '1.00'; # make CPAN.pm's r() version scanner happy
  26.  
  27. use File::Spec::Functions qw(catfile);
  28.  
  29. #subclass of Apache::TestRun that configures mod_perlish things
  30. use vars qw(@ISA);
  31. @ISA = qw(Apache::TestRun);
  32.  
  33. sub pre_configure {
  34.     my $self = shift;
  35.  
  36.     # Apache::TestConfigPerl already configures mod_perl.so
  37.     Apache::TestConfig::autoconfig_skip_module_add('mod_perl.c');
  38. }
  39.  
  40. sub configure_modperl {
  41.     my $self = shift;
  42.  
  43.     my $test_config = $self->{test_config};
  44.  
  45.     my $rev = $test_config->server->{rev};
  46.     my $ver = $test_config->server->{version};
  47.  
  48.     # sanity checking and loading the right mod_perl version
  49.     if ($rev == 2) {
  50.         eval { require Apache2 && require mod_perl };
  51.     } else {
  52.         eval { require mod_perl };
  53.     }
  54.     if ($@) {
  55.         error "You are using mod_perl response handlers ",
  56.             "but do not have a mod_perl capable Apache.";
  57.         Apache::TestRun::exit_perl(0);
  58.     }
  59.     if (($rev == 1 and $mod_perl::VERSION >= 1.99) ||
  60.         ($rev == 2 and $mod_perl::VERSION < 1.99)) {
  61.         error "Found mod_perl/$mod_perl::VERSION, " .
  62.             "but it can't be used with $ver";
  63.         Apache::TestRun::exit_perl(0);
  64.     }
  65.  
  66.     $test_config->preamble_register(qw(configure_libmodperl));
  67.  
  68.     $test_config->postamble_register(qw(configure_inc
  69.                                         configure_trace
  70.                                         configure_pm_tests_inc
  71.                                         configure_startup_pl
  72.                                         configure_pm_tests));
  73. }
  74.  
  75. sub configure {
  76.     my $self = shift;
  77.  
  78.     $self->configure_modperl;
  79.  
  80.     $self->SUPER::configure;
  81. }
  82.  
  83. #if Apache::TestRun refreshes config in the middle of configure
  84. #we need to re-add modperl configure hooks
  85. sub refresh {
  86.     my $self = shift;
  87.     $self->SUPER::refresh;
  88.     $self->configure_modperl;
  89. }
  90.  
  91. 1;
  92. __END__
  93.  
  94. =head1 NAME
  95.  
  96. Apache::TestRunPerl - Run mod_perl-requiring Test Suite
  97.  
  98. =head1 SYNOPSIS
  99.  
  100.   use Apache::TestRunPerl;
  101.   Apache::TestRunPerl->new->run(@ARGV);
  102.  
  103. =head1 DESCRIPTION
  104.  
  105. The C<Apache::TestRunPerl> package controls the configuration and
  106. running of the test suite. It's a subclass of C<Apache::TestRun>, and
  107. should be used only when you need to run mod_perl tests.
  108.  
  109. Refer to the C<Apache::TestRun> manpage for information on the
  110. available API.
  111.  
  112. =cut
  113.