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