]> git.vpit.fr Git - perl/modules/Test-Leaner.git/blobdiff - lib/Test/Leaner.pm
Fix and test thread safety
[perl/modules/Test-Leaner.git] / lib / Test / Leaner.pm
index f0f490eba2ed5f9930d44a8d7de7c5f10c5b15dd..c4c577d2dde61f0eeece12b0f6ccdf9c6ff1a721 100644 (file)
@@ -25,22 +25,26 @@ BEGIN {
  }
 }
 
-my ($plan, $test, $failed, $no_diag);
+my $TAP_STREAM  = *STDOUT;
+my $DIAG_STREAM = *STDERR;
+
+my ($plan, $test, $failed, $no_diag, $done_testing);
 
 sub NO_PLAN  () { -1 }
 sub SKIP_ALL () { -2 }
 
 BEGIN {
- threads::shared::share($plan), lock $plan if THREADSAFE;
+ if (THREADSAFE) {
+  threads::shared::share($_) for $plan, $test, $failed, $no_diag;
+ }
+
+ lock $plan if THREADSAFE;
 
  $plan   = undef;
  $test   = 0;
  $failed = 0;
 }
 
-my $TAP_STREAM  = *STDOUT;
-my $DIAG_STREAM = *STDERR;
-
 sub carp {
  my $level = 1 + ($Test::Builder::Level || 0);
  my ($file, $line) = (caller $level)[1, 2];
@@ -194,8 +198,6 @@ sub skip {
  last SKIP;
 }
 
-my $done_testing;
-
 sub done_testing {
  my ($count) = @_;