X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Flib%2FDBICTest%2FUtil%2FLeakTracer.pm;h=58790e4332e554294e1df777d7a00ee0808b03f9;hb=de4705b7393350ae7cde8f5409f204747c1a4a4e;hp=718a0aad396040881042e2f989bc169d5ea678d1;hpb=7664b1a03c8f4da961d1f9795c9af1d545a24ea1;p=dbsrgits%2FDBIx-Class.git diff --git a/t/lib/DBICTest/Util/LeakTracer.pm b/t/lib/DBICTest/Util/LeakTracer.pm index 718a0aa..58790e4 100644 --- a/t/lib/DBICTest/Util/LeakTracer.pm +++ b/t/lib/DBICTest/Util/LeakTracer.pm @@ -5,7 +5,7 @@ use strict; use Carp; use Scalar::Util qw(isweak weaken blessed reftype); -use DBIx::Class::_Util 'refcount'; +use DBIx::Class::_Util qw(refcount hrefaddr); use DBIx::Class::Optional::Dependencies; use Data::Dumper::Concise; use DBICTest::Util 'stacktrace'; @@ -15,14 +15,12 @@ use constant { }; use base 'Exporter'; -our @EXPORT_OK = qw(populate_weakregistry assert_empty_weakregistry hrefaddr visit_refs); +our @EXPORT_OK = qw(populate_weakregistry assert_empty_weakregistry visit_refs); my $refs_traced = 0; my $leaks_found = 0; my %reg_of_regs; -sub hrefaddr { sprintf '0x%x', &Scalar::Util::refaddr } - # so we don't trigger stringification sub _describe_ref { sprintf '%s%s(%s)', @@ -168,6 +166,9 @@ sub assert_empty_weakregistry { croak 'Expecting a registry hashref' unless ref $weak_registry eq 'HASH'; + defined $weak_registry->{$_}{weakref} or delete $weak_registry->{$_} + for keys %$weak_registry; + return unless keys %$weak_registry; my $tb = eval { Test::Builder->new }