From: Chris Nehren Date: Wed, 12 Jan 2011 13:48:23 +0000 (-0500) Subject: clean up forking/cleanup for clean harness testing X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=17ccdf07e4494d38662593628e97586c256d826b;p=scpubgit%2FTest-Harness-Selenium.git clean up forking/cleanup for clean harness testing --- diff --git a/lib/Test/Harness/Selenium.pm b/lib/Test/Harness/Selenium.pm index 4766a28..3590be0 100644 --- a/lib/Test/Harness/Selenium.pm +++ b/lib/Test/Harness/Selenium.pm @@ -36,9 +36,11 @@ sub new { sub start_server { my($self) = @_; - my $server_pid = fork(); - if($server_pid > 0) { - $self->{server_pid} = $server_pid; + $self->{server_pid} = fork(); + if(!defined $self->{server_pid}) { + die "can't fork: $!"; + } + if($self->{server_pid} > 0) { my $tries = 0; while($tries < 5) { eval { @@ -59,14 +61,9 @@ sub start_server { } die "timed out waiting for selenium server to start" if $tries == 5; } - elsif($server_pid == 0) { - close STDOUT; - close STDERR; + elsif($self->{server_pid} == 0) { # muttermutter, can't specify a host for selenium - Alien::SeleniumRC::start("-port $self->{port}"); - } - else { - die "can't fork: $!"; + exec("$^X -MAlien::SeleniumRC -e 'Alien::SeleniumRC::start(q{-port $self->{port}})'"); } } @@ -74,6 +71,7 @@ sub stop_server { my($self) = @_; # okay, we're done, kill the server. get("http://localhost:$self->{port}/selenium-server/driver/?cmd=shutDownSeleniumServer"); + delete $self->{src}; wait; } @@ -90,7 +88,7 @@ sub test_directory { sub run_tests_for { my ($self, $html_file) = @_; my $rows = $self->get_rows_for($html_file); - eval { $self->{src}->run_test_table($rows); }; + $self->{src}->run_test_table($rows); } my $te = HTML::TableExtract->new;