[Catalyst-commits] r10633 - in
Catalyst-Devel/1.00/branches/helper_refactor: share/script t
dhoss at dev.catalyst.perl.org
dhoss at dev.catalyst.perl.org
Tue Jun 23 22:35:53 GMT 2009
Author: dhoss
Date: 2009-06-23 22:35:53 +0000 (Tue, 23 Jun 2009)
New Revision: 10633
Modified:
Catalyst-Devel/1.00/branches/helper_refactor/share/script/myapp_server.pl.tt
Catalyst-Devel/1.00/branches/helper_refactor/t/generated_app.t
Log:
moosified server template.
added test to make sure new server works. Can't seem to connect, so
test doesn't pass.
Modified: Catalyst-Devel/1.00/branches/helper_refactor/share/script/myapp_server.pl.tt
===================================================================
--- Catalyst-Devel/1.00/branches/helper_refactor/share/script/myapp_server.pl.tt 2009-06-23 21:50:11 UTC (rev 10632)
+++ Catalyst-Devel/1.00/branches/helper_refactor/share/script/myapp_server.pl.tt 2009-06-23 22:35:53 UTC (rev 10633)
@@ -1,50 +1,31 @@
-[% startperl %]
+package [% appprefix %]::Script::Server;
-BEGIN {
- $ENV{CATALYST_ENGINE} ||= 'HTTP';
- $ENV{CATALYST_SCRIPT_GEN} = [% scriptgen %];
- require Catalyst::Engine::HTTP;
-}
+use Catalyst::Engine::HTTP;
+use [% appprefix %];
+use Moose;
-use strict;
-use warnings;
-use Getopt::Long;
-use Pod::Usage;
-use FindBin;
-use lib "$FindBin::Bin/../lib";
+with 'MooseX::GetOpt';
-my $debug = 0;
-my $fork = 0;
-my $help = 0;
-my $host = undef;
-my $port = $ENV{[% appenv %]_PORT} || $ENV{CATALYST_PORT} || 3000;
-my $keepalive = 0;
-my $restart = $ENV{[% appenv %]_RELOAD} || $ENV{CATALYST_RELOAD} || 0;
-my $background = 0;
-my $pidfile = undef;
+has argv => ( isa => 'ArrayRef', is => 'ro', required => 1 );
+has [qw/ fork background keepalive /] => ( isa => 'Bool', is => 'ro', required => 1, default => 0 );
+has pidfile => ( isa => 'Str', required => 0, is => 'ro' );
-my $check_interval;
-my $file_regex;
-my $watch_directory;
-my $follow_symlinks;
+sub run {
+ my $self = shift;
+ [% appprefix %]->run(
+ $port, $host,
+ {
+ argv => $self->argv,
+ 'fork' => $self->fork,
+ keepalive => $self->keepalive,
+ background => $self->background,
+ pidfile => $self->pidfile,
+ }
+ );
+}
-my @argv = @ARGV;
+__PACKAGE__->new_with_options->run;
-GetOptions(
- 'debug|d' => \$debug,
- 'fork|f' => \$fork,
- 'help|?' => \$help,
- 'host=s' => \$host,
- 'port|p=s' => \$port,
- 'keepalive|k' => \$keepalive,
- 'restart|r' => \$restart,
- 'restartdelay|rd=s' => \$check_interval,
- 'restartregex|rr=s' => \$file_regex,
- 'restartdirectory=s@' => \$watch_directory,
- 'followsymlinks' => \$follow_symlinks,
- 'background' => \$background,
- 'pidfile=s' => \$pidfile,
-);
pod2usage(1) if $help;
Modified: Catalyst-Devel/1.00/branches/helper_refactor/t/generated_app.t
===================================================================
--- Catalyst-Devel/1.00/branches/helper_refactor/t/generated_app.t 2009-06-23 21:50:11 UTC (rev 10632)
+++ Catalyst-Devel/1.00/branches/helper_refactor/t/generated_app.t 2009-06-23 22:35:53 UTC (rev 10633)
@@ -1,8 +1,10 @@
use strict;
use warnings;
-use File::Temp qw/ tempdir /;
+use File::Temp qw/ tempdir tmpnam /;
use File::Spec;
+use Test::WWW::Mechanize;
+
my $dir = tempdir(); # CLEANUP => 1 );
use Test::More;
@@ -43,7 +45,7 @@
script/testapp_create.pl
|;
-plan 'tests' => scalar @files + 3;
+plan 'tests' => scalar @files + 4;
foreach my $fn (@files) {
ok -r $fn, "Have $fn in generated app";
@@ -57,8 +59,23 @@
ok $newapp_test_status, "Tests ran okay";
#is $newapp_test_status, ;
-## Moosey server tests
+## Moosey server tests - kmx++
my $server_path = File::Spec->catfile('script', 'testapp_server.pl');
-#my $server_status = `$^X $server_path`;
-#ok $server_status, "Moosey server starts ok";
+my $childpid = fork();
+my $port = 3333; # or call some random generator
+
+if ($childpid == 0) {
+ my $tmpfile = tmpnam(); # do not redirect to /dev/null as it will not work on Win32
+ system("$^X $server_path -p $port > $tmpfile 2>&1");
+ unlink $tmpfile;
+ exit;
+}
+
+sleep 10; #wait for catalyst application to start
+my $mech = Test::WWW::Mechanize->new;
+$mech->get_ok( "http://localhost:" . $port );
+
+kill 'KILL', $childpid;
+
+
More information about the Catalyst-commits
mailing list