X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Flei-watch.t;h=df887a03dc77fb0af6f79290d4814504a8e0dff6;hb=e6b5ef6a248f5808fff0483f02bd73dcbfea8c0a;hp=492f6c1d7790e8e58d6ce6bd40905e609dbfb852;hpb=a1539672716f91acc67397a1a7d16e99df068931;p=public-inbox.git diff --git a/t/lei-watch.t b/t/lei-watch.t index 492f6c1d..df887a03 100644 --- a/t/lei-watch.t +++ b/t/lei-watch.t @@ -2,7 +2,7 @@ # Copyright all contributors # License: AGPL-3.0+ use strict; use v5.10.1; use PublicInbox::TestCommon; -use File::Path qw(make_path); +use File::Path qw(make_path remove_tree); require_mods('lei'); my $have_fast_inotify = eval { require Linux::Inotify2 } || eval { require IO::KQueue }; @@ -25,7 +25,7 @@ test_lei(sub { lei_ok 'daemon-pid'; chomp(my $pid = $lei_out); skip 'missing /proc/$PID/fd', 1 if !-d "/proc/$pid/fd"; my @ino = grep { - readlink($_) =~ /\binotify\b/ + (readlink($_) // '') =~ /\binotify\b/ } glob("/proc/$pid/fd/*"); is(scalar(@ino), 1, 'only one inotify FD'); my $ino_fd = (split('/', $ino[0]))[-1]; @@ -52,7 +52,7 @@ test_lei(sub { my @f = glob("$md/cur/*:2,"); is(scalar(@f), 1, 'got populated maildir with one result'); rename($f[0], "$f[0]S") or xbail "rename $!"; # set (S)een - $have_fast_inotify or tick(2); + tick($have_fast_inotify ? 0.1 : 2.1); # always needed for 1 CPU systems lei_ok qw(note-event done); # flushes immediately (instead of 5s) lei_ok qw(q mid:testmessage@example.com -o), $md2, '-I', "$ro_home/t1"; @@ -71,9 +71,19 @@ test_lei(sub { 'inotify has Maildir watches'); } - is(xsys(qw(git config -f), $cfg_f, - '--remove-section', "watch.maildir:$md"), - 0, 'unset config state'); + lei_ok 'rm-watch', $md; + lei_ok 'ls-watch', \'refresh watches'; + is($lei_out, '', 'no watches left'); + + lei_ok 'add-watch', $md2; + remove_tree($md2); + lei_ok 'rm-watch', "maildir:".$md2, \'with maildir: prefix'; + lei_ok 'ls-watch', \'refresh watches'; + is($lei_out, '', 'no watches left'); + + lei_ok 'add-watch', $md; + remove_tree($md); + lei_ok 'rm-watch', $md, \'absolute path w/ missing dir'; lei_ok 'ls-watch', \'refresh watches'; is($lei_out, '', 'no watches left'); @@ -81,7 +91,7 @@ test_lei(sub { $ino_fdinfo or skip 'Linux/inotify-only removal removal', 1; open my $fh, '<', $ino_fdinfo or xbail "open $ino_fdinfo: $!"; my $cmp = [ <$fh> ]; - is_deeply($cmp, $ino_contents, 'inotify Maildir watches gone'); + is_xdeeply($cmp, $ino_contents, 'inotify Maildir watches gone'); }; });