about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2023-09-08 12:54:12 +0000
committerEric Wong <e@80x24.org>2023-09-08 20:43:19 +0000
commit7a0f5c42a8e22a01c076ef38204d3ee9fa8b3af2 (patch)
tree20da6811fbd08ad1bc75b695f239427a0570ee95
parent8651b0487c4f2353e79d9088cd26d559bbe51948 (diff)
downloadpublic-inbox-7a0f5c42a8e22a01c076ef38204d3ee9fa8b3af2.tar.gz
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.
-rw-r--r--lib/PublicInbox/FakeInotify.pm3
-rw-r--r--t/dir_idle.t4
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 = ();