diff options
Diffstat (limited to 't/dir_idle.t')
-rw-r--r-- | t/dir_idle.t | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/t/dir_idle.t b/t/dir_idle.t index 19e54967..8d085d6e 100644 --- a/t/dir_idle.t +++ b/t/dir_idle.t @@ -1,7 +1,7 @@ #!perl -w -# Copyright (C) 2020-2021 all contributors <meta@public-inbox.org> +# Copyright (C) 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 v5.12; use PublicInbox::TestCommon; use PublicInbox::DS qw(now); use File::Path qw(make_path); use_ok 'PublicInbox::DirIdle'; @@ -11,26 +11,30 @@ my @x; my $cb = sub { push @x, \@_ }; my $di = PublicInbox::DirIdle->new($cb); $di->add_watches(["$tmpdir/a", "$tmpdir/c"], 1); -PublicInbox::DS->SetLoopTimeout(1000); +$PublicInbox::DS::loop_timeout = 1000; my $end = 3 + now; -PublicInbox::DS->SetPostLoopCallback(sub { scalar(@x) == 0 && now < $end }); -tick(0.011); +local @PublicInbox::DS::post_loop_do = (sub { scalar(@x) == 0 && now < $end }); rmdir("$tmpdir/a/b") or xbail "rmdir $!"; PublicInbox::DS::event_loop(); -is(scalar(@x), 1, 'got an event') and +if (is(scalar(@x), 1, 'got an rmdir event')) { is($x[0]->[0]->fullname, "$tmpdir/a/b", 'got expected fullname') and ok($x[0]->[0]->IN_DELETE, 'IN_DELETE set'); +} else { + check_broken_tmpfs; + xbail explain(\@x); +} -tick(0.011); rmdir("$tmpdir/a") or xbail "rmdir $!"; @x = (); $end = 3 + now; PublicInbox::DS::event_loop(); -is(scalar(@x), 1, 'got an event') and +if (is(scalar(@x), 1, 'got an event after rmdir')) { 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); +} else { + check_broken_tmpfs; + diag explain(\@x); +} rename("$tmpdir/c", "$tmpdir/j") or xbail "rmdir $!"; @x = (); $end = 3 + now; @@ -40,5 +44,4 @@ is(scalar(@x), 1, 'got an event') 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; |