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;h=0e07d21f796e131fa49219bdb0674296dee88947;hp=8fd6eada95641e4adf97defedf41ca25b831b934;hb=10542b5178b2fa036e0658111523ea68a7a04437;hpb=c234ca5552150323a80cc138ef4d39d353534258 diff --git a/t/aggregate/psgi_file.t b/t/aggregate/psgi_file.t index 8fd6ead..0e07d21 100644 --- a/t/aggregate/psgi_file.t +++ b/t/aggregate/psgi_file.t @@ -6,6 +6,7 @@ use lib "$FindBin::Bin/../lib"; use File::Temp qw/ tempdir /; use TestApp; use File::Spec; +use Carp qw/croak/; my $home = tempdir( CLEANUP => 1 ); my $path = File::Spec->catfile($home, 'testapp.psgi'); @@ -19,16 +20,31 @@ use TestApp; 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) ); +} + # NOTE - YOU *CANNOT* do something like: #my $psgi_ref = require $path; # otherwise this test passes! # I don't exactly know why that is yet, however, to be safe for future, that -# is why this test writes out it's own .psgi file in a temp directory - so that that +# is why this test writes out its own .psgi file in a temp directory - so that that # path has never been require'd before, and will never be require'd again.. local TestApp->config->{home} = $home; @@ -37,10 +53,10 @@ my $failed = 0; eval { # Catch infinite recursion (or anything else) local $SIG{__WARN__} = sub { warn(@_); $failed = 1; die; }; - TestApp->setup_psgi_app; + TestApp->_finalized_psgi_app; }; ok(!$@, 'No exception') or diag $@; -ok(!$failed, 'TestApp->setup_psgi_app works'); +ok(!$failed, 'TestApp->_finalized_psgi_app works'); done_testing;