added kmx's patch, still fails
[catagits/Catalyst-Devel.git] / t / generated_app.t
1 use strict;
2 use warnings;
3
4 use File::Temp qw/ tempdir tmpnam /;
5 use File::Spec;
6 use Test::WWW::Mechanize;
7
8 my $dir = tempdir(); # CLEANUP => 1 );
9
10 use Test::More;
11 {
12     # Check exit status here
13     system("cd $dir; catalyst.pl TestApp");
14 }
15 # Fix paths / nl work on win32
16 chdir("$dir/TestApp/");
17 warn($dir);
18
19 # Ok, this is lame.. Also, check +x permissions?
20 my @files = qw|
21     Makefile.PL
22     testapp.conf
23 lib/TestApp.pm
24 lib/TestApp/Controller/Root.pm
25 README
26 Changes
27 t/01app.t
28 t/02pod.t
29 t/03podcoverage.t
30 root/static/images/catalyst_logo.png
31 root/static/images/btn_120x50_built.png
32 root/static/images/btn_120x50_built_shadow.png
33 root/static/images/btn_120x50_powered.png
34 root/static/images/btn_120x50_powered_shadow.png
35 root/static/images/btn_88x31_built.png
36 root/static/images/btn_88x31_built_shadow.png
37 root/static/images/btn_88x31_powered.png
38 root/static/images/btn_88x31_powered_shadow.png
39 root/favicon.ico
40 Makefile.PL
41 script/testapp_cgi.pl
42 script/testapp_fastcgi.pl
43 script/testapp_server.pl
44 script/testapp_test.pl
45 script/testapp_create.pl
46 |;
47
48 plan 'tests' => scalar @files + 4;
49
50 foreach my $fn (@files) {
51     ok -r $fn, "Have $fn in generated app";
52 }
53
54 ## Makefile stuff
55 my $makefile_status = `$^X Makefile.PL`;
56 ok $makefile_status, "Makefile ran okay";
57 ok -e "Makefile", "Makefile exists";
58 my $newapp_test_status = `prove -l t/`;
59 ok $newapp_test_status, "Tests ran okay";
60 #is $newapp_test_status, ;
61
62 ## Moosey server tests - kmx++
63 my $server_path   = File::Spec->catfile('script', 'testapp_server.pl');
64 my $childpid = fork();
65
66 my $port = 3333; # or call some random generator
67 my $tmpfile = tmpnam(); # do not redirect to /dev/null as it will not work on Win32
68
69 if ($childpid == 0) {
70   system("$^X $server_path -p $port > $tmpfile 2>&1");
71   exit;
72 }
73
74 sleep 10; #wait for catalyst application to start
75 my $mech = Test::WWW::Mechanize->new;
76 $mech->get_ok( "http://localhost:" . $port );
77
78 kill 'KILL', $childpid;
79 unlink $tmpfile;
80