add guards to app server management methods to save callers needing to check if they...
Matt S Trout [Wed, 22 Jun 2011 12:56:46 +0000 (13:56 +0100)]
lib/Test/Harness/Selenium.pm

index 99ffe43..3937119 100644 (file)
@@ -128,13 +128,16 @@ sub stop_selenium_server {
 
 sub start_app_server {
   my($self) = @_;
+  return unless $self->{app_server_cmd};
   my $child = Child->new(sub { exec($self->{app_server_cmd}) } );
   $self->{app_server_proc} = $child->start;
 }
 
 sub stop_app_server {
   my($self) = @_;
-  $self->{app_server_proc}->kill("KILL");
+  if (my $proc = $self->{app_server_proc}) {
+    $proc->kill("KILL");
+  }
 }
 
 sub test_directory {
@@ -171,13 +174,12 @@ sub get_rows_for {
 
 sub done {
   my($self) = @_;
-  if(exists $self->{selenium_rc}{xvnc_server_proc} and 
-    exists $self->{selenium_rc}{selenium_server_proc}) {
-    $self->stop_selenium_server;
-  }
+  $self->stop_selenium_server;
   $self->stop_app_server;
 }
 
+sub DESTROY { shift->done }
+
 1;
 
 __END__