Doc changes to Upgrading and PSGI.
[catagits/Catalyst-Runtime.git] / t / aggregate / psgi_file.t
CommitLineData
c234ca55 1use strict;
2use warnings;
3use Test::More;
4use FindBin;
5use lib "$FindBin::Bin/../lib";
6use File::Temp qw/ tempdir /;
7use TestApp;
8use File::Spec;
9
10my $home = tempdir( CLEANUP => 1 );
11my $path = File::Spec->catfile($home, 'testapp.psgi');
12open(my $psgi, '>', $path)
13 or die;
14print $psgi q{
15use strict;
16use warnings;
17use TestApp;
18
8f076801 19TestApp->psgi_app;
c234ca55 20};
21close($psgi);
22# Check we wrote out something that compiles
23system($^X, '-I', "$FindBin::Bin/../lib", '-c', $path)
24 ? fail('.psgi does not compile')
25 : pass('.psgi compiles');
26
27# NOTE - YOU *CANNOT* do something like:
28#my $psgi_ref = require $path;
29# otherwise this test passes!
30# I don't exactly know why that is yet, however, to be safe for future, that
e6006848 31# is why this test writes out its own .psgi file in a temp directory - so that that
c234ca55 32# path has never been require'd before, and will never be require'd again..
33
34local TestApp->config->{home} = $home;
35
36my $failed = 0;
37eval {
38 # Catch infinite recursion (or anything else)
39 local $SIG{__WARN__} = sub { warn(@_); $failed = 1; die; };
8f076801 40 TestApp->_finalized_psgi_app;
c234ca55 41};
42ok(!$@, 'No exception')
43 or diag $@;
8f076801 44ok(!$failed, 'TestApp->_finalized_psgi_app works');
c234ca55 45
46done_testing;