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 command_ok( [ ($Config{make} || 'make') ] );
85 run_generated_component_tests();
87 my $server_script = do {
88 open(my $fh, '<', File::Spec->catdir(qw/script testapp_server.pl/)) or fail $!;
94 ok $server_script =~ qr/CATALYST_SCRIPT_GEN}\s+=\s+(\d+)/,
95 'SCRIPT_GEN found in generated output';
96 is $1, $Catalyst::Devel::CATALYST_SCRIPT_GEN, 'Script gen correct';
107 run3( $cmd, \undef, \$stdout, \$stderr );
109 $desc ||= "Exit status ok for '@{$cmd}'";
110 unless ( is $? >> 8, 0, $desc ) {
111 diag "STDOUT:\n$stdout" if defined $stdout;
112 diag "STDERR:\n$stderr" if defined $stderr;
117 my $comment = pop @_;
118 command_ok( [ $^X, '-I', File::Spec->catdir($Bin, '..', 'lib'), @_ ], $comment );
121 my @generated_component_tests;
125 ok -r $fn, "Have $fn in generated app";
126 if ($fn =~ /script/) {
128 skip 'Executable file flag test does not make sense on Win32', 1 if ($^O eq 'MSWin32');
129 ok -x $fn, "$fn is executable";
132 if ($fn =~ /\.p[ml]$/) {
133 runperl( '-c', $fn, "$fn compiles" );
135 # Save these till later as Catalyst::Test will only be loaded once :-/
136 push @generated_component_tests, $fn
140 sub run_generated_component_tests {
141 local $ENV{TEST_POD} = 1;
142 local $ENV{CATALYST_DEBUG} = 0;
143 foreach my $fn (@generated_component_tests) {
144 subtest "Generated app test: $fn", sub {
151 my ($type, $name) = @_;
152 runperl( File::Spec->catdir('script', 'testapp_create.pl'), $type, $name,
153 "'script/testapp_create.pl $type $name' ok");
154 test_fn(File::Spec->catdir('t', sprintf("%s_%s.t", lc $type, $name)));