added a test application to get the new scripts working
[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
13 my $dir = tempdir(); # CLEANUP => 1 );
14 my $devnull = File::Spec->devnull;
15
16 my $server_path   = File::Spec->catfile('script', 'testapp_fastcgi.pl');
17 my $port = int(rand(10000)) + 40000; # get random port between 40000-50000
18
19 my $childpid = fork();
20 die "fork() error, cannot continue" unless defined($childpid);
21
22 if ($childpid == 0) {
23   system("$^X $server_path -p $port > $devnull 2>&1");
24   exit; # just for sure; we should never got here
25 }
26
27 sleep 10; #wait for catalyst application to start
28 my $mech = Test::WWW::Mechanize->new;
29 $mech->get_ok( "http://localhost:" . $port );
30
31 kill 'KILL', $childpid;
32
33