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