From: Tomas Doran Date: Fri, 2 Jan 2009 19:31:37 +0000 (+0000) Subject: plugin new method test as-per various other plugins tests - shows issue with Hooks... X-Git-Tag: 5.8000_05~56 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=edb20ed3aaf578b6784f7e0a52ed8c00f05f2718;hp=420453e3f2bd4f6420e98221d12407b6020f5129 plugin new method test as-per various other plugins tests - shows issue with Hooks::EndOfScope, so switch to Scope::Upper on msts suggestion --- diff --git a/Makefile.PL b/Makefile.PL index eb5f49a..9cf0e8e 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -6,7 +6,7 @@ name 'Catalyst-Runtime'; all_from 'lib/Catalyst/Runtime.pm'; requires 'namespace::clean'; -requires 'B::Hooks::EndOfScope'; +requires 'Scope::Upper'; requires 'MooseX::Emulate::Class::Accessor::Fast' => '0.00700'; requires 'Moose' => '0.64'; requires 'Carp'; diff --git a/TODO b/TODO index f5baf32..36e8940 100644 --- a/TODO +++ b/TODO @@ -18,10 +18,13 @@ Back-compat investigation / known issues: - Run another round of repository smokes against latest 5.80 trunk, manually go through all the things which are broken (t0m). - - Catalyst::Plugin::Authorization::ACL - - Catalyst::Plugin::Server - - Catalyst::Plugin::HTML::Widget - - Should hopefully be fixed now.. + - Catalyst-Plugin-Session-State-Cookie + Catalyst-Plugin-Session-Store-FastMmap + Catalyst-Plugin-Session-PerUser + Catalyst-Plugin-Session-Store-File + Catalyst-Authentication-Credential-HTTP + Catalyst-Plugin-SmartURI + - All fixed by Scope::Upper - Catalyst-Log-Log4perl Deep recursion on subroutine "MockApp::setup" (rafl) @@ -40,10 +43,6 @@ Back-compat investigation / known issues: still support that, but warn for/deprecate it so it can go for 5.9X... This obviously needs better tests :/ - - With 5.7 people did extends qw/Moose::Object Catalyst::Component/, now - Catalyst::Component isa Moose::Object so now isa doesn't linearize - anymore, test case.. - Cleanups: - Update Test suite to not assume MyApp ISA Controller @@ -69,6 +68,10 @@ Documentation: - Fix the Roadmap to be less full of lies. + - With 5.7 people did extends qw/Moose::Object Catalyst::Component/, now + Catalyst::Component isa Moose::Object so now isa doesn't linearize + anymore, docs of what doesn't work and why (rafl) + Profiling: - vs 5.70 and optimisation as needed. diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 8a1167f..db307ab 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -8,7 +8,7 @@ use Moose; use Class::MOP::Object (); extends 'Catalyst::Component'; use bytes; -use B::Hooks::EndOfScope; +use Scope::Upper (); use Catalyst::Exception; use Catalyst::Log; use Catalyst::Request; @@ -1024,10 +1024,10 @@ EOF # Note however that we have to do the work on scope end, so that method # modifiers work correctly in MyApp (as you have to call setup _before_ # applying modifiers). - on_scope_end { + Scope::Upper::reap(sub { my $meta = $class->Moose::Object::meta(); $meta->make_immutable unless $meta->is_immutable; - }; + }, 1); $class->setup_finished(1); } diff --git a/t/lib/TestAppPluginWithNewMethod.pm b/t/lib/TestAppPluginWithNewMethod.pm deleted file mode 100644 index 778f63d..0000000 --- a/t/lib/TestAppPluginWithNewMethod.pm +++ /dev/null @@ -1,29 +0,0 @@ -{ - package NewTestPlugin; - use strict; - use warnings; - sub new { - my $class = shift; - return bless $_[0], $class; - } -} - -{ - package TestAppPluginWithNewMethod; - use Test::Exception; - use Catalyst qw/+NewTestPlugin/; - - sub foo : Local { - my ($self, $c) = @_; - $c->res->body('foo'); - } - - use Moose; # Just testing method modifiers still work. - __PACKAGE__->setup; - our $MODIFIER_FIRED = 0; - - lives_ok { - before 'dispatch' => sub { $MODIFIER_FIRED = 1 } - } 'Can apply method modifier'; - no Moose; -} diff --git a/t/plugin_new_method_backcompat.t b/t/plugin_new_method_backcompat.t index 7aaef8b..74e8f10 100644 --- a/t/plugin_new_method_backcompat.t +++ b/t/plugin_new_method_backcompat.t @@ -8,10 +8,45 @@ # that plugins don't get it wrong for us. # Also tests method modifiers and etc in MyApp.pm still work as expected. +use Test::More tests => 3; + +{ + package NewTestPlugin; + use strict; + use warnings; + sub new { + my $class = shift; + return bless $_[0], $class; + } +} + +{ # This is all in the same file so that the setup method on the + # application is called at runtime, rather than at compile time. + # This ensures that the end of scope hook has to happen at runtime + # correctly, otherwise the test will fail (ergo the switch from + # B::Hooks::EndOfScope to Sub::Uplevel) + package TestAppPluginWithNewMethod; + use Test::Exception; + use Catalyst qw/+NewTestPlugin/; + + sub foo : Local { + my ($self, $c) = @_; + $c->res->body('foo'); + } + + use Moose; # Just testing method modifiers still work. + __PACKAGE__->setup; + our $MODIFIER_FIRED = 0; + + lives_ok { + before 'dispatch' => sub { $MODIFIER_FIRED = 1 } + } 'Can apply method modifier'; + no Moose; +} use FindBin; -use lib "$FindBin::Bin/lib";use Test::More tests => 3; +use lib "$FindBin::Bin/lib"; -use Catalyst::Test qw/TestAppPluginWithNewMethod/; # 1 test for adding a modifer not throwing. +use Catalyst::Test qw/TestAppPluginWithNewMethod/; ok request('/foo')->is_success; is $TestAppPluginWithNewMethod::MODIFIER_FIRED, 1, 'Before modifier was fired correctly.';