From: Peter Rabbitson Date: Thu, 26 Feb 2015 22:25:39 +0000 (+0100) Subject: Get the leaktest to work with Test::More-(hopefully-not)-to-be X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ee20935b61ef210ea2d05fcf03cd3c28e07ef21b;p=dbsrgits%2FDBIx-Class.git Get the leaktest to work with Test::More-(hopefully-not)-to-be --- diff --git a/t/52leaks.t b/t/52leaks.t index 8140113..dad4f36 100644 --- a/t/52leaks.t +++ b/t/52leaks.t @@ -23,34 +23,24 @@ use Test::More; use lib qw(t/lib); use DBICTest::RunMode; +use DBICTest::Util::LeakTracer qw(populate_weakregistry assert_empty_weakregistry visit_refs); +use Scalar::Util qw(weaken blessed reftype); +use DBIx::Class::_Util qw(hrefaddr sigwarn_silencer modver_gt_or_eq modver_gt_or_eq_and_lt); +BEGIN { + plan skip_all => "Your perl version $] appears to leak like a sieve - skipping test" + if DBIx::Class::_ENV_::PEEPEENESS; +} -plan skip_all => "Temporarily no smoke testing of Test::More 1.3xx alphas" if ( - DBICTest::RunMode->is_smoker - and - eval { Test::More->VERSION("1.300") } - and - require ExtUtils::MakeMaker - and - MM->parse_version($INC{"Test/Builder.pm"}) =~ / ^ 1 \. 3.. ... \_ /x -); my $TB = Test::More->builder; if ($ENV{DBICTEST_IN_PERSISTENT_ENV}) { - # without this explicit close older TBs warn in END after a ->reset - if ($TB->VERSION < 1.005) { - close ($TB->$_) for (qw/output failure_output todo_output/); - } - - # if I do not do this, I get happy sigpipes on new TB, no idea why - # (the above close-and-forget doesn't work - new TB does *not* reopen - # its handles automatically anymore) - else { - for (qw/failure_output todo_output/) { - close $TB->$_; - open ($TB->$_, '>&', *STDERR); - } + # without this explicit close TB warns in END after a ->reset + close ($TB->$_) for qw(output failure_output todo_output); - close $TB->output; + # newer TB does not auto-reopen handles + if ( modver_gt_or_eq( 'Test::More', '1.200' ) ) { + open ($TB->$_, '>&', *STDERR) + for qw( failure_output todo_output ); open ($TB->output, '>&', *STDOUT); } @@ -58,15 +48,6 @@ if ($ENV{DBICTEST_IN_PERSISTENT_ENV}) { $TB->reset; } -use DBICTest::Util::LeakTracer qw(populate_weakregistry assert_empty_weakregistry visit_refs); -use Scalar::Util qw(weaken blessed reftype); -use DBIx::Class; -use DBIx::Class::_Util qw(hrefaddr sigwarn_silencer); -BEGIN { - plan skip_all => "Your perl version $] appears to leak like a sieve - skipping test" - if DBIx::Class::_ENV_::PEEPEENESS; -} - # this is what holds all weakened refs to be checked for leakage my $weak_registry = {}; @@ -98,7 +79,7 @@ unless (DBICTest::RunMode->is_plain) { # Test Builder is now making a new object for every pass/fail (que bloat?) # and as such we can't really store any of its objects (since it will # re-populate the registry while checking it, ewwww!) - return $obj if (ref $obj) =~ /^TB2::/; + return $obj if (ref $obj) =~ /^TB2::|^Test::Stream/; # populate immediately to avoid weird side effects return populate_weakregistry ($weak_registry, $obj ); @@ -545,6 +526,9 @@ SKIP: { skip 'Main test failed - skipping persistent env tests', 1 unless $TB->is_passing; + skip "Test::Builder\@@{[ Test::Builder->VERSION ]} known to break persistence tests", 1 + if modver_gt_or_eq_and_lt( 'Test::More', '1.200', '1.301001_099' ); + local $ENV{DBICTEST_IN_PERSISTENT_ENV} = 1; $persistence_tests = {