user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
0bb3b7585328dc2308c315019b80320c53e4508c blob 1472 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
 
#!perl -w
# Copyright (C) 2020-2021 all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
use v5.10.1; use strict; use PublicInbox::TestCommon;
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", "$tmpdir/c");
my @x;
my $cb = sub { push @x, \@_ };
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 });
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') 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;
debug log:

solving 0bb3b7585328 ...
found 0bb3b7585328 in https://80x24.org/public-inbox.git

Code repositories for project(s) associated with this inbox:

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).