Commit | Line | Data |
a24a5860 |
1 | use Test::More tests => 1; |
2 | use strict; |
3 | use warnings; |
4 | use Catalyst::Engine::HTTP; |
5 | use File::Temp qw/ tempdir tmpnam /; |
6 | use FindBin qw/$Bin/; |
7 | use File::Spec; |
8 | use lib "$Bin/TestApp/lib"; |
9 | use TestApp; |
615fee7c |
10 | use Catalyst::Test 'TestApp', {default_host => 'default.com'}; |
11 | use Catalyst::Request; |
a24a5860 |
12 | use Test::WWW::Mechanize; |
a3ca4468 |
13 | BEGIN { |
14 | $ENV{CATALYST_ENGINE} ||= 'HTTP'; |
15 | $ENV{CATALYST_SCRIPT_GEN} = 31; |
16 | require Catalyst::Engine::HTTP; |
17 | } |
a24a5860 |
18 | my $dir = tempdir(); # CLEANUP => 1 ); |
19 | my $devnull = File::Spec->devnull; |
20 | |
21 | my $server_path = File::Spec->catfile('script', 'testapp_server.pl'); |
22 | my $port = int(rand(10000)) + 40000; # get random port between 40000-50000 |
23 | |
24 | my $childpid = fork(); |
25 | die "fork() error, cannot continue" unless defined($childpid); |
26 | |
27 | if ($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 | |
32 | sleep 10; #wait for catalyst application to start |
33 | my $mech = Test::WWW::Mechanize->new; |
34 | $mech->get_ok( "http://localhost:" . $port ); |
35 | |
36 | kill 'KILL', $childpid; |
37 | |
38 | |