Fixed get_sharedir_file.t checking for the wrong exception text.
[catagits/Catalyst-Devel.git] / t / generated_app.t
CommitLineData
ad9d93fc 1use strict;
2use warnings;
3
99618c49 4use File::Temp qw/ tempdir tmpnam /;
0f89baa1 5use File::Spec;
99618c49 6use Test::WWW::Mechanize;
7
ad9d93fc 8my $dir = tempdir(); # CLEANUP => 1 );
165233a4 9my $devnull = File::Spec->devnull;
ad9d93fc 10
11use Test::More;
12{
13 # Check exit status here
165233a4 14 if ($^O eq 'MSWin32') {
15 system("cd $dir & catalyst TestApp > $devnull 2>&1");
16 }
17 else {
18 system("cd $dir; catalyst.pl TestApp > $devnull 2>&1");
19 }
ad9d93fc 20}
21# Fix paths / nl work on win32
22chdir("$dir/TestApp/");
23warn($dir);
24
25# Ok, this is lame.. Also, check +x permissions?
26my @files = qw|
27 Makefile.PL
2cb998f9 28 testapp.conf
29lib/TestApp.pm
30lib/TestApp/Controller/Root.pm
31README
32Changes
33t/01app.t
34t/02pod.t
35t/03podcoverage.t
36root/static/images/catalyst_logo.png
37root/static/images/btn_120x50_built.png
38root/static/images/btn_120x50_built_shadow.png
39root/static/images/btn_120x50_powered.png
40root/static/images/btn_120x50_powered_shadow.png
41root/static/images/btn_88x31_built.png
42root/static/images/btn_88x31_built_shadow.png
43root/static/images/btn_88x31_powered.png
44root/static/images/btn_88x31_powered_shadow.png
45root/favicon.ico
46Makefile.PL
47script/testapp_cgi.pl
48script/testapp_fastcgi.pl
49script/testapp_server.pl
50script/testapp_test.pl
51script/testapp_create.pl
f5159e3e 52script/testapp_deploy_schema.pl
ad9d93fc 53|;
54
99618c49 55plan 'tests' => scalar @files + 4;
ad9d93fc 56
57foreach my $fn (@files) {
58 ok -r $fn, "Have $fn in generated app";
59}
60
20859489 61## Makefile stuff
62my $makefile_status = `$^X Makefile.PL`;
63ok $makefile_status, "Makefile ran okay";
64ok -e "Makefile", "Makefile exists";
165233a4 65my $newapp_test_status = `prove -l t/ 2> $devnull`;
20859489 66ok $newapp_test_status, "Tests ran okay";
67#is $newapp_test_status, ;
68
99618c49 69## Moosey server tests - kmx++
0f89baa1 70my $server_path = File::Spec->catfile('script', 'testapp_server.pl');
165233a4 71my $port = int(rand(10000)) + 40000; # get random port between 40000-50000
99618c49 72
165233a4 73my $childpid = fork();
74die "fork() error, cannot continue" unless defined($childpid);
99618c49 75
76if ($childpid == 0) {
165233a4 77 system("$^X $server_path -p $port > $devnull 2>&1");
78 exit; # just for sure; we should never got here
99618c49 79}
80
81sleep 10; #wait for catalyst application to start
82my $mech = Test::WWW::Mechanize->new;
83$mech->get_ok( "http://localhost:" . $port );
84
85kill 'KILL', $childpid;
165233a4 86
0f89baa1 87