X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FTest%2FWWW%2FSelenium%2FCatalyst.pm;h=4de39a425603acf0ee4b38799554b6594cc3f889;hb=765b2b209b5b16985939956f29cdcd6aae6d9c93;hp=c87806db718880716313441a3ea8657f3ea3d9cc;hpb=a6c14dc68f42680a7dfda4eed9af846a349887c3;p=catagits%2FTest-WWW-Selenium-Catalyst.git diff --git a/lib/Test/WWW/Selenium/Catalyst.pm b/lib/Test/WWW/Selenium/Catalyst.pm index c87806d..4de39a4 100644 --- a/lib/Test/WWW/Selenium/Catalyst.pm +++ b/lib/Test/WWW/Selenium/Catalyst.pm @@ -7,6 +7,7 @@ use Alien::SeleniumRC; use Test::WWW::Selenium; use Test::More; use Catalyst::Utils; +use Catalyst::EngineLoader; BEGIN { $ENV{CATALYST_ENGINE} ||= 'HTTP'; } @@ -102,13 +103,13 @@ and it's killed when your test exits. If wish to manage a selenium server yourself, (for instance you wish to start up a server once and run a number of tests against it) pass C<-no_selenium_server> to import: - use Test::WWW::Selenium 'MyApp' + use Test::WWW::Selenium::Catalyst 'MyApp', -no_selenium_server => 1 Along a similar vein you can also pass command line arguments to the selenium server via C<-selenium_args>: - use Test::WWW::Selenium 'MyApp' + use Test::WWW::Selenium::Catalyst 'MyApp', -selenium_args => "-singleWindow -port 4445" =head2 sel_pid @@ -216,8 +217,16 @@ sub start { diag("Catalyst server $$ going down (TERM)") if $DEBUG; exit 0; }; - diag("Catalyst server running in $$") if $DEBUG; - $app->run($port, 'localhost'); + diag("Catalyst server running in pid $$ with port $port") if $DEBUG; + my $loader = Catalyst::EngineLoader->new(application_name => $app); + my $server = $loader->auto(port => $port, host => 'localhost', + server_ready => sub { + diag("Server started on port $port") if $DEBUG; + }, + ); + $app->run($port, 'localhost', $server); + + diag("Process $$ (catalyst server) exiting.") if $DEBUG; exit 1; } $uri = 'http://localhost:' . $port; @@ -278,8 +287,7 @@ END { undef $sel_pid; } elsif ($www_selenium) { - diag("Stopping Selenium Session $sel_pid") if $DEBUG; - $www_selenium->stop(); + diag("Using external Selenium server. Don't shut it down.") if $DEBUG; undef $www_selenium; }