10 plan skip_all => 'set TEST_HTTP to enable this test' unless $ENV{TEST_HTTP};
11 eval "use Catalyst::Devel 1.0";
12 plan skip_all => 'Catalyst::Devel required' if $@;
13 eval "use File::Copy::Recursive";
14 plan skip_all => 'File::Copy::Recursive required' if $@;
17 # Run a single test by providing it as the first arg
18 my $single_test = shift;
20 my $tmpdir = "$FindBin::Bin/../t/tmp";
23 rmtree $tmpdir if -d $tmpdir;
25 # create a TestApp and copy the test libs into it
28 system( 'perl', "-I$FindBin::Bin/../lib", "$FindBin::Bin/../script/catalyst.pl", 'TestApp' );
29 chdir "$FindBin::Bin/..";
30 File::Copy::Recursive::dircopy( 't/lib', 't/tmp/TestApp/lib' );
32 # remove TestApp's tests
33 rmtree 't/tmp/TestApp/t';
35 # spawn the standalone HTTP server
36 my $port = 30000 + int rand(1 + 10000);
37 my $pid = open3( undef, my $server, undef,
38 'perl', "-I$FindBin::Bin/../lib",
39 "$FindBin::Bin/../t/tmp/TestApp/script/testapp_server.pl", '-port', $port )
40 or die "Unable to spawn standalone HTTP server: $!";
42 # wait for it to start
43 print "Waiting for server to start...\n";
44 while ( check_port( 'localhost', $port ) != 1 ) {
48 # run the testsuite against the HTTP server
49 $ENV{CATALYST_SERVER} = "http://localhost:$port";
53 $return = system( "perl -Ilib/ $single_test" );
56 $return = system( 'prove -r -Ilib/ t/live_*.t' );
64 rmtree "$FindBin::Bin/../t/tmp" if -d "$FindBin::Bin/../t/tmp";
66 is( $return, 0, 'live tests' );
69 my ( $host, $port ) = @_;
71 my $remote = IO::Socket::INET->new(