Testing
Konstantin S. Uvarin
khedin at gmail.com
Sat Apr 20 10:55:45 CEST 2013
Hello, Dirk.
> The main issue, I suppose, is the need to have rendezvous between more
> than one output and to declare success or failure dependent not just on
> each output being correct but all outputs having appeared.
>
> Suggestions?
1) It looks like Async::MergePoint
(http://search.cpan.org/~pevans/Async-MergePoint-0.04/lib/Async/MergePoint.pm)
provides exactly what you're asking for - "a rendezvous between more
than one output".
I haven't tried it out myself yet, but I'm planning to.
2) I would also dare to suggest my own module AE::AdHoc. It's a beta
product at best, but it's designed specifically for tests like yours.
The syntax is like
use Ae::AdHoc;
my $data = ae_recv {
do_domething_1( when_done => ae_goal("one");
do_something_2( when_done => ae_goal("two");
} timeout => 10;
# here $data is { one => result_of_do_smth_1, two =>
result_of_do_smth_2 }
ae_recv{} just sets up a AE::condvar and a timer that croak()s after
time has expired (I *hate* when tests hang).
ae_goal() returns a callback that puts its arguments into the hash,
calling $cv->send when no unfinished tasks are left.
Hope that's interesting enough.
--
Konstantin S. Uvarin
More information about the anyevent
mailing list