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::Path qw(make_path);
7 my $have_fast_inotify = eval { require Linux::Inotify2 } ||
8 eval { require IO::KQueue };
11 diag("$0 IO::KQueue or Linux::Inotify2 missing, test will be slow");
13 my ($ro_home, $cfg_path) = setup_public_inboxes;
15 my $md = "$ENV{HOME}/md";
18 is($lei_out, '', 'nothing in ls-watch, yet');
20 my $url = 'imaps://example.com/foo.bar.0';
21 lei_ok([qw(add-watch --state=pause), $url], undef, {});
23 is($lei_out, "$url\n", 'ls-watch shows added watch');
24 ok(!lei(qw(add-watch --state=pause), 'bogus'.$url),
25 'bogus URL rejected');
28 # first, make sure tag-ro works
29 make_path("$md/new", "$md/cur", "$md/tmp");
30 lei_ok qw(add-watch --state=tag-ro), $md;
32 like($lei_out, qr/^\Qmaildir:$md\E$/sm, 'maildir shown');
33 lei_ok qw(q mid:testmessage@example.com -o), $md, '-I', "$ro_home/t1";
34 my @f = glob("$md/cur/*:2,");
35 is(scalar(@f), 1, 'got populated maildir with one result');
36 rename($f[0], "$f[0]S") or xbail "rename $!"; # set (S)een
37 $have_fast_inotify or tick(2);
38 lei_ok qw(note-event done); # flushes immediately (instead of 5s)
40 lei_ok qw(q mid:testmessage@example.com -o), $md2, '-I', "$ro_home/t1";
41 my @f2 = glob("$md2/*/*");
42 is(scalar(@f2), 1, 'got one result');
43 like($f2[0], qr/S\z/, 'seen set from rename');
44 my $e2 = eml_load($f2[0]);
45 my $e1 = eml_load("$f[0]S");
46 is_deeply($e2, $e1, 'results match');