plugin new method test as-per various other plugins tests - shows issue with Hooks...
Tomas Doran [Fri, 2 Jan 2009 19:31:37 +0000 (19:31 +0000)]
Makefile.PL
TODO
lib/Catalyst.pm
t/lib/TestAppPluginWithNewMethod.pm [deleted file]
t/plugin_new_method_backcompat.t

index eb5f49a..9cf0e8e 100644 (file)
@@ -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 (file)
--- 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.
index 8a1167f..db307ab 100644 (file)
@@ -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 (file)
index 778f63d..0000000
+++ /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;
-}
index 7aaef8b..74e8f10 100644 (file)
@@ -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.';