4 use Test::More tests => 1;
11 use Catalyst::Devel 1.0;
12 use File::Copy::Recursive;
14 # Run a single test by providing it as the first arg
15 my $single_test = shift;
17 my $tmpdir = "$FindBin::Bin/../../t/tmp";
20 rmtree $tmpdir if -d $tmpdir;
22 # create a TestApp and copy the test libs into it
25 system( $^X, "-I$FindBin::Bin/../../lib", "$FindBin::Bin/../../script/catalyst.pl", 'TestApp' );
26 chdir "$FindBin::Bin/..";
27 File::Copy::Recursive::dircopy( '../t/lib', '../t/tmp/TestApp/lib' ) or die;
29 # remove TestApp's tests
30 rmtree '../t/tmp/TestApp/t' or die;
32 # spawn the standalone HTTP server
33 my $port = 30000 + int rand(1 + 10000);
34 my @cmd = ($^X, "-I$FindBin::Bin/../../lib",
35 "$FindBin::Bin/../../t/tmp/TestApp/script/testapp_server.pl", '--port', $port );
36 my $pid = open3( undef, my $server, undef, @cmd)
37 or die "Unable to spawn standalone HTTP server: $!";
39 # wait for it to start
40 print "Waiting for server to start...\n";
43 while ( check_port( 'localhost', $port ) != 1 ) {
45 die("Server did not start within $timeout seconds: " . join(' ', @cmd))
46 if $count++ > $timeout;
49 # run the testsuite against the HTTP server
50 $ENV{CATALYST_SERVER} = "http://localhost:$port";
54 $return = system( "$^X -I../lib/ $single_test" );
57 $return = prove( '-r', '-I../lib/', glob('../t/aggregate/live_*.t') );
65 rmtree "$FindBin::Bin/../../t/tmp" if -d "$FindBin::Bin/../../t/tmp";
67 is( $return, 0, 'live tests' );
70 my ( $host, $port ) = @_;
72 my $remote = IO::Socket::INET->new(
87 if (!(my $pid = fork)) {
89 my $prove = App::Prove->new;
90 $prove->process_args(@_);
91 exit( $prove->run ? 0 : 1 );