]> git.vpit.fr Git - perl/modules/Test-Valgrind.git/blobdiff - lib/Test/Valgrind.pm
This is 0.06
[perl/modules/Test-Valgrind.git] / lib / Test / Valgrind.pm
index fa79775c2efb2be24be053fc42c19e09e822de5f..34ff5d903cc5c75ee06c7b2152870749ec789047 100644 (file)
@@ -17,11 +17,11 @@ Test::Valgrind - Test Perl code through valgrind.
 
 =head1 VERSION
 
-Version 0.04
+Version 0.06
 
 =cut
 
-our $VERSION = '0.04';
+our $VERSION = '0.06';
 
 =head1 SYNOPSIS
 
@@ -39,6 +39,8 @@ You can also use it from the command-line to test a given script :
 
     perl -MTest::Valgrind leaky.pl
 
+Due to the nature of perl's memory allocator, this module can't track leaks of Perl objects. This includes non-mortalized scalars and memory cycles. However, it can track leaks of chunks of memory allocated in XS extensions with C<Newx> and friends or C<malloc>. As such, it's complementary to the other very good leak detectors listed in the L</SEE ALSO> section.
+
 =head1 CONFIGURATION
 
 You can pass parameters to C<import> as a list of key / value pairs, where valid keys are :
@@ -112,14 +114,23 @@ sub import {
  croak 'Optional arguments must be passed as key => value pairs' if @_ % 2;
  my %args = @_;
  if (!defined $args{run} && !$run) {
-  my ($file, $next);
+  my ($file, $pm, $next);
   my $l = 0;
   while ($l < 1000) {
    $next = (caller $l++)[1];
    last unless defined $next;
-   $file = $next;
+   next unless $next ne '-e' and $next !~ /^\s*\(\s*eval\s*\d*\s*\)\s*$/
+                             and -f $next;
+   if ($next =~ /\.pm$/) {
+    $pm = $next;
+   } else {
+    $file = $next;
+   }
+  }
+  unless (defined $file) {
+   $file = $pm;
+   return unless defined $pm;
   }
-  return if not $file or $file eq '-e';
   my $callers = $args{callers};
   $callers = 12 unless defined $callers;
   $callers = int $callers;
@@ -225,6 +236,10 @@ L<Carp>, L<POSIX> (core modules since perl 5) and L<Test::More> (since 5.6.2).
 
 L<Perl::Destruct::Level>.
 
+=head1 SEE ALSO
+
+L<Devel::Leak>, L<Devel::LeakTrace>, L<Devel::LeakTrace::Fast>.
+
 =head1 AUTHOR
 
 Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.