cleaned up sub runner
[catagits/Catalyst-Runtime.git] / t / start_fcgi.t
CommitLineData
cc999ce2 1use Test::More tests => 1;
2use strict;
3use warnings;
4
5BEGIN { $ENV{CATALYST_ENGINE} ||= 'FastCGI' }
6use File::Temp qw/ tempdir tmpnam /;
7use FindBin qw/$Bin/;
8use File::Spec;
9use lib "$Bin/TestApp/lib";
10use TestApp;
11use Test::WWW::Mechanize;
451b2a44 12use Catalyst::Test 'TestApp';
cc999ce2 13
14my $dir = tempdir(); # CLEANUP => 1 );
15my $devnull = File::Spec->devnull;
16
17my $server_path = File::Spec->catfile('script', 'testapp_fastcgi.pl');
18my $port = int(rand(10000)) + 40000; # get random port between 40000-50000
19
20my $childpid = fork();
21die "fork() error, cannot continue" unless defined($childpid);
22
23if ($childpid == 0) {
24 system("$^X $server_path -p $port > $devnull 2>&1");
25 exit; # just for sure; we should never got here
26}
27
28sleep 10; #wait for catalyst application to start
29my $mech = Test::WWW::Mechanize->new;
30$mech->get_ok( "http://localhost:" . $port );
31
32kill 'KILL', $childpid;
33
34