[Catalyst-commits] r10046 - in Catalyst-Runtime/5.80/trunk: . lib/Catalyst t

kane at dev.catalyst.perl.org kane at dev.catalyst.perl.org
Thu May 7 15:14:17 GMT 2009


Author: kane
Date: 2009-05-07 15:14:16 +0000 (Thu, 07 May 2009)
New Revision: 10046

Modified:
   Catalyst-Runtime/5.80/trunk/
   Catalyst-Runtime/5.80/trunk/lib/Catalyst/Test.pm
   Catalyst-Runtime/5.80/trunk/t/unit_load_catalyst_test.t
Log:
 r8142 at myriad-wifi:  kane | 2009-05-07 17:13:37 +0200
 * perl5.8.8 + cat 5.80's Cat::Test->ctx_request didn't return $c the 2nd 
   time it was invoked. Without tracking the bug down all the way, it was
   clearly related to the Moose'ification of Cat::Test and a scoping issue
   with a 'my'd variable. Since the same code works fine in 5.10, a bug in
   either Moose or perl 5.8 is suspected.
   Khisanth++ for the elegant patch.



Property changes on: Catalyst-Runtime/5.80/trunk
___________________________________________________________________
Name: svk:merge
   - 1c72fc7c-9ce4-42af-bf25-3bfe470ff1e8:/local/Catalyst/trunk/Catalyst-Runtime:9763
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.70/branches/compres:7999
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.70/branches/context_go:8001
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.70/trunk:8533
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates:8363
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/add_captures_to_visit:9546
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/moose:7911
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-ChildOf:4443
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-Runtime-jrockway:5857
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-component-setup:4320
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-docs:4325
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/current/Catalyst-Runtime:5142
4ad37cd2-5fec-0310-835f-b3785c72a374:/trunk/Catalyst:4483
4ad37cd2-5fec-0310-835f-b3785c72a374:/trunk/Catalyst-Runtime:6165
d7608cd0-831c-0410-93c0-e5b306c3c028:/local/Catalyst/Catalyst-Runtime:8339
d7608cd0-831c-0410-93c0-e5b306c3c028:/local/Catalyst/Catalyst-Runtime-jrockway:8342
e56d974f-7718-0410-8b1c-b347a71765b2:/local/Catalyst-Runtime:6511
e56d974f-7718-0410-8b1c-b347a71765b2:/local/Catalyst-Runtime-current:10442
   + 1c72fc7c-9ce4-42af-bf25-3bfe470ff1e8:/local/Catalyst/trunk/Catalyst-Runtime:9763
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.70/branches/compres:7999
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.70/branches/context_go:8001
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.70/trunk:8533
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates:8363
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/add_captures_to_visit:9546
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/moose:7911
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-ChildOf:4443
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-Runtime-jrockway:5857
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-component-setup:4320
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-docs:4325
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/current/Catalyst-Runtime:5142
4ad37cd2-5fec-0310-835f-b3785c72a374:/trunk/Catalyst:4483
4ad37cd2-5fec-0310-835f-b3785c72a374:/trunk/Catalyst-Runtime:6165
8a9521aa-ff93-41d6-9f87-b05cafcdab40:/local/cat/Catalyst-Runtime/5.80/trunk:8142
d7608cd0-831c-0410-93c0-e5b306c3c028:/local/Catalyst/Catalyst-Runtime:8339
d7608cd0-831c-0410-93c0-e5b306c3c028:/local/Catalyst/Catalyst-Runtime-jrockway:8342
e56d974f-7718-0410-8b1c-b347a71765b2:/local/Catalyst-Runtime:6511
e56d974f-7718-0410-8b1c-b347a71765b2:/local/Catalyst-Runtime-current:10442

Modified: Catalyst-Runtime/5.80/trunk/lib/Catalyst/Test.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/lib/Catalyst/Test.pm	2009-05-07 13:43:18 UTC (rev 10045)
+++ Catalyst-Runtime/5.80/trunk/lib/Catalyst/Test.pm	2009-05-07 15:14:16 UTC (rev 10046)
@@ -38,19 +38,24 @@
         Catalyst::Exception->throw("$me only works with local requests, not remote")
             if $ENV{CATALYST_SERVER};
 
+        ### check explicitly for the class here, or the Cat->meta call will blow
+        ### up in our face
+        Catalyst::Exception->throw("Must specify a test app: use Catalyst::Test 'TestApp'") unless $class;
+
         ### place holder for $c after the request finishes; reset every time
         ### requests are done.
         my $c;
 
         ### hook into 'dispatch' -- the function gets called after all plugins
         ### have done their work, and it's an easy place to capture $c.
-        no warnings 'redefine';
-        my $dispatch = Catalyst->can('dispatch');
-        local *Catalyst::dispatch = sub {
+
+        my $meta = Catalyst->meta;
+        $meta->make_mutable;
+        $meta->add_after_method_modifier( "dispatch", sub {
             $c = shift;
-            $dispatch->( $c, @_ );
-        };
-
+        });
+        $meta->make_immutable;
+        
         ### do the request; C::T::request will know about the class name, and
         ### we've already stopped it from doing remote requests above.
         my $res = $request->( @_ );

Modified: Catalyst-Runtime/5.80/trunk/t/unit_load_catalyst_test.t
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/unit_load_catalyst_test.t	2009-05-07 13:43:18 UTC (rev 10045)
+++ Catalyst-Runtime/5.80/trunk/t/unit_load_catalyst_test.t	2009-05-07 15:14:16 UTC (rev 10046)
@@ -5,7 +5,7 @@
 
 use FindBin;
 use lib         "$FindBin::Bin/lib";
-use Test::More  tests => 56;
+use Test::More  tests => 59;
 use FindBin qw/$Bin/;
 use lib "$Bin/lib";
 use Catalyst::Utils;
@@ -92,6 +92,18 @@
     } }
 }
 
+### perl5.8.8 + cat 5.80's Cat::Test->ctx_request didn't return $c the 2nd 
+### time it was invoked. Without tracking the bug down all the way, it was
+### clearly related to the Moose'ification of Cat::Test and a scoping issue
+### with a 'my'd variable. Since the same code works fine in 5.10, a bug in
+### either Moose or perl 5.8 is suspected.
+{   ok( 1,                      "Testing consistency of ctx_request()" );
+    for( 1..2 ) {
+        my($res, $c) = ctx_request( $Url );
+        ok( $c,                 "   Call $_: Context object returned" );
+    }
+}    
+
 # FIXME - These vhosts in tests tests should be somewhere else...
 
 sub customize { Catalyst::Test::_customize_request(@_) }




More information about the Catalyst-commits mailing list