5 use lib "$FindBin::Bin/../lib";
6 use File::Temp qw/ tempdir /;
10 use IPC::Open3 qw(open3);
12 my $home = tempdir( CLEANUP => 1 );
13 my $path = File::Spec->catfile($home, 'testapp.psgi');
14 open(my $psgi, '>', $path)
25 my @command = ($^X, '-I', "$FindBin::Bin/../lib", '-I', "$FindBin::Bin/../../lib", '-c', $path);
26 open my $stdin, '<', File::Spec->devnull;
27 my $pid = open3 $stdin, my $stdout, undef, @command;
28 my $output = do { local $/; <$stdout> };
31 ok $? == 0, '.psgi compiles'
34 # NOTE - YOU *CANNOT* do something like:
35 #my $psgi_ref = require $path;
36 # otherwise this test passes!
37 # I don't exactly know why that is yet, however, to be safe for future, that
38 # is why this test writes out its own .psgi file in a temp directory - so that that
39 # path has never been require'd before, and will never be require'd again..
41 local TestApp->config->{home} = $home;
45 # Catch infinite recursion (or anything else)
46 local $SIG{__WARN__} = sub { warn(@_); $failed = 1; die; };
47 TestApp->_finalized_psgi_app;
49 ok(!$@, 'No exception')
51 ok(!$failed, 'TestApp->_finalized_psgi_app works');