hi all...

I've found it necessary to toggle single server mode when using Apache-Test,
specifically for getting Devel::Cover to work with mod_perl 1.0 nicely.  so,
I'd like to add an option for switching back to single server mode on demand
for a normal run.

the problem is that TestServer, which controls how the server is started,
does not have access to TestRun parsed configuration options.  TestServer
has access to TestConfig options, but all of those take arguments and
persist until the next time you run -clean, which isn't desirable.

we've run into this issue before, wanting to give TestServer access to
per-run directives, but we never really had a decent solution.  this one
just adds an Apache::TestRun object to the Apache::TestServer hash at the
appropriate times, which TestServer can then use if it so chooses.  other
solutions welcome.

--Geoff
Index: Apache/TestServer.pm
===================================================================
RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestServer.pm,v
retrieving revision 1.85
diff -u -r1.85 TestServer.pm
--- Apache/TestServer.pm	6 Aug 2004 18:20:42 -0000	1.85
+++ Apache/TestServer.pm	22 Sep 2004 01:57:10 -0000
@@ -159,10 +159,20 @@
 my %one_process = (1 => '-X', 2 => '-D ONE_PROCESS');
 
 sub start_cmd {
-    my $self = shift;
+    my $self   = shift;
+
+    my $args   = $self->args;
+    my $config = $self->{config};
+    my $vars   = $config->{vars};
+    my $httpd  = $vars->{httpd};
+
+    my $one_process = $self->{run}->{opts}->{'one-process'} ? 
+                      $self->version_of(\%one_process)      : 
+                      '';
+
     #XXX: threaded mpm does not respond to SIGTERM with -D ONE_PROCESS
-    my $args = $self->args;
-    return "$self->{config}->{vars}->{httpd} $args";
+
+    return "$httpd $one_process $args";
 }
 
 sub default_gdbinit {
Index: Apache/TestRun.pm
===================================================================
RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestRun.pm,v
retrieving revision 1.182
diff -u -r1.182 TestRun.pm
--- Apache/TestRun.pm	5 Sep 2004 00:11:30 -0000	1.182
+++ Apache/TestRun.pm	22 Sep 2004 01:57:11 -0000
@@ -48,7 +48,7 @@
 
 my @std_run      = qw(start-httpd run-tests stop-httpd);
 my @others       = qw(verbose configure clean help ssl http11 bugreport 
-                      save no-httpd);
+                      save no-httpd one-process);
 my @flag_opts    = (@std_run, @others);
 my @string_opts  = qw(order trace);
 my @ostring_opts = qw(proxy ping);
@@ -89,6 +89,7 @@
    'trace=T'         => 'change tracing default to: warning, notice, ' .
                         'info, debug, ...',
    'save'            => 'save test paramaters into Apache::TestConfigData',
+   'one-process'     => 'run the server in single process mode',
    (map { $_, "\U$_\E url" } @request_opts),
 );
 
@@ -398,6 +399,7 @@
     $self->opt_clean(1);
     $self->{conf_opts}->{save} = delete $self->{conf_opts}->{thaw} || 1;
     $self->{test_config} = $self->new_test_config()->httpd_config;
+    $self->{test_config}->{server}->{run} = $self;
     $self->{server} = $self->{test_config}->server;
 }
 
@@ -690,6 +692,10 @@
     $self->{test_config} = $self->new_test_config();
 
     $self->warn_core();
+
+    # give TestServer access to our runtime configuration directives
+    # so we can tell the server stuff if we need to
+    $self->{test_config}->{server}->{run} = $self;
 
     $self->{server} = $self->{test_config}->server;
 

Reply via email to