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";
56 $return = system( "$^X -Ilib/ $single_test" );
59 $return = prove(grep { $_ ne '..' } 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(
90 if (!(my $pid = fork)) {
93 my $aggr = -e '.aggregating';
94 my $harness = TAP::Harness->new({
95 ($aggr ? (test_args => \@tests) : ()),
99 my $aggregator = $aggr
100 ? $harness->runtests('t/aggregate.t')
101 : $harness->runtests(@tests);
103 exit $aggregator->has_errors ? 1 : 0;