X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=t%2Foptional_http-server.t;h=60f925936c37ddba966d4286447be879ba71cbdc;hp=bf1878bc8205054a47addda91d2100ca19137446;hb=ae29b412955743885e80350085167b54b69672da;hpb=e16a6c4e6c4d49e73b5286b3186616af14f3f554 diff --git a/t/optional_http-server.t b/t/optional_http-server.t index bf1878b..60f9259 100644 --- a/t/optional_http-server.t +++ b/t/optional_http-server.t @@ -1,13 +1,16 @@ use strict; use warnings; +use Test::More; +BEGIN { + plan skip_all => 'set TEST_HTTP to enable this test' unless $ENV{TEST_HTTP}; +} + use File::Path; use FindBin; use IPC::Open3; use IO::Socket; -use Test::More; -plan skip_all => 'set TEST_HTTP to enable this test' unless $ENV{TEST_HTTP}; eval "use Catalyst::Devel 1.0"; plan skip_all => 'Catalyst::Devel required' if $@; eval "use File::Copy::Recursive"; @@ -25,7 +28,7 @@ rmtree $tmpdir if -d $tmpdir; # create a TestApp and copy the test libs into it mkdir $tmpdir; chdir $tmpdir; -system( 'perl', "-I$FindBin::Bin/../lib", "$FindBin::Bin/../script/catalyst.pl", 'TestApp' ); +system( $^X, "-I$FindBin::Bin/../lib", "$FindBin::Bin/../script/catalyst.pl", 'TestApp' ); chdir "$FindBin::Bin/.."; File::Copy::Recursive::dircopy( 't/lib', 't/tmp/TestApp/lib' ); @@ -35,7 +38,7 @@ rmtree 't/tmp/TestApp/t'; # spawn the standalone HTTP server my $port = 30000 + int rand(1 + 10000); my $pid = open3( undef, my $server, undef, - 'perl', "-I$FindBin::Bin/../lib", + $^X, "-I$FindBin::Bin/../lib", "$FindBin::Bin/../t/tmp/TestApp/script/testapp_server.pl", '-port', $port ) or die "Unable to spawn standalone HTTP server: $!"; @@ -50,10 +53,10 @@ $ENV{CATALYST_SERVER} = "http://localhost:$port"; my $return; if ( $single_test ) { - $return = system( "perl -Ilib/ $single_test" ); + $return = system( "$^X -Ilib/ $single_test" ); } else { - $return = system( 'prove -r -Ilib/ t/live_*.t' ); + $return = prove( '-r', '-Ilib/', glob('t/aggregate/live_*.t') ); } # shut it down @@ -81,3 +84,15 @@ sub check_port { return 0; } } + +sub prove { + if (!(my $pid = fork)) { + require App::Prove; + my $prove = App::Prove->new; + $prove->process_args(@_); + exit( $prove->run ? 0 : 1 ); + } else { + waitpid $pid, 0; + return $?; + } +}