2 # Copyright all contributors <meta@public-inbox.org>
3 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
4 use strict; use v5.10.1; use PublicInbox::TestCommon;
5 use File::Basename qw(basename);
6 plan skip_all => "TEST_FLAKY not enabled for $0" if !$ENV{TEST_FLAKY};
7 my $have_fast_inotify = eval { require Linux::Inotify2 } ||
8 eval { require IO::KQueue };
10 diag("$0 IO::KQueue or Linux::Inotify2 missing, test will be slow");
13 my ($ro_home, $cfg_path) = setup_public_inboxes;
14 my $x = "$ENV{HOME}/x";
15 my $y = "$ENV{HOME}/y";
16 lei_ok qw(add-external), "$ro_home/t1";
17 lei_ok qw(q mid:testmessage@example.com -o), $x;
18 lei_ok qw(q mid:testmessage@example.com -o), $y;
19 my @x = glob("$x/cur/*");
20 my @y = glob("$y/cur/*");
21 scalar(@x) == 1 or xbail 'expected 1 file', \@x;
22 scalar(@y) == 1 or xbail 'expected 1 file', \@y;
24 my $oid = '9bf1002c49eb075df47247b74d69bcd555e23422';
25 lei_ok qw(inspect), "blob:$oid";
26 my $ins = json_utf8->decode($lei_out);
27 my $exp = { "maildir:$x" => [ map { basename($_) } @x ],
28 "maildir:$y" => [ map { basename($_) } @y ] };
29 is_deeply($ins->{'mail-sync'}, $exp, 'inspect as expected');
30 lei_ok qw(add-watch), $x;
31 my $dst = $x[0] . 'S';
32 rename($x[0], $dst) or xbail "rename($x[0], $dst): $!";
36 tick; # wait for inotify or kevent
38 my @y2 = glob("$y/*/*");
39 is_deeply(\@y2, [ $ys ], "`seen' kw propagated to `y' dir");
40 lei_ok qw(note-event done);
41 lei_ok qw(inspect), "blob:$oid";
42 $ins = json_utf8->decode($lei_out);
43 $exp = { "maildir:$x" => [ map { basename($_) } glob("$x/*/*") ],
44 "maildir:$y" => [ map { basename($_) } glob("$y/*/*") ] };
45 is_deeply($ins->{'mail-sync'}, $exp, 'mail_sync matches FS') or