And more tests and fixing for the same thing
Tomas Doran [Wed, 9 Dec 2009 20:35:13 +0000 (20:35 +0000)]
lib/Catalyst/Script/Server.pm
t/aggregate/unit_core_script_server.t

index 8226af4..4fc199b 100644 (file)
@@ -47,8 +47,7 @@ has port => (
     isa           => PositiveInt,
     is            => 'ro',
     default       => sub {
-        my $self = shift;
-        $ENV{ Catalyst::Utils::class2env($self->application_name . '_PORT')}||3000
+        Catalyst::Utils::env_value(shift->application_name, 'port') || 3000
     },
     documentation => 'Specify a different listening port (to the default port 3000)',
 );
@@ -84,7 +83,9 @@ has restart => (
     cmd_aliases   => 'r',
     isa           => Bool,
     is            => 'ro',
-    default       => 0,
+    default       => sub {
+        Catalyst::Utils::env_value(shift->application_name, 'reload') || 0;
+    },
     documentation => 'use Catalyst::Restarter to detect code changes and restart the application',
 );
 
index 96b7a9f..c75cec6 100644 (file)
@@ -30,6 +30,10 @@ testOption( [ qw/--port 3001/ ], ['3001', undef, opthash()] );
     local $ENV{TESTAPPTOTESTSCRIPTS_PORT} = 5000;
     testOption( [ qw// ], [5000, undef, opthash()] );
 }
+{
+    local $ENV{CATALYST_PORT} = 5000;
+    testOption( [ qw// ], [5000, undef, opthash()] );
+}
 
 # fork           -f -fork --fork           -f --fork
 testOption( [ qw/--fork/ ], ['3000', undef, opthash(fork => 1)] );
@@ -53,6 +57,15 @@ testOption( [ qw/--bg/ ], ['3000', undef, opthash(background => 1)] );
 
 # restart        -r -restart --restart     -R --restart
 testRestart( ['-r'], restartopthash() );
+{
+    local $ENV{TESTAPPTOTESTSCRIPTS_RELOAD} = 1;
+    testRestart( [], restartopthash() );
+}
+{
+    local $ENV{CATALYST_RELOAD} = 1;
+    testRestart( [], restartopthash() );
+}
+
 # restart dly    -rd -restartdelay         --rd --restart_delay
 testRestart( ['-r', '--rd', 30], restartopthash(sleep_interval => 30) );
 testRestart( ['-r', '--restart_delay', 30], restartopthash(sleep_interval => 30) );
@@ -82,6 +95,7 @@ sub testOption {
 sub testRestart {
     my ($argstring, $resultarray) = @_;
     my $app = _build_testapp($argstring);
+    ok $app->restart, 'App is in restart mode';
     my $args = {$app->_restarter_args};
     is_deeply delete $args->{argv}, $argstring, 'argv is arg string';
     is ref(delete $args->{start_sub}), 'CODE', 'Closure to start app present';