X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fgenerated_app.t;h=b3a09988f39a0aca9927621abace1092439a5810;hb=636c7d946d756a64fa6fc7ac2bc4e112f1131471;hp=4010bfa9b1e03c0b9fa5cdb0682d9c0cc482eb6e;hpb=29ac6b9f339255c78e2fe9ec00c1dc34572c3750;p=catagits%2FCatalyst-Devel.git diff --git a/t/generated_app.t b/t/generated_app.t index 4010bfa..b3a0998 100644 --- a/t/generated_app.t +++ b/t/generated_app.t @@ -18,6 +18,14 @@ plan skip_all => "No share dir at $share_dir!" unless -d $share_dir; $ENV{CATALYST_DEVEL_SHAREDIR} = $share_dir; +my $instdir = tempdir(CLEANUP => 1); + +$ENV{PERL_MM_OPT} = "INSTALL_BASE=$instdir"; +$ENV{INSTALL_BASE} = $instdir; +if ($ENV{MAKEFLAGS}) { + $ENV{MAKEFLAGS} =~ s/PREFIX=[^\s]+//; + $ENV{MAKEFLAGS} =~ s/INSTALL_BASE=[^\s]+//; +} my $dir = tempdir(CLEANUP => 1); my $devnull = File::Spec->devnull; @@ -72,7 +80,7 @@ my @files = qw| script/testapp_create.pl |; -foreach my $fn (map { File::Spec->catdir(@$_) } map { [ split /\// ] } @files) { +foreach my $fn (map { File::Spec->catdir(@$_) } map { [ File::Spec::Unix->splitdir($_) ] } @files) { test_fn($fn); } create_ok($_, 'My' . $_) for qw/Model View Controller/; @@ -84,8 +92,9 @@ command_ok( [ ($Config{make} || 'make') ] ); run_generated_component_tests(); +my $server_script_file = File::Spec->catdir(qw/script testapp_server.pl/); my $server_script = do { - open(my $fh, '<', File::Spec->catdir(qw/script testapp_server.pl/)) or fail $!; + open(my $fh, '<', $server_script_file) or fail $!; local $/; <$fh>; }; @@ -95,6 +104,61 @@ ok $server_script =~ qr/CATALYST_SCRIPT_GEN}\s+=\s+(\d+)/, 'SCRIPT_GEN found in generated output'; is $1, $Catalyst::Devel::CATALYST_SCRIPT_GEN, 'Script gen correct'; +{ + open(my $fh, '>', $server_script_file) or fail $!; + print $fh "MOO\n"; +} +my $helper = Catalyst::Helper->new( + { + '.newfiles' => 0, + 'makefile' => 0, + 'scripts' => 1, + name => '.', + } +); +$helper->mk_app( '.' ) or fail; + +my $server_script_new = do { + open(my $fh, '<', $server_script_file) or fail $!; + local $/; + <$fh>; +}; + +is $server_script, $server_script_new; + +diag "Installed app is in $instdir"; +command_ok( [ ($Config{make} || 'make', 'install') ] ); + +my $inst_app_dir = File::Spec->catdir($instdir); +chdir($inst_app_dir) or die "Cannot chdir to $inst_app_dir: $!"; +lib->import(File::Spec->catdir($instdir, 'lib', 'perl5')); + +my @installed_files = qw| + lib/perl5/TestApp.pm + lib/perl5/TestApp/testapp.conf + lib/perl5/TestApp/Controller/Root.pm + lib/perl5/TestApp/root/static/images/catalyst_logo.png + lib/perl5/TestApp/root/static/images/btn_120x50_built.png + lib/perl5/TestApp/root/static/images/btn_120x50_built_shadow.png + lib/perl5/TestApp/root/static/images/btn_120x50_powered.png + lib/perl5/TestApp/root/static/images/btn_120x50_powered_shadow.png + lib/perl5/TestApp/root/static/images/btn_88x31_built.png + lib/perl5/TestApp/root/static/images/btn_88x31_built_shadow.png + lib/perl5/TestApp/root/static/images/btn_88x31_powered.png + lib/perl5/TestApp/root/static/images/btn_88x31_powered_shadow.png + lib/perl5/TestApp/root/favicon.ico + bin/testapp_cgi.pl + bin/testapp_fastcgi.pl + bin/testapp_server.pl + bin/testapp_test.pl + bin/testapp_create.pl +|; + +foreach my $fn (map { File::Spec->catdir(@$_) } map { [ File::Spec::Unix->splitdir($_) ] } @installed_files) { + my $ffn = File::Spec->catfile($inst_app_dir, $fn); + ok -r $ffn, "'$fn' installed in correct location"; +} + chdir('/'); done_testing; @@ -142,7 +206,7 @@ sub run_generated_component_tests { local $ENV{CATALYST_DEBUG} = 0; foreach my $fn (@generated_component_tests) { subtest "Generated app test: $fn", sub { - require $fn; + do $fn; }; } }