--- AnyEvent/t/62_cocoa_03_child.t 2011/07/04 21:14:27 1.2 +++ AnyEvent/t/62_cocoa_03_child.t 2011/10/01 22:39:29 1.6 @@ -19,8 +19,11 @@ } use AnyEvent; -BEGIN { eval q{use AnyEvent::Impl::Cocoa;1} or ((print qq{1..0 # SKIP AnyEvent::Impl::Cocoa not loadable -}), exit 0) } + + BEGIN { $ENV{PERL_ANYEVENT_LOOP_TESTS} or ((print qq{1..0 # SKIP PERL_ANYEVENT_LOOP_TESTS not true\n}), exit 0) } + BEGIN { eval q{use AnyEvent::Impl::Cocoa;1} or ((print qq{1..0 # SKIP AnyEvent::Impl::Cocoa not loadable\n}), exit 0) } + + $| = 1; print "1..50\n"; @@ -35,29 +38,31 @@ defined $pid or die "unable to fork"; -# work around Tk bug until it has been fixed. -#my $timer = AnyEvent->timer (after => 2, cb => sub { }); + # work around Tk bug until it has been fixed. + #my $timer = AnyEvent->timer (after => 2, cb => sub { }); my $cv = AnyEvent->condvar; unless ($pid) { - print "ok ${it}2\n"; + print "ok ${it}2 # child $$\n"; POSIX::_exit 3; } - my $w = AnyEvent->child (pid => $pid, cb => sub { print $pid == $_[0] ? "" : "not ", "ok ${it}3\ # $pid == $_[0]\n"; print 3 == ($_[1] >> 8) ? "" : "not ", "ok ${it}4 # 3 == $_[1] >> 8 ($_[1])\n"; $cv->broadcast; }); - $cv->wait; + $cv->recv; my $pid2 = fork || POSIX::_exit 7; my $cv2 = AnyEvent->condvar; - my $w2 = AnyEvent->child (pid => 0, cb => sub { + # Glib is the only model that doesn't support pid == 0 + my $pid0 = $AnyEvent::MODEL eq "AnyEvent::Impl::Glib" ? $pid2 : 0; + + my $w2 = AnyEvent->child (pid => $pid0, cb => sub { print $pid2 == $_[0] ? "" : "not ", "ok ${it}5 # $pid2 == $_[0]\n"; print 7 == ($_[1] >> 8) ? "" : "not ", "ok ${it}6 # 7 == $_[1] >> 8 ($_[1])\n"; $cv2->broadcast; @@ -70,7 +75,7 @@ exit 0; }); - $cv2->wait; + $cv2->recv; print "ok ${it}7\n"; print "ok ${it}8\n";