From: Thomas Sibley Date: Fri, 6 Nov 2015 17:43:43 +0000 (-0800) Subject: Test for recent regression parsing Args() X-Git-Tag: 0.090103~8 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=1c20c63931df63b579c27cf822bc933211d33df9 Test for recent regression parsing Args() Args() started parsing as Args('') instead of Args, which in DispatchType::Chained->list's debugging output ends up causing the equivalent of this to run: ("*") x ~0 The result is Perl throwing an "Out of memory during list extend" error. Fix to follow. NB: Using the normalized_arg_number (where ~0 stands in for ∞) for this debugging output is dubious, but there's not a clear cut revert as the changes which got us there are spread across multiple commits related to the new typed Args support. I'm saving any change to the use of normalized_arg_number and list_extra_info for another time (and probably another person), in favor of changing the least while fixing both the Args() regression and the original Path() bug which precipitated it. --- diff --git a/t/args-empty-parens-bug.t b/t/args-empty-parens-bug.t new file mode 100644 index 0000000..285fc6e --- /dev/null +++ b/t/args-empty-parens-bug.t @@ -0,0 +1,28 @@ +use warnings; +use strict; +use Test::More; +use FindBin qw< $Bin >; +use lib "$Bin/lib"; +use constant App => 'TestAppArgsEmptyParens'; +use Catalyst::Test App; + +{ + my $res = request('/chain_base/args/foo/bar'); + is $res->content, 'Args', "request '/chain_base/args/foo/bar'"; +} + +{ + my $res = request('/chain_base/args_empty/foo/bar'); + is $res->content, 'Args()', "request '/chain_base/args_empty/foo/bar'"; +} + +eval { App->dispatcher->dispatch_type('Chained')->list(App) }; +ok !$@, "didn't die" + or diag "Died with: $@"; +like $TestLogger::LOGS[-1], qr{/args\s*\Q(...)\E}; +like $TestLogger::LOGS[-1], qr{/args_empty\s*\Q(...)\E}; + +done_testing; + +__END__ + diff --git a/t/lib/TestAppArgsEmptyParens.pm b/t/lib/TestAppArgsEmptyParens.pm new file mode 100644 index 0000000..051a850 --- /dev/null +++ b/t/lib/TestAppArgsEmptyParens.pm @@ -0,0 +1,21 @@ +package TestAppArgsEmptyParens::Controller::Root; +use Moose; +use MooseX::MethodAttributes; + +extends 'Catalyst::Controller'; + +sub chain_base :Chained(/) PathPart('chain_base') CaptureArgs(0) { } + + sub args : Chained(chain_base) PathPart('args') Args { $_[1]->res->body('Args') } + sub args_empty : Chained(chain_base) PathPart('args_empty') Args() { $_[1]->res->body('Args()') } + +TestAppArgsEmptyParens::Controller::Root->config(namespace=>''); + +package TestAppArgsEmptyParens; +use Catalyst; +use TestLogger; + +TestAppArgsEmptyParens->setup; +TestAppArgsEmptyParens->log( TestLogger->new ); + +1;