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