Fix waiting for the server to start in t/author/http-server.t
[catagits/Catalyst-Runtime.git] / t / author / http-server.t
index 2927f18..7f886ca 100644 (file)
@@ -5,12 +5,19 @@ 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;
 
-use Catalyst::Devel 1.0;
-use File::Copy::Recursive;
+eval { require Catalyst::Devel; Catalyst::Devel->VERSION(1.0); 1; } || do {
+    fail("Could not load Catalyst::Devel: $@");
+    exit 1;
+};
+
+eval { require File::Copy::Recursive; 1 } || do {
+    fail("Could not load File::Copy::Recursive: $@");
+    exit 1;
+};
 
 # Run a single test by providing it as the first arg
 my $single_test = shift;
@@ -89,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";
 }