[Bps-public-commit] Plack-Middleware-Test-StashWarnings branch, master, updated. 4e645ce69a040f675efdf425f642bbae4d202c5a
Shawn Moore
sartak at bestpractical.com
Tue Oct 19 08:27:54 EDT 2010
The branch, master has been updated
via 4e645ce69a040f675efdf425f642bbae4d202c5a (commit)
from 4fa3a1be348b4db986e401e8bfc35796016f964c (commit)
Summary of changes:
lib/Plack/Middleware/Test/StashWarnings.pm | 28 ++++++++++++++--------------
1 files changed, 14 insertions(+), 14 deletions(-)
- Log -----------------------------------------------------------------
commit 4e645ce69a040f675efdf425f642bbae4d202c5a
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Tue Oct 19 21:26:52 2010 +0900
Refactor the sigwarn handler
Having the same code twice is ooglay
diff --git a/lib/Plack/Middleware/Test/StashWarnings.pm b/lib/Plack/Middleware/Test/StashWarnings.pm
index b258886..b897b26 100644
--- a/lib/Plack/Middleware/Test/StashWarnings.pm
+++ b/lib/Plack/Middleware/Test/StashWarnings.pm
@@ -18,29 +18,29 @@ sub call {
return [ 200, ["Content-Type", "application/x-storable"], [ $self->dump_warnings ] ];
}
- local $SIG{__WARN__} = sub {
- push @{ $self->{stashed_warnings} }, @_;
- warn @_ if $ENV{TEST_VERBOSE};
- };
-
- my $ret = $self->app->($env);
+ my $ret = $self->_stash_warnings_for($self->app, $env);
# for the streaming API, we need to re-instate the dynamic sigwarn handler
# around the streaming callback
if (ref($ret) eq 'CODE') {
- my $original_ret = $ret;
- $ret = sub {
- local $SIG{__WARN__} = sub {
- push @{ $self->{stashed_warnings} }, @_;
- warn @_ if $ENV{TEST_VERBOSE};
- };
- $original_ret->(@_);
- };
+ return sub { $self->_stash_warnings_for($ret, @_) };
}
return $ret;
}
+sub _stash_warnings_for {
+ my $self = shift;
+ my $code = shift;
+
+ local $SIG{__WARN__} = sub {
+ push @{ $self->{stashed_warnings} }, @_;
+ warn @_ if $ENV{TEST_VERBOSE};
+ };
+
+ return $code->(@_);
+}
+
sub dump_warnings {
my $self = shift;
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list