From: Dagfinn Ilmari Mannsåker Date: Fri, 24 May 2013 21:39:19 +0000 (+0100) Subject: Fix waiting for the server to start in t/author/http-server.t X-Git-Tag: 5.90040~3^2~9 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=a526c982f02435e4592256848c679c473ea57b4b;hp=cc66256716f67b2866a800fd6c99b126f379422d Fix waiting for the server to start in t/author/http-server.t Use Net::EmptyPort directly, since we don't need any of the actual testing stuff from Test::TCP. This also lets us control the sleep interval and retries, so we don't have to loop ourselves as well. Net::EmptyPort started exporting wait_port in 1.27, but doesn't have a $VERSION of its own, so declare the author dependency on Net::TCP 1.27. --- diff --git a/Changes b/Changes index ac27f9c..3c88749 100644 --- a/Changes +++ b/Changes @@ -11,6 +11,7 @@ TBA with event loops. - lets you access a psgix.io socket, if your server supports it, for manual handling of the client - server communication, such as for websockets. + - Fix waiting for the server to start in t/author/http-server.t 5.90030 - 2013-04-12 ! POSSIBLE BREAKING CHANGE: Removed Regexp dispatch type from core, and put diff --git a/Makefile.PL b/Makefile.PL index f25c082..a37f617 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -94,6 +94,7 @@ else { push(@author_requires, 'CatalystX::LeakChecker', '0.05'); push(@author_requires, 'Catalyst::Devel', '1.0'); # For http server test +push(@author_requires, 'Test::TCP', '1.27'); # ditto, ships Net::EmptyPort author_tests('t/author'); author_requires( diff --git a/t/author/http-server.t b/t/author/http-server.t index ead1cad..7f886ca 100644 --- a/t/author/http-server.t +++ b/t/author/http-server.t @@ -5,7 +5,7 @@ use Test::More tests => 1; use File::Path; use FindBin; -use Test::TCP; +use Net::EmptyPort qw(wait_port empty_port); use Try::Tiny; use Plack::Builder; @@ -96,10 +96,7 @@ if ($^O eq 'MSWin32') { sub wait_port_timeout { my ($port, $timeout) = @_; - # wait_port waits for 10 seconds - for (1 .. int($timeout / 10)) { # meh, good enough. - try { wait_port $port; 1 } and return; - } + wait_port($port, 0.1, $timeout * 10) and return; die "Server did not start within $timeout seconds"; }