It actually needs to be bigger than the polling interval.
I suspect I missed this due to parallel tests on a loaded
VM, but running t/dir_idle.t on an unloaded machine reproduces
the problem when neither IO::KQueue nor Linux::Inotify2 are
present.
---
 lib/PublicInbox/FakeInotify.pm | 3 ++-
 t/dir_idle.t                   | 4 +++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/PublicInbox/FakeInotify.pm b/lib/PublicInbox/FakeInotify.pm
index 3a09b030..8be07135 100644
--- a/lib/PublicInbox/FakeInotify.pm
+++ b/lib/PublicInbox/FakeInotify.pm
@@ -92,7 +92,8 @@ sub dir_adj ($) {
        my ($old_ctime) = @_;
        my $now = Time::HiRes::time;
        my $diff = $now - $old_ctime;
-       ($diff > -1 && $diff < 1) ? 1 : 0;
+       my $adj = $poll_intvl + 1;
+       ($diff > -$adj && $diff < $adj) ? 1 : 0;
 }
 
 # behaves like non-blocking Linux::Inotify2->read
diff --git a/t/dir_idle.t b/t/dir_idle.t
index 9e66cc58..bb6f47eb 100644
--- a/t/dir_idle.t
+++ b/t/dir_idle.t
@@ -16,9 +16,11 @@ my $end = 3 + now;
 local @PublicInbox::DS::post_loop_do = (sub { scalar(@x) == 0 && now < $end });
 rmdir("$tmpdir/a/b") or xbail "rmdir $!";
 PublicInbox::DS::event_loop();
-is(scalar(@x), 1, 'got an rmdir event') and
+is(scalar(@x), 1, 'got an rmdir event') or xbail explain(\@x);
+if (@x) {
        is($x[0]->[0]->fullname, "$tmpdir/a/b", 'got expected fullname') and
        ok($x[0]->[0]->IN_DELETE, 'IN_DELETE set');
+}
 
 rmdir("$tmpdir/a") or xbail "rmdir $!";
 @x = ();

Reply via email to