From: Tomas Doran Date: Wed, 9 Dec 2009 20:21:13 +0000 (+0000) Subject: Fixes port environment, RT#52604 X-Git-Tag: 5.80016~9 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=b89d8b9875b08957089b2758fb3533bf8fc1e0c6 Fixes port environment, RT#52604 --- diff --git a/lib/Catalyst/Script/Server.pm b/lib/Catalyst/Script/Server.pm index 6d44bd4..8226af4 100644 --- a/lib/Catalyst/Script/Server.pm +++ b/lib/Catalyst/Script/Server.pm @@ -8,6 +8,7 @@ BEGIN { use Moose; use MooseX::Types::Common::Numeric qw/PositiveInt/; use MooseX::Types::Moose qw/ArrayRef Str Bool Int RegexpRef/; +use Catalyst::Utils; use namespace::autoclean; with 'Catalyst::ScriptRole'; @@ -45,7 +46,10 @@ has port => ( cmd_aliases => 'p', isa => PositiveInt, is => 'ro', - default => 3000, + default => sub { + my $self = shift; + $ENV{ Catalyst::Utils::class2env($self->application_name . '_PORT')}||3000 + }, documentation => 'Specify a different listening port (to the default port 3000)', ); diff --git a/t/aggregate/unit_core_script_server.t b/t/aggregate/unit_core_script_server.t index 258255e..96b7a9f 100644 --- a/t/aggregate/unit_core_script_server.t +++ b/t/aggregate/unit_core_script_server.t @@ -26,6 +26,10 @@ testOption( [ qw/-h testhost/ ], ['3000', 'testhost', opthash()] ); # port -p -port --port -l --listen testOption( [ qw/-p 3001/ ], ['3001', undef, opthash()] ); testOption( [ qw/--port 3001/ ], ['3001', undef, opthash()] ); +{ + local $ENV{TESTAPPTOTESTSCRIPTS_PORT} = 5000; + testOption( [ qw// ], [5000, undef, opthash()] ); +} # fork -f -fork --fork -f --fork testOption( [ qw/--fork/ ], ['3000', undef, opthash(fork => 1)] );