fix psgi_file test without Catalyst installed
[catagits/Catalyst-Runtime.git] / t / aggregate / psgi_file.t
index c7a0e36..1f8f0c5 100644 (file)
@@ -6,6 +6,8 @@ use lib "$FindBin::Bin/../lib";
 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');
@@ -16,19 +18,24 @@ use strict;
 use warnings;
 use TestApp;
 
-TestApp->raw_psgi_app;
+TestApp->psgi_app;
 };
 close($psgi);
-# Check we wrote out something that compiles
-system($^X, '-I', "$FindBin::Bin/../lib", '-c', $path)
-    ? fail('.psgi does not compile')
-    : pass('.psgi compiles');
+
+my @command = ($^X, '-I', "$FindBin::Bin/../lib", '-I', "$FindBin::Bin/../../lib", '-c', $path);
+open my $stdin, '<', File::Spec->devnull;
+my $pid = open3 $stdin, my $stdout, undef, @command;
+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;
 # 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 +44,10 @@ my $failed = 0;
 eval {
     # Catch infinite recursion (or anything else)
     local $SIG{__WARN__} = sub { warn(@_); $failed = 1; die; };
-    TestApp->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;