4 use Cwd qw( abs_path );
5 use File::Temp qw/ tempdir /;
14 plan skip_all => 'These tests require IPC::Run3' if $@;
16 my $share_dir = abs_path('share');
17 plan skip_all => "No share dir at $share_dir!"
20 $ENV{CATALYST_DEVEL_SHAREDIR} = $share_dir;
22 my $dir = tempdir(CLEANUP => 1);
23 my $devnull = File::Spec->devnull;
25 diag "Generated app is in $dir";
27 chdir $dir or die "Cannot chdir to $dir: $!";
30 open my $fh, '>', $devnull or die "Cannot write to $devnull: $!";
34 my $helper = Catalyst::Helper->new(
40 $helper->mk_app('TestApp');
43 my $app_dir = File::Spec->catdir($dir, 'TestApp');
44 chdir($app_dir) or die "Cannot chdir to $app_dir: $!";
45 lib->import(File::Spec->catdir($dir, 'TestApp', 'lib'));
51 lib/TestApp/Controller/Root.pm
57 root/static/images/catalyst_logo.png
58 root/static/images/btn_120x50_built.png
59 root/static/images/btn_120x50_built_shadow.png
60 root/static/images/btn_120x50_powered.png
61 root/static/images/btn_120x50_powered_shadow.png
62 root/static/images/btn_88x31_built.png
63 root/static/images/btn_88x31_built_shadow.png
64 root/static/images/btn_88x31_powered.png
65 root/static/images/btn_88x31_powered_shadow.png
69 script/testapp_fastcgi.pl
70 script/testapp_server.pl
71 script/testapp_test.pl
72 script/testapp_create.pl
75 foreach my $fn (map { File::Spec->catdir(@$_) } map { [ split /\// ] } @files) {
78 create_ok($_, 'My' . $_) for qw/Model View Controller/;
80 command_ok( [ $^X, 'Makefile.PL' ] );
81 ok -e "Makefile", "Makefile generated";
82 #NOTE: do not assume that 'make' is always 'make' as e.g. Win32/strawberry perl uses 'dmake'
83 my $make = $Config{make} || 'make';
84 command_ok( [ $make ], 'Ran make ok' );
85 if (eval { require PAR::Packer }) {
86 command_ok([ $make, 'catalyst_par' ], 'Ran make catalyst_par ok');
87 command_ok([ 'parl', ]); # FIXME - Win32?
90 run_generated_component_tests();
92 my $server_script = do {
93 open(my $fh, '<', File::Spec->catdir(qw/script testapp_server.pl/)) or fail $!;
99 ok $server_script =~ qr/CATALYST_SCRIPT_GEN}\s+=\s+(\d+)/,
100 'SCRIPT_GEN found in generated output';
101 is $1, $Catalyst::Devel::CATALYST_SCRIPT_GEN, 'Script gen correct';
112 run3( $cmd, \undef, \$stdout, \$stderr );
114 $desc ||= "Exit status ok for '@{$cmd}'";
115 unless ( is $? >> 8, 0, $desc ) {
116 diag "STDOUT:\n$stdout" if defined $stdout;
117 diag "STDERR:\n$stderr" if defined $stderr;
122 my $comment = pop @_;
123 command_ok( [ $^X, '-I', File::Spec->catdir($Bin, '..', 'lib'), @_ ], $comment );
126 my @generated_component_tests;
130 ok -r $fn, "Have $fn in generated app";
131 if ($fn =~ /script/) {
133 skip 'Executable file flag test does not make sense on Win32', 1 if ($^O eq 'MSWin32');
134 ok -x $fn, "$fn is executable";
137 if ($fn =~ /\.p[ml]$/) {
138 runperl( '-c', $fn, "$fn compiles" );
140 # Save these till later as Catalyst::Test will only be loaded once :-/
141 push @generated_component_tests, $fn
145 sub run_generated_component_tests {
146 local $ENV{TEST_POD} = 1;
147 local $ENV{CATALYST_DEBUG} = 0;
148 foreach my $fn (@generated_component_tests) {
149 subtest "Generated app test: $fn", sub {
156 my ($type, $name) = @_;
157 runperl( File::Spec->catdir('script', 'testapp_create.pl'), $type, $name,
158 "'script/testapp_create.pl $type $name' ok");
159 test_fn(File::Spec->catdir('t', sprintf("%s_%s.t", lc $type, $name)));