From: Chris Nehren Date: Fri, 15 Apr 2011 09:35:38 +0000 (-0400) Subject: Remove spurious old tests. Clean up process handling. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e5f319fcec7fb0484e237061aa80846503569654;p=scpubgit%2FTest-Harness-Selenium.git Remove spurious old tests. Clean up process handling. --- diff --git a/lib/Test/Harness/Selenium.pm b/lib/Test/Harness/Selenium.pm index dc4d936..34187b2 100644 --- a/lib/Test/Harness/Selenium.pm +++ b/lib/Test/Harness/Selenium.pm @@ -48,19 +48,19 @@ sub new { sub start_selenium_server { my($self) = @_; if($self->{selenium_rc}{start}) { - $self->{selenium_rc}{xvnc_server_proc} = Child->new(sub { + my $child = Child->new(sub { system('ssh', $self->{selenium_rc}{host}, 'vncserver', ":$self->{selenium_rc}{xvnc_display}"); } ); - $self->{selenium_rc}{xvnc_server_proc}->start; - $self->{selenium_rc}{selenium_server_proc} = Child->new(sub { + $self->{selenium_rc}{xvnc_server_proc} = $child->start; + $child = Child->new(sub { system('ssh', $self->{selenium_rc}{host}, 'env', "DISPLAY=:$self->{selenium_rc}{xvnc_display}", 'selenium-rc', '-port', $self->{selenium_rc}{port} ); } ); - $self->{selenium_rc}{selenium_server_proc}->start; + $self->{selenium_rc}{selenium_server_proc} = $child->start; } my $tries = 0; while($tries < 5) { @@ -80,8 +80,11 @@ sub start_selenium_server { last; } } - die "timed out waiting for selenium server to start at - http://$self->{selenium_rc}{host}:$self->{selenium_rc}{port}" if $tries == 5; + if($tries == 5) { + diag "timed out waiting for selenium server to start at + http://$self->{selenium_rc}{host}:$self->{selenium_rc}{port}" if $tries == 5; + $self->done; + } } sub stop_selenium_server { @@ -92,19 +95,25 @@ sub stop_selenium_server { $self->{selenium_rc}{host}, $self->{selenium_rc}{port}; get($url); delete $self->{src}; - $self->{selenium_rc}{selenium_server_proc}->wait; - $self->{selenium_rc}{xvnc_server_proc}->wait; + $self->{selenium_rc}{selenium_server_proc}->kill("KILL"); + my $child = Child->new(sub { + system('ssh', $self->{selenium_rc}{host}, 'vncserver', '-kill', + ":$self->{selenium_rc}{xvnc_display}"); + } + ); + my $proc = $child->start; + $proc->wait; } sub start_app_server { my($self) = @_; - $self->{app_server_proc} = Child->new(sub { exec($self->{app_server_cmd}) } ); - $self->{app_server_proc}->start; + 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}->complete || $self->{app_server_proc}->kill("KILL"); + $self->{app_server_proc}->kill("KILL"); } sub test_directory { @@ -139,14 +148,11 @@ sub get_rows_for { return \@rows; } -sub DESTROY { +sub done { my($self) = @_; if(exists $self->{selenium_rc}{xvnc_server_proc} and exists $self->{selenium_rc}{selenium_server_proc}) { - $self->{selenium_rc}{xvnc_server_proc}->complete || - $self->{selenium_rc}{xvnc_server_proc}->kill("KILL"); - $self->{selenium_rc}{selenium_server_proc}->complete || - $self->{selenium_rc}{selenium_server_proc}->kill("KILL"); + $self->stop_selenium_server; } $self->stop_app_server; } diff --git a/t/basic.t b/t/basic.t deleted file mode 100644 index 303599b..0000000 --- a/t/basic.t +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/perl -use strict; -use warnings; - -use lib 'lib'; -use Test::Harness::Selenium; -use Test::More; - -my $s = Test::Harness::Selenium->new({ - host => 'localhost', - port => $< + 60_000, - browser_url => 'http://www.google.com', - browser => shift, -}); -$s->test_directory(shift); -done_testing; diff --git a/t/catapp.t b/t/catapp.t index ee9e631..603f1e6 100644 --- a/t/catapp.t +++ b/t/catapp.t @@ -18,5 +18,6 @@ my $s = Test::Harness::Selenium->new( app_server_cmd => 'examples/THSelenium-Test/script/thselenium_test_server.pl', browser => '*firefox', ); -$s->test_directory('t/corpus/'); +eval { $s->test_directory('t/corpus/') }; +$s->done; done_testing; diff --git a/t/catapppass.t b/t/catapppass.t deleted file mode 100644 index 8406d1c..0000000 --- a/t/catapppass.t +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/perl -use strict; -use warnings; - -use lib 'lib'; -use Test::Harness::Selenium; -use Test::More; - -my $browser = shift; -my $s = Test::Harness::Selenium->new({ - host => 'localhost', - port => $< + 60_000, - browser_url => 'http://127.0.0.1:3000', - browser => $browser, -}); -$s->start_server; -$s->run_tests_for('t/corpus/thseleniumpass.html'); -$s->stop_server; -done_testing; diff --git a/t/vnc.t b/t/vnc.t deleted file mode 100644 index c333286..0000000 --- a/t/vnc.t +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/perl -use strict; -use warnings; - -use lib 'lib'; -use Test::Harness::Selenium; -use Test::More; - -my $s = Test::Harness::Selenium->new({ - host => 'localhost', - port => $< + 60_000, - browser_url => 'http://www.google.com', - browser => shift, - xvnc => ':0', -}); -$s->test_directory(shift); -done_testing;