I am trying to test a logging module which asynchronously writes to a file... the unit test tries to read the log to make sure the written message matches expected. However, I am finding that the asynchronous writes by the module don't reach the file until after the unit tests are finished, even if I sleep to wait on the file for an arbitrary length of time. I verified that the files aren't getting closed until the very end by adding a print statement next to the aio_close. What can I do to test this?
#approximately the way this works:
aio_open($pathname,
$flags,
$mode,
sub
{
my $fh = shift;
aio_write($fh,
0,
length($log),
$log,
0,
sub
{
print "here";
aio_close($fh, sub {});
});
});