]> git.vpit.fr Git - perl/modules/Variable-Magic.git/commitdiff
Work around stray exits in t/40-threads.t and t/41-clone.t
authorVincent Pit <vince@profvince.com>
Mon, 20 Jul 2015 18:47:42 +0000 (15:47 -0300)
committerVincent Pit <vince@profvince.com>
Mon, 20 Jul 2015 22:34:26 +0000 (19:34 -0300)
t/40-threads.t
t/41-clone.t

index 9b2d2fa2c95fd59bfbf691ab9413cea011703006..151116bab11f44b9aebe5b25a1e6240380d8576a 100644 (file)
@@ -102,7 +102,8 @@ sub try {
    is $c, 1,  "get in thread $tid after dispell doesn't trigger magic";
   }
  }
- return; # Ugly if not here
+
+ return 1;
 }
 
 for my $dispell (1, 0) {
@@ -111,11 +112,16 @@ for my $dispell (1, 0) {
   $destroyed = 0;
  }
 
+ my $completed = 0;
+
  my @threads = map spawn(\&try, $dispell, $_), ('name') x 2, ('object') x 2;
- $_->join for @threads;
+ for my $thr (@threads) {
+  my $res = $thr->join;
+  $completed += $res if defined $res;
+ }
 
  {
   lock $destroyed;
-  is $destroyed, (1 - $dispell) * 4, 'destructors';
+  is $destroyed, (1 - $dispell) * $completed, 'destructors';
  }
 }
index 1efd250bd13f6c8a0b59c6401256f70804bda238..2058cc58ed67c14cec7219ef5cb71f3ccad802f4 100644 (file)
@@ -102,7 +102,7 @@ sub try {
   }
  }
 
- return;
+ return 1;
 }
 
 my $wiz_name = spawn_wiz VMG_OP_INFO_NAME;
@@ -119,16 +119,21 @@ for my $dispell (1, 0) {
    $destroyed = 0;
   }
 
+  my $completed = 0;
+
   my @threads = map spawn(\&try, $dispell, $wiz), 1 .. 2;
-  $_->join for @threads;
+  for my $thr (@threads) {
+   my $res = $thr->join;
+   $completed += $res if defined $res;
+  }
 
   {
    lock $c;
-   is $c, 2, "get triggered twice";
+   is $c, $completed, "get triggered twice";
   }
   {
    lock $destroyed;
-   is $destroyed, (1 - $dispell) * 2, 'destructors';
+   is $destroyed, (1 - $dispell) * $completed, 'destructors';
   }
  }
 }