X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fgenerated_app.t;h=ec7e3b0c6ed9012e396008abe359eeacca3feb5e;hb=0f33c7455320e02edf7f27d90978c953015d21ba;hp=3083eaff4fb5b1e427743d91e72fb088bcacdbcc;hpb=20859489a4776c7dec22fe308860d5b4bb0583c2;p=catagits%2FCatalyst-Devel.git diff --git a/t/generated_app.t b/t/generated_app.t index 3083eaf..ec7e3b0 100644 --- a/t/generated_app.t +++ b/t/generated_app.t @@ -1,18 +1,26 @@ use strict; use warnings; -use File::Temp qw/ tempdir /; +use File::Temp qw/ tempdir tmpnam /; +use File::Spec; +use Test::WWW::Mechanize; +use Catalyst::Devel; -my $dir = tempdir(); # CLEANUP => 1 ); +my $dir = tempdir( CLEANUP => 1 ); +my $devnull = File::Spec->devnull; use Test::More; { # Check exit status here - system("cd $dir; catalyst.pl TestApp"); + if ($^O eq 'MSWin32') { + system("cd $dir & catalyst TestApp > $devnull 2>&1"); + } + else { + system("cd $dir; catalyst.pl TestApp > $devnull 2>&1"); + } } # Fix paths / nl work on win32 chdir("$dir/TestApp/"); -warn($dir); # Ok, this is lame.. Also, check +x permissions? my @files = qw| @@ -43,17 +51,47 @@ script/testapp_test.pl script/testapp_create.pl |; -plan 'tests' => scalar @files + 3; - foreach my $fn (@files) { ok -r $fn, "Have $fn in generated app"; + if ($fn =~ /script/) { + ok -x $fn, "$fn is executable"; + } } ## Makefile stuff my $makefile_status = `$^X Makefile.PL`; ok $makefile_status, "Makefile ran okay"; ok -e "Makefile", "Makefile exists"; -my $newapp_test_status = `prove -l t/`; -ok $newapp_test_status, "Tests ran okay"; -#is $newapp_test_status, ; +my $newapp_test_status = system("make", "test"); +ok !$newapp_test_status, "Tests ran okay"; + +## Moosey server tests - kmx++ +my $server_path = File::Spec->catfile('script', 'testapp_server.pl'); +my $port = int(rand(10000)) + 40000; # get random port between 40000-50000 + +my $childpid = fork(); +die "fork() error, cannot continue" unless defined($childpid); + +if ($childpid == 0) { + system("$^X $server_path -p $port > $devnull 2>&1"); + exit; # just for sure; we should never got here +} + +sleep 10; #wait for catalyst application to start +my $mech = Test::WWW::Mechanize->new; +$mech->get_ok( "http://localhost:" . $port ); + +kill 'KILL', $childpid; + +my $server_script = do { + open(my $fh, '<', 'script/testapp_server.pl') or die $!; + local $/; + <$fh>; +}; + +ok $server_script =~ qr/CATALYST_SCRIPT_GEN}\s+=\s+(\d+)/, + 'SCRIPT_GEN found in generated output'; +is $1, $Catalyst::Devel::CATALYST_SCRIPT_GEN, 'Script gen correct'; + +done_testing;