Author: stas
Date: Mon Dec 20 07:10:15 2004
New Revision: 122855

URL: http://svn.apache.org/viewcvs?view=rev&rev=122855
Log:
refactor some dups into find_and_load_module() wrapper
Contributed by: Chia-Liang Kao <[EMAIL PROTECTED]>

Modified:
   httpd/test/trunk/perl-framework/Apache-Test/Changes
   httpd/test/trunk/perl-framework/Apache-Test/lib/Apache/TestConfig.pm

Modified: httpd/test/trunk/perl-framework/Apache-Test/Changes
Url: 
http://svn.apache.org/viewcvs/httpd/test/trunk/perl-framework/Apache-Test/Changes?view=diff&rev=122855&p1=httpd/test/trunk/perl-framework/Apache-Test/Changes&r1=122854&p2=httpd/test/trunk/perl-framework/Apache-Test/Changes&r2=122855
==============================================================================
--- httpd/test/trunk/perl-framework/Apache-Test/Changes (original)
+++ httpd/test/trunk/perl-framework/Apache-Test/Changes Mon Dec 20 07:10:15 2004
@@ -8,6 +8,10 @@
   
 =item 1.18-dev
 
+
+new TestConfig wrapper find_and_load_module [Chia-Liang Kao <chialiang
+gmail.com>]
+
 add Apache-TestItSelf and Apache-TestMe sub-projects. [Stas]
 
 add various straps to aid the new Apache-TestItSelf sub-project, which

Modified: httpd/test/trunk/perl-framework/Apache-Test/lib/Apache/TestConfig.pm
Url: 
http://svn.apache.org/viewcvs/httpd/test/trunk/perl-framework/Apache-Test/lib/Apache/TestConfig.pm?view=diff&rev=122855&p1=httpd/test/trunk/perl-framework/Apache-Test/lib/Apache/TestConfig.pm&r1=122854&p2=httpd/test/trunk/perl-framework/Apache-Test/lib/Apache/TestConfig.pm&r2=122855
==============================================================================
--- httpd/test/trunk/perl-framework/Apache-Test/lib/Apache/TestConfig.pm        
(original)
+++ httpd/test/trunk/perl-framework/Apache-Test/lib/Apache/TestConfig.pm        
Mon Dec 20 07:10:15 2004
@@ -1212,6 +1212,18 @@
     };
 }
 
+sub find_and_load_module {
+    my ($self, $name) = @_;
+    my $mod_path = $self->find_apache_module($name) or return;
+    my ($sym) = $name =~ m/mod_(\w+)\./;
+
+    if ($mod_path && -e $mod_path) {
+        $self->preamble(IfModule => "!$name",
+                        qq{LoadModule ${sym}_module "$mod_path"\n});
+    }
+    return 1;
+}
+
 sub replace_vhost_modules {
     my $self = shift;
 
@@ -1265,11 +1277,7 @@
 
     # handle the case when mod_mime is built as a shared object
     # but wasn't included in the system-wide httpd.conf
-    my $mod_mime = $self->find_apache_module('mod_mime.so');
-    if ($mod_mime && -e $mod_mime) {
-        $self->preamble(IfModule => '!mod_mime.c',
-                        qq{LoadModule mime_module "$mod_mime"\n});
-    }
+    $self->find_and_load_module('mod_mime.so');
 
     unless ($self->{inherit_config}->{TypesConfig}) {
         my $types = catfile $self->{vars}->{t_conf}, 'mime.types';
@@ -1521,6 +1529,8 @@
 
     my $out = $self->genfile($conf_file);
 
+    $self->find_and_load_module('mod_alias.so');
+
     $self->preamble_run($out);
 
     for my $name (qw(user group)) { #win32/cygwin do not support
@@ -1542,14 +1552,6 @@
 
     # handle the case when mod_alias is built as a shared object
     # but wasn't included in the system-wide httpd.conf
-    my $mod_alias = $self->find_apache_module('mod_alias.so');
-    if ($mod_alias && -e $mod_alias) {
-        print $out <<EOF;
-<IfModule !mod_alias.c>
-    LoadModule alias_module "$mod_alias"
-</IfModule>
-EOF
-    }
 
     print $out "<IfModule mod_alias.c>\n";
     for (keys %aliases) {

Reply via email to