]> git.imager.perl.org - poe-xs-queue-array.git/commitdiff
use CLONE_SKIP to ignore threads
authorTony Cook <tony@develop=help.com>
Sun, 15 Mar 2009 00:28:39 +0000 (00:28 +0000)
committerTony Cook <tony@develop=help.com>
Sun, 15 Mar 2009 00:28:39 +0000 (00:28 +0000)
fix the test code to work with pseudo-fork's real behaviour

Array.pm
t/05_pfork.t

index 3ea293d6fe4e5f1cdb6ce5c048202c17ec12eb48..4f76f0c7140ea45716c4ec5b870d8679bc00e511 100644 (file)
--- a/Array.pm
+++ b/Array.pm
@@ -31,6 +31,8 @@ sub import {
   *{ $package . '::ITEM_PAYLOAD'  } = \&ITEM_PAYLOAD;
 }
 
+sub CLONE_SKIP { 1 }
+
 # everything else is XS
 1;
 
index fc2993e2b7e763584809355024f6824e746d3944..1683753e0c58c131b9c55d09328a2e4d3815a316 100644 (file)
@@ -1,24 +1,47 @@
 #!perl -w
 use strict;
-use Test::More;
 use POE::XS::Queue::Array;
 use Config;
 
 $^O eq 'MSWin32'
-  or plan skip_all => "You probably have a sane fork(), not testing";
+  or skip_all("You probably have a sane fork(), not testing");
 
 $Config{useithreads} && $Config{useithreads} eq 'define'
-  or plan skip_all => "No ithreads to support pseudo-fork";
+  or skip_all("No ithreads to support pseudo-fork");
 
-plan tests => 2;
+sub nok($$$);
+
+print "1..2\n";
 
 {
   my $q1 = POE::XS::Queue::Array->new;
   $q1->enqueue(100, 101);
-  if (!fork) {
+  my $pid = fork;
+  if (!$pid) {
     # child
-    is($q1, undef, "queue object should be magically undef");
+    nok(1, !eval { $q1->isa("POE::XS::Queue::Array") },
+       "queue object should be magically unblessed");
     exit;
   }
-  isa_ok($q1, "POE::XS::Queue::Array", "parent should still have an object");
+  wait();
+  nok(2, eval {$q1->isa("POE::XS::Queue::Array") },
+      "parent should still have an object");
+}
+
+# since we use fork, Test::More can't track test numbers, so we set them manually
+sub nok ($$$) {
+  my ($num, $ok, $msg) = @_;
+
+  if ($ok) {
+    print "ok $num # $msg\n";
+  }
+  else {
+    print "not ok $num # $msg\n";
+  }
+  $ok;
+}
+
+sub skip_all {
+  print "1..0 # $_[0]\n";
+  exit;
 }