[Rt-commit] rt branch, 4.0/collect-warnings-in-end-block-not-GD, created. rt-4.0.4-184-g483ec72
Ruslan Zakirov
ruz at bestpractical.com
Thu Jan 12 16:01:52 EST 2012
The branch, 4.0/collect-warnings-in-end-block-not-GD has been created
at 483ec7229e68b676b82464e70b8b8ea77d996a79 (commit)
- Log -----------------------------------------------------------------
commit 483ec7229e68b676b82464e70b8b8ea77d996a79
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Fri Jan 13 00:54:24 2012 +0400
call ::Test::Web->no_warnings_ok before GD
Most instances of RT::Test::Web class are destroyed
during global destruction. We call ->no_warnings_ok
in DESTROY and It's just luck we don't hit problems.
Use END block instead.
diff --git a/lib/RT/Test/Web.pm b/lib/RT/Test/Web.pm
index 28ca3b8..ee87a28 100644
--- a/lib/RT/Test/Web.pm
+++ b/lib/RT/Test/Web.pm
@@ -52,15 +52,19 @@ use strict;
use warnings;
use base qw(Test::WWW::Mechanize);
+use Scalar::Util qw(weaken);
-require RT::Test;
+BEGIN { require RT::Test; }
require Test::More;
+my $instance;
+
sub new {
my ($class, @args) = @_;
push @args, app => $RT::Test::TEST_APP if $RT::Test::TEST_APP;
- my $self = $class->SUPER::new(@args);
+ my $self = $instance = $class->SUPER::new(@args);
+ weaken $instance;
$self->cookie_jar(HTTP::Cookies->new);
return $self;
@@ -370,4 +374,10 @@ sub DESTROY {
}
}
+END {
+ return unless $instance;
+ return if RT::Test->builder->{Original_Pid} != $$;
+ $instance->no_warnings_ok if !$RT::Test::Web::DESTROY++;
+}
+
1;
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list