]> git.vpit.fr Git - perl/modules/Variable-Magic.git/blobdiff - t/41-clone.t
Work around stray exits in t/40-threads.t and t/41-clone.t
[perl/modules/Variable-Magic.git] / t / 41-clone.t
index 6214741724b8e72c2d4123891873b9b9686735d4..2058cc58ed67c14cec7219ef5cb71f3ccad802f4 100644 (file)
@@ -1,18 +1,20 @@
-#!perl -T
+#!perl
 
 use strict;
 use warnings;
 
-use lib 't/lib';
-use Variable::Magic::TestThreads;
-
-use Test::More 'no_plan';
-
 use Variable::Magic qw<
  wizard cast dispell getdata
  VMG_OP_INFO_NAME VMG_OP_INFO_OBJECT
 >;
 
+use lib 't/lib';
+use VPIT::TestHelpers (
+ threads => [ 'Variable::Magic' => 'Variable::Magic::VMG_THREADSAFE()' ],
+);
+
+use Test::Leaner 'no_plan';
+
 my $destroyed : shared = 0;
 my $c         : shared = 0;
 
@@ -100,7 +102,7 @@ sub try {
   }
  }
 
- return;
+ return 1;
 }
 
 my $wiz_name = spawn_wiz VMG_OP_INFO_NAME;
@@ -117,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';
   }
  }
 }