Added a test script to auto-test the standalone server
[catagits/Catalyst-Runtime.git] / t / optional / 01http-server.ot
CommitLineData
040850b3 1#!perl
2
3use strict;
4use warnings;
5
6use File::Copy::Recursive;
7use File::Path;
8use FindBin;
9
10# clean up
11rmtree "$FindBin::Bin/../../t/var" if -d "$FindBin::Bin/../../t/var";
12
13# create a TestApp and copy the test libs into it
14mkdir "$FindBin::Bin/../../t/var";
15chdir "$FindBin::Bin/../../t/var";
16system "$FindBin::Bin/../../script/catalyst.pl TestApp";
17chdir "$FindBin::Bin/../..";
18File::Copy::Recursive::dircopy( 't/live/lib', 't/var/TestApp/lib' );
19
20# spawn the standalone HTTP server
21my $pid = open SERVER,
22 "$FindBin::Bin/../../t/var/TestApp/script/testapp_server.pl 2>&1 |"
23 or die "Unable to spawn standalone HTTP server: $!";
24
25# wait for it to start
26sleep 2;
27
28# run the testsuite against the HTTP server
29$ENV{CATALYST_SERVER} = 'http://localhost:3000';
30system( 'prove -r -Ilib/ t/live/' );
31
32# shut it down
33kill 2, $pid;
34close SERVER;
35
36# clean up
37rmtree "$FindBin::Bin/../../t/var" if -d "$FindBin::Bin/../../t/var";