X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=t%2Foptional%2Fapache-fastcgi.pl;h=ec7e77ec6f65cf4b79d7096af03878cc10ab4904;hp=68f095c4a2113780a7fb5330023a044e2e8b1785;hb=e2a248924a4f84d01ee7e6ba2bbfd715d1187947;hpb=fb9b4097e68731458806e9f2e6d699c6a2b16ad4 diff --git a/t/optional/apache-fastcgi.pl b/t/optional/apache-fastcgi.pl index 68f095c..ec7e77e 100755 --- a/t/optional/apache-fastcgi.pl +++ b/t/optional/apache-fastcgi.pl @@ -16,6 +16,7 @@ use Apache::TestRun (); use File::Path; use File::Copy::Recursive; use FindBin; +use IO::Socket; # clean up rmtree "$FindBin::Bin/../../t/tmp" if -d "$FindBin::Bin/../../t/tmp"; @@ -34,5 +35,25 @@ $ENV{CATALYST_SERVER} = 'http://localhost:8529/fastcgi'; Apache::TestRun->new->run(@ARGV); -# clean up -rmtree "$FindBin::Bin/../../t/tmp" if -d "$FindBin::Bin/../../t/tmp"; +# clean up if the server has shut down +# this allows the test files to stay around if the user ran -start-httpd +if ( ! check_port( 'localhost', 8529 ) ) { + rmtree "$FindBin::Bin/../../t/tmp" if -d "$FindBin::Bin/../../t/tmp"; +} + +sub check_port { + my ( $host, $port ) = @_; + + my $remote = IO::Socket::INET->new( + Proto => "tcp", + PeerAddr => $host, + PeerPort => $port + ); + if ($remote) { + close $remote; + return 1; + } + else { + return 0; + } +}