poked at t/start_dev_server.t
[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;
615fee7c 10use Catalyst::Test 'TestApp', {default_host => 'default.com'};
11use Catalyst::Request;
a24a5860 12use Test::WWW::Mechanize;
a3ca4468 13BEGIN {
14 $ENV{CATALYST_ENGINE} ||= 'HTTP';
15 $ENV{CATALYST_SCRIPT_GEN} = 31;
16 require Catalyst::Engine::HTTP;
17}
a24a5860 18my $dir = tempdir(); # CLEANUP => 1 );
19my $devnull = File::Spec->devnull;
20
21my $server_path = File::Spec->catfile('script', 'testapp_server.pl');
22my $port = int(rand(10000)) + 40000; # get random port between 40000-50000
23
24my $childpid = fork();
25die "fork() error, cannot continue" unless defined($childpid);
26
27if ($childpid == 0) {
615fee7c 28 system("$^X $server_path --listen $port > $devnull 2>&1");
a24a5860 29 exit; # just for sure; we should never got here
30}
31
32sleep 10; #wait for catalyst application to start
33my $mech = Test::WWW::Mechanize->new;
34$mech->get_ok( "http://localhost:" . $port );
35
36kill 'KILL', $childpid;
37
38