X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=t%2Faggregate%2Fpsgi_file.t;fp=t%2Faggregate%2Fpsgi_file.t;h=f96bf927df5296ec9fd3610a4a62e2c000be19b9;hp=0e07d21f796e131fa49219bdb0674296dee88947;hb=7991d6fc21b6827110266ea18a2e302a609190e2;hpb=136fa8da2711e22ec40a39c880595a11907e4d06 diff --git a/t/aggregate/psgi_file.t b/t/aggregate/psgi_file.t index 0e07d21..f96bf92 100644 --- a/t/aggregate/psgi_file.t +++ b/t/aggregate/psgi_file.t @@ -7,6 +7,7 @@ use File::Temp qw/ tempdir /; use TestApp; use File::Spec; use Carp qw/croak/; +use IPC::Open3 qw(open3); my $home = tempdir( CLEANUP => 1 ); my $path = File::Spec->catfile($home, 'testapp.psgi'); @@ -21,24 +22,13 @@ TestApp->psgi_app; }; close($psgi); -my ($saved_stdout, $saved_stderr); -my $stdout = !open( $saved_stdout, '>&'. STDOUT->fileno ); -my $stderr = !open( $saved_stderr, '>&'. STDERR->fileno ); -open( STDOUT, '+>', undef ) - or croak("Can't reopen stdout to /dev/null"); -open( STDERR, '+>', undef ) - or croak("Can't reopen stdout to /dev/null"); -# Check we wrote out something that compiles -system($^X, '-I', "$FindBin::Bin/../lib", '-c', $path) - ? fail('.psgi does not compile') - : pass('.psgi compiles'); - -if ($stdout) { - open( STDOUT, '>&'. fileno($saved_stdout) ); -} -if ($stderr) { - open( STDERR, '>&'. fileno($saved_stderr) ); -} +open my $stdin, '<', File::Spec->devnull; +my $pid = open3 $stdin, my $stdout, undef, $^X, '-I', "$FindBin::Bin/../lib", '-c', $path; +my $output = do { local $/; <$stdout> }; +waitpid $pid, 0; + +ok $? == 0, '.psgi compiles' + or diag $output; # NOTE - YOU *CANNOT* do something like: #my $psgi_ref = require $path;