]> git.vpit.fr Git - perl/modules/Test-Leaner.git/blobdiff - lib/Test/Leaner.pm
Turn autoflush on as soon as the module is loaded
[perl/modules/Test-Leaner.git] / lib / Test / Leaner.pm
index dfba80f1505119d9e795865661fbe6264413b0fb..1efe7a295183bf1f285b059b82cc57fe635c9b24 100644 (file)
@@ -28,6 +28,12 @@ BEGIN {
 my $TAP_STREAM  = *STDOUT;
 my $DIAG_STREAM = *STDERR;
 
+for ($TAP_STREAM, $DIAG_STREAM) {
+ my $fh = select $_;
+ $|++;
+ select $fh;
+}
+
 my ($plan, $test, $failed, $no_diag, $done_testing);
 
 sub NO_PLAN  () { -1 }
@@ -35,7 +41,7 @@ sub SKIP_ALL () { -2 }
 
 BEGIN {
  if (THREADSAFE) {
-  threads::shared::share($_) for $plan, $test, $failed, $no_diag;
+  threads::shared::share($_) for $plan, $test, $failed, $no_diag, $done_testing;
  }
 
  lock $plan if THREADSAFE;
@@ -96,12 +102,6 @@ sub plan {
   croak("plan() doesn't understand @args");
  }
 
- {
-  my $fh = select $TAP_STREAM;
-  $|++;
-  select $fh;
- }
-
  if (defined $plan_str) {
   local $\;
   print $TAP_STREAM "$plan_str\n";
@@ -143,6 +143,7 @@ sub import {
     push @imports, @{ $_[$i+1] };
     $splice  = 2;
    } elsif ($item eq 'no_diag') {
+    lock $plan if THREADSAFE;
     $no_diag = 1;
     $splice  = 1;
    }