about summary refs log tree commit homepage
path: root/t
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-05-14 20:14:47 +0000
committerEric Wong <e@80x24.org>2021-05-15 05:39:17 +0000
commit79e274b293a71fb41dd8bf6e9598a8e8a24fed4f (patch)
tree2847419f054afcd738b12c1a6fd3d130b9a4a3a1 /t
parent671e7f4c9d82b053fba475aaeaa16a94dc3adad2 (diff)
downloadpublic-inbox-79e274b293a71fb41dd8bf6e9598a8e8a24fed4f.tar.gz
We'll treat IN_MOVE_SELF as IN_DELETE_SELF since there
doesn't seem to be a reliable way to distinguish them
with FakeInotify, nor know the new name with kevent.
Diffstat (limited to 't')
-rw-r--r--t/dir_idle.t27
1 files changed, 24 insertions, 3 deletions
diff --git a/t/dir_idle.t b/t/dir_idle.t
index 969c16e9..0bb3b758 100644
--- a/t/dir_idle.t
+++ b/t/dir_idle.t
@@ -6,10 +6,10 @@ use PublicInbox::DS qw(now);
 use File::Path qw(make_path);
 use_ok 'PublicInbox::DirIdle';
 my ($tmpdir, $for_destroy) = tmpdir();
-make_path("$tmpdir/a/b");
+make_path("$tmpdir/a/b", "$tmpdir/c");
 my @x;
 my $cb = sub { push @x, \@_ };
-my $di = PublicInbox::DirIdle->new(["$tmpdir/a"], $cb, 1);
+my $di = PublicInbox::DirIdle->new(["$tmpdir/a", "$tmpdir/c"], $cb, 1);
 PublicInbox::DS->SetLoopTimeout(1000);
 my $end = 3 + now;
 PublicInbox::DS->SetPostLoopCallback(sub { scalar(@x) == 0 && now < $end });
@@ -17,6 +17,27 @@ tick(0.011);
 rmdir("$tmpdir/a/b") or xbail "rmdir $!";
 PublicInbox::DS->EventLoop;
 is(scalar(@x), 1, 'got an event') and
-        is($x[0]->[0]->fullname, "$tmpdir/a/b", 'got expected fullname');
+        is($x[0]->[0]->fullname, "$tmpdir/a/b", 'got expected fullname') and
+        ok($x[0]->[0]->IN_DELETE, 'IN_DELETE set');
+
+tick(0.011);
+rmdir("$tmpdir/a") or xbail "rmdir $!";
+@x = ();
+$end = 3 + now;
+PublicInbox::DS->EventLoop;
+is(scalar(@x), 1, 'got an event') and
+        is($x[0]->[0]->fullname, "$tmpdir/a", 'got expected fullname') and
+        ok($x[0]->[0]->IN_DELETE_SELF, 'IN_DELETE_SELF set');
+
+tick(0.011);
+rename("$tmpdir/c", "$tmpdir/j") or xbail "rmdir $!";
+@x = ();
+$end = 3 + now;
+PublicInbox::DS->EventLoop;
+is(scalar(@x), 1, 'got an event') and
+        is($x[0]->[0]->fullname, "$tmpdir/c", 'got expected fullname') and
+        ok($x[0]->[0]->IN_DELETE_SELF || $x[0]->[0]->IN_MOVE_SELF,
+                'IN_DELETE_SELF set on move');
+
 PublicInbox::DS->Reset;
 done_testing;