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