Even saner diagnostics (view under diff -w)
Peter Rabbitson [Wed, 15 Jan 2014 15:19:54 +0000 (16:19 +0100)]
Now that we no longer store signs of "ref X was here but GCed" there is no
point in "No leaks of X" pass()es either

t/lib/DBICTest/Util/LeakTracer.pm

index 10dca61..794e83f 100644 (file)
@@ -170,35 +170,38 @@ sub assert_empty_weakregistry {
 
   for my $addr (sort { $weak_registry->{$a}{display_name} cmp $weak_registry->{$b}{display_name} } keys %$weak_registry) {
 
-    ! defined $weak_registry->{$addr}{weakref} and next if $quiet;
-
-    $tb->ok (! defined $weak_registry->{$addr}{weakref}, "No leaks of $weak_registry->{$addr}{display_name}") or do {
-      $leaks_found++;
-
-      my $diag = do {
-        local $Data::Dumper::Maxdepth = 1;
-        sprintf "\n%s (refcnt %d) => %s\n",
-          $weak_registry->{$addr}{display_name},
-          refcount($weak_registry->{$addr}{weakref}),
-          (
-            ref($weak_registry->{$addr}{weakref}) eq 'CODE'
-              and
-            B::svref_2object($weak_registry->{$addr}{weakref})->XSUB
-          ) ? '__XSUB__' : Dumper( $weak_registry->{$addr}{weakref} )
-        ;
-      };
-
-      $diag .= Devel::FindRef::track ($weak_registry->{$addr}{weakref}, 20) . "\n"
-        if ( $ENV{TEST_VERBOSE} && eval { require Devel::FindRef });
-
-      $diag =~ s/^/    /mg;
-
-      if (my $stack = $weak_registry->{$addr}{stacktrace}) {
-        $diag .= "    Reference first seen$stack";
-      }
-
-      $tb->diag($diag);
+    next if ! defined $weak_registry->{$addr}{weakref};
+
+    $leaks_found++;
+    $tb->ok (0, "Leaked $weak_registry->{$addr}{display_name}");
+
+    my $diag = do {
+      local $Data::Dumper::Maxdepth = 1;
+      sprintf "\n%s (refcnt %d) => %s\n",
+        $weak_registry->{$addr}{display_name},
+        refcount($weak_registry->{$addr}{weakref}),
+        (
+          ref($weak_registry->{$addr}{weakref}) eq 'CODE'
+            and
+          B::svref_2object($weak_registry->{$addr}{weakref})->XSUB
+        ) ? '__XSUB__' : Dumper( $weak_registry->{$addr}{weakref} )
+      ;
     };
+
+    $diag .= Devel::FindRef::track ($weak_registry->{$addr}{weakref}, 20) . "\n"
+      if ( $ENV{TEST_VERBOSE} && eval { require Devel::FindRef });
+
+    $diag =~ s/^/    /mg;
+
+    if (my $stack = $weak_registry->{$addr}{stacktrace}) {
+      $diag .= "    Reference first seen$stack";
+    }
+
+    $tb->diag($diag);
+  }
+
+  if (! $quiet and ! $leaks_found) {
+    $tb->ok(1, sprintf "No leaks found at %s line %d", (caller())[1,2] );
   }
 }