[Bps-public-commit] Plack-Middleware-Test-StashWarnings branch, master, updated. 8703418a46748917e758cfdb7886414247a908eb

Shawn Moore sartak at bestpractical.com
Tue Nov 9 14:08:24 EST 2010


The branch, master has been updated
       via  8703418a46748917e758cfdb7886414247a908eb (commit)
       via  56e563b4e19b3afb52cb0cec0275c4a0b176a8ec (commit)
       via  b6819269c980359deb41a10375899a291ec6c467 (commit)
       via  4cf310269808a1967a80d339e51ec697684ad7fe (commit)
       via  d2dedaa9a7aba1b9f4a9900ac0961b61e7cc0000 (commit)
       via  e992bb9e1944c30238b33241d73e308b761a9220 (commit)
       via  c5f2c1e931bc39aca424065bfed0610b264810f1 (commit)
      from  4e645ce69a040f675efdf425f642bbae4d202c5a (commit)

Summary of changes:
 Changes                                    |    3 +++
 lib/Plack/Middleware/Test/StashWarnings.pm |    4 ++--
 t/destroy.t                                |   23 +++++++++++++++--------
 3 files changed, 20 insertions(+), 10 deletions(-)

- Log -----------------------------------------------------------------
commit c5f2c1e931bc39aca424065bfed0610b264810f1
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Mon Nov 8 20:37:35 2010 -0500

    destroy.t doesn't use thaw

diff --git a/t/destroy.t b/t/destroy.t
index 0a33d58..517c4c6 100644
--- a/t/destroy.t
+++ b/t/destroy.t
@@ -6,8 +6,6 @@ use HTTP::Request::Common;
 use Plack::Builder;
 use Plack::Request;
 
-use Storable 'thaw';
-
 my $app = sub {
     my $req = Plack::Request->new(shift);
     my $name = $req->param('name');

commit e992bb9e1944c30238b33241d73e308b761a9220
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Mon Nov 8 20:51:49 2010 -0500

    Skip on 5.8 and lower
    
        Better ideas welcome :/

diff --git a/t/destroy.t b/t/destroy.t
index 517c4c6..a2a59fd 100644
--- a/t/destroy.t
+++ b/t/destroy.t
@@ -1,8 +1,13 @@
 use strict;
 use Plack::Test;
 use Test::More;
-use HTTP::Request::Common;
 
+BEGIN {
+    plan skip_all => "Perls before 5.10 break this DESTROY-based test"
+        if $] < 5.010;
+}
+
+use HTTP::Request::Common;
 use Plack::Builder;
 use Plack::Request;
 

commit d2dedaa9a7aba1b9f4a9900ac0961b61e7cc0000
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Tue Nov 9 11:08:12 2010 -0500

    Revert "Skip on 5.8 and lower"
    
    This reverts commit e992bb9e1944c30238b33241d73e308b761a9220.

diff --git a/t/destroy.t b/t/destroy.t
index a2a59fd..517c4c6 100644
--- a/t/destroy.t
+++ b/t/destroy.t
@@ -1,13 +1,8 @@
 use strict;
 use Plack::Test;
 use Test::More;
-
-BEGIN {
-    plan skip_all => "Perls before 5.10 break this DESTROY-based test"
-        if $] < 5.010;
-}
-
 use HTTP::Request::Common;
+
 use Plack::Builder;
 use Plack::Request;
 

commit 4cf310269808a1967a80d339e51ec697684ad7fe
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Mon Nov 8 20:26:39 2010 -0500

    Switch from using Plack::Builder

diff --git a/t/destroy.t b/t/destroy.t
index 517c4c6..9909946 100644
--- a/t/destroy.t
+++ b/t/destroy.t
@@ -3,7 +3,7 @@ use Plack::Test;
 use Test::More;
 use HTTP::Request::Common;
 
-use Plack::Builder;
+use Plack::Middleware::Test::StashWarnings;
 use Plack::Request;
 
 my $app = sub {
@@ -18,12 +18,10 @@ local $SIG{__WARN__} = sub {
 };
 
 {
-    my $t = builder {
-        enable "Test::StashWarnings";
-        $app;
-    };
+    my $mw = Plack::Middleware::Test::StashWarnings->new;
+    my $new_app = $mw->wrap($app);
 
-    test_psgi $t, sub {
+    test_psgi $new_app, sub {
         my $cb = shift;
 
         my $res = $cb->(GET "/");

commit b6819269c980359deb41a10375899a291ec6c467
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Tue Nov 9 11:09:51 2010 -0500

    Throw away the warnings we have during DESTROY

diff --git a/lib/Plack/Middleware/Test/StashWarnings.pm b/lib/Plack/Middleware/Test/StashWarnings.pm
index b897b26..405102a 100644
--- a/lib/Plack/Middleware/Test/StashWarnings.pm
+++ b/lib/Plack/Middleware/Test/StashWarnings.pm
@@ -49,7 +49,7 @@ sub dump_warnings {
 
 sub DESTROY {
     my $self = shift;
-    for (@{ $self->{stashed_warnings} }) {
+    for (splice @{ $self->{stashed_warnings} }) {
         warn "Unhandled warning: $_";
     }
 }

commit 56e563b4e19b3afb52cb0cec0275c4a0b176a8ec
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Tue Nov 9 11:10:05 2010 -0500

    5.8.x support for destroy.t
    
        The codepath does work but the test works differently on 5.8 because
        there's a memory cycle in Plack somewhere which keeps the middleware
        alive. But not on 5.12!

diff --git a/t/destroy.t b/t/destroy.t
index 9909946..d56c61d 100644
--- a/t/destroy.t
+++ b/t/destroy.t
@@ -2,6 +2,7 @@ use strict;
 use Plack::Test;
 use Test::More;
 use HTTP::Request::Common;
+use Scalar::Util 'weaken';
 
 use Plack::Middleware::Test::StashWarnings;
 use Plack::Request;
@@ -17,10 +18,13 @@ local $SIG{__WARN__} = sub {
     push @warnings, @_;
 };
 
+my $weak_mw;
 {
     my $mw = Plack::Middleware::Test::StashWarnings->new;
     my $new_app = $mw->wrap($app);
 
+    weaken($weak_mw = $mw);
+
     test_psgi $new_app, sub {
         my $cb = shift;
 
@@ -32,6 +36,13 @@ local $SIG{__WARN__} = sub {
     is @warnings, 0, "no warnings yet";
 }
 
+# XXX: on 5.8.x we have to explicitly trigger the destructor because there's a memory leak
+# so the destructor isn't called til global destruction. which is actually *fine* except
+# when you want to test for the destructor's behavior
+if ($weak_mw) {
+    $weak_mw->DESTROY;
+}
+
 is @warnings, 1, "caught one warning";
 like $warnings[0], qr/Unhandled warning: Use of uninitialized value (?:\$name )?in concatenation/;
 

commit 8703418a46748917e758cfdb7886414247a908eb
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Tue Nov 9 11:21:55 2010 -0500

    0.03 and its changes

diff --git a/Changes b/Changes
index f58cd5f..06c15af 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,8 @@
 Revision history for Perl extension Plack::Middleware::Test::StashWarnings
 
+0.03  2010-11-09
+        - fix failing test on 5.8
+
 0.02  2010-10-19
         - streaming API support (clkao++ for the assist)
 
diff --git a/lib/Plack/Middleware/Test/StashWarnings.pm b/lib/Plack/Middleware/Test/StashWarnings.pm
index 405102a..6232d40 100644
--- a/lib/Plack/Middleware/Test/StashWarnings.pm
+++ b/lib/Plack/Middleware/Test/StashWarnings.pm
@@ -2,7 +2,7 @@ package Plack::Middleware::Test::StashWarnings;
 
 use strict;
 use 5.008_001;
-our $VERSION = '0.02';
+our $VERSION = '0.03';
 
 use parent qw(Plack::Middleware);
 use Carp ();

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list