]> git.vpit.fr Git - perl/modules/Test-Valgrind.git/blobdiff - t/30-bad.t
Unload dynamically loaded libraries at END-time
[perl/modules/Test-Valgrind.git] / t / 30-bad.t
index 271772ebe94f61263fd56745794bfe73e9f3e1fb..11705875bad2913a456bb924506f6d2357a660a0 100644 (file)
@@ -3,15 +3,30 @@
 use strict;
 use warnings;
 
-use Config qw/%Config/;
-
 use Test::More;
 
+my $dbg;
+
 sub tester {
  my ($a, $desc) = @_;
  my $passed;
- my $dbg = eval "Test::Valgrind::DEBUGGING()";
- if ($desc =~ /still\s+reachable/) {
+ if (!defined $dbg) {
+  eval "
+   use lib qw{blib/arch};
+   require XSLoader;
+   XSLoader::load('Test::Valgrind', \$Test::Valgrind::VERSION);
+  ";
+  if ($@) {
+   my $err = $@;
+   $dbg = 0;
+   chomp $err;
+   diag "XS test code not available ($err)";
+  } else {
+   my $ret = eval "Test::Valgrind::DEBUGGING()";
+   $dbg = $@ ? 0 : $ret;
+  }
+ }
+ if ($desc =~ /definitely\s+lost/) {
   $passed = $a >= 9900 && $a < 10100;
   if ($dbg) {
    ok($passed, $desc);
@@ -29,18 +44,18 @@ sub tester {
  return $passed;
 }
 
-eval {
- require XSLoader;
- XSLoader::load('Test::Valgrind', 0.05);
-};
+use lib qw{blib/archpub};
+eval 'use Test::Valgrind cb => \&tester';
 if ($@) {
- plan skip_all => "XS test code not available ($@)";
+ diag $@;
+ plan skip_all => 'Test::Valgrind is required to run test your distribution with valgrind';
 } else {
- use lib qw{blib/archpub};
- eval 'use Test::Valgrind cb => \&tester;';
- if ($@) {
-  plan skip_all => 'Test::Valgrind is required to run test your distribution with valgrind';
- } else {
+ eval "
+  use lib qw{blib/arch};
+  require XSLoader;
+  XSLoader::load('Test::Valgrind', \$Test::Valgrind::VERSION);
+ ";
+ unless ($@) {
   Test::Valgrind::leak();
  }
 }