4 use Test::More tests => 1;
10 use Catalyst::Devel 1.0;
11 use File::Copy::Recursive;
13 # Run a single test by providing it as the first arg
14 my $single_test = shift;
16 my $tmpdir = "$FindBin::Bin/../../t/tmp";
19 rmtree $tmpdir if -d $tmpdir;
21 # create a TestApp and copy the test libs into it
24 system( $^X, "-I$FindBin::Bin/../../lib", "$FindBin::Bin/../../script/catalyst.pl", 'TestApp' );
25 chdir "$FindBin::Bin/..";
26 File::Copy::Recursive::dircopy( '../t/lib', '../t/tmp/TestApp/lib' ) or die;
28 # remove TestApp's tests
29 rmtree '../t/tmp/TestApp/t' or die;
31 # spawn the standalone HTTP server
32 my $port = 30000 + int rand(1 + 10000);
37 print "Waiting for server to start...\n";
40 while ( check_port( 'localhost', $port ) != 1 ) {
42 die "Server did not start within $timeout seconds:"
43 if $count++ > $timeout;
47 unshift @INC, "$tmpdir/TestApp/lib", "$FindBin::Bin/../../lib";
50 my $psgi_app = TestApp->_wrapped_legacy_psgi_app(TestApp->psgi_app);
51 Plack::Loader->auto(port => $port)->run($psgi_app);
55 die "fork failed: $!";
58 # run the testsuite against the HTTP server
59 $ENV{CATALYST_SERVER} = "http://localhost:$port";
65 $return = system( "$^X -Ilib/ $single_test" );
68 $return = prove(grep { $_ ne '..' } glob('t/aggregate/live_*.t'));
75 rmtree "$FindBin::Bin/../../t/tmp" if -d "$FindBin::Bin/../../t/tmp";
77 is( $return, 0, 'live tests' );
80 my ( $host, $port ) = @_;
82 my $remote = IO::Socket::INET->new(
98 if (!(my $pid = fork)) {
101 my $aggr = -e '.aggregating';
102 my $harness = TAP::Harness->new({
103 ($aggr ? (test_args => \@tests) : ()),
107 my $aggregator = $aggr
108 ? $harness->runtests('t/aggregate.t')
109 : $harness->runtests(@tests);
111 exit $aggregator->has_errors ? 1 : 0;