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