6 plan skip_all => 'set TEST_HTTP to enable this test' unless $ENV{TEST_HTTP};
14 eval "use Catalyst::Devel 1.0";
15 plan skip_all => 'Catalyst::Devel required' if $@;
16 eval "use File::Copy::Recursive";
17 plan skip_all => 'File::Copy::Recursive required' if $@;
20 # Run a single test by providing it as the first arg
21 my $single_test = shift;
23 my $tmpdir = "$FindBin::Bin/../t/tmp";
26 rmtree $tmpdir if -d $tmpdir;
28 # create a TestApp and copy the test libs into it
31 system( $^X, "-I$FindBin::Bin/../lib", "$FindBin::Bin/../script/catalyst.pl", 'TestApp' );
32 chdir "$FindBin::Bin/..";
33 File::Copy::Recursive::dircopy( 't/lib', 't/tmp/TestApp/lib' );
35 # remove TestApp's tests
36 rmtree 't/tmp/TestApp/t';
38 # spawn the standalone HTTP server
39 my $port = 30000 + int rand(1 + 10000);
40 my $pid = open3( undef, my $server, undef,
41 $^X, "-I$FindBin::Bin/../lib",
42 "$FindBin::Bin/../t/tmp/TestApp/script/testapp_server.pl", '-port', $port )
43 or die "Unable to spawn standalone HTTP server: $!";
45 # wait for it to start
46 print "Waiting for server to start...\n";
47 while ( check_port( 'localhost', $port ) != 1 ) {
51 # run the testsuite against the HTTP server
52 $ENV{CATALYST_SERVER} = "http://localhost:$port";
56 $return = system( "$^X -Ilib/ $single_test" );
59 $return = prove( '-r', '-Ilib/', glob('t/aggregate/live_*.t') );
67 rmtree "$FindBin::Bin/../t/tmp" if -d "$FindBin::Bin/../t/tmp";
69 is( $return, 0, 'live tests' );
72 my ( $host, $port ) = @_;
74 my $remote = IO::Socket::INET->new(
89 if (!(my $pid = fork)) {
91 my $prove = App::Prove->new;
92 $prove->process_args(@_);
93 exit( $prove->run ? 0 : 1 );