4 use Cwd qw( abs_path );
5 use File::Temp qw/ tempdir /;
13 plan skip_all => 'These tests require IPC::Run3' if $@;
15 my $share_dir = abs_path('share');
16 plan skip_all => "No share dir at $share_dir!"
19 $ENV{CATALYST_DEVEL_SHAREDIR} = $share_dir;
21 my $dir = tempdir(CLEANUP => 1);
22 my $devnull = File::Spec->devnull;
24 diag "Generated app is in $dir";
26 chdir $dir or die "Cannot chdir to $dir: $!";
29 open my $fh, '>', $devnull or die "Cannot write to $devnull: $!";
33 my $helper = Catalyst::Helper->new(
39 $helper->mk_app('TestApp');
42 my $app_dir = File::Spec->catdir($dir, 'TestApp');
43 chdir($app_dir) or die "Cannot chdir to $app_dir: $!";
44 lib->import(File::Spec->catdir($dir, 'TestApp', 'lib'));
50 lib/TestApp/Controller/Root.pm
56 root/static/images/catalyst_logo.png
57 root/static/images/btn_120x50_built.png
58 root/static/images/btn_120x50_built_shadow.png
59 root/static/images/btn_120x50_powered.png
60 root/static/images/btn_120x50_powered_shadow.png
61 root/static/images/btn_88x31_built.png
62 root/static/images/btn_88x31_built_shadow.png
63 root/static/images/btn_88x31_powered.png
64 root/static/images/btn_88x31_powered_shadow.png
68 script/testapp_fastcgi.pl
69 script/testapp_server.pl
70 script/testapp_test.pl
71 script/testapp_create.pl
74 foreach my $fn (map { File::Spec->catdir(@$_) } map { [ split /\// ] } @files) {
77 create_ok($_, 'My' . $_) for qw/Model View Controller/;
79 command_ok( [ $^X, 'Makefile.PL' ] );
80 ok -e "Makefile", "Makefile generated";
81 command_ok( [ 'make' ] );
83 run_generated_component_tests();
85 my $server_script = do {
86 open(my $fh, '<', File::Spec->catdir(qw/script testapp_server.pl/)) or fail $!;
92 ok $server_script =~ qr/CATALYST_SCRIPT_GEN}\s+=\s+(\d+)/,
93 'SCRIPT_GEN found in generated output';
94 is $1, $Catalyst::Devel::CATALYST_SCRIPT_GEN, 'Script gen correct';
105 run3( $cmd, \undef, \$stdout, \$stderr );
107 $desc ||= "Exit status ok for '@{$cmd}'";
108 unless ( is $? >> 8, 0, $desc ) {
109 diag "STDOUT:\n$stdout" if defined $stdout;
110 diag "STDERR:\n$stderr" if defined $stderr;
115 my $comment = pop @_;
116 command_ok( [ $^X, '-I', File::Spec->catdir($Bin, '..', 'lib'), @_ ], $comment );
119 my @generated_component_tests;
123 ok -r $fn, "Have $fn in generated app";
124 if ($fn =~ /script/) {
125 ok -x $fn, "$fn is executable";
127 if ($fn =~ /\.p[ml]$/) {
128 runperl( '-c', $fn, "$fn compiles" );
130 # Save these till later as Catalyst::Test will only be loaded once :-/
131 push @generated_component_tests, $fn
135 sub run_generated_component_tests {
136 local $ENV{TEST_POD} = 1;
137 local $ENV{CATALYST_DEBUG} = 0;
138 foreach my $fn (@generated_component_tests) {
139 subtest "Generated app test: $fn", sub {
146 my ($type, $name) = @_;
147 runperl( File::Spec->catdir('script', 'testapp_create.pl'), $type, $name,
148 "'script/testapp_create.pl $type $name' ok");
149 test_fn(File::Spec->catdir('t', sprintf("%s_%s.t", lc $type, $name)));