2 # Copyright (C) all contributors <meta@public-inbox.org>
3 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
5 use PublicInbox::TestCommon;
7 my ($tmpdir, $for_destroy) = tmpdir();
8 use_ok 'PublicInbox::TailNotify';
10 open my $fh, '>>', $f or xbail $!;
11 my $tn = PublicInbox::TailNotify->new($f);
12 my @x = $tn->getlines(1);
13 is_deeply(\@x, [], 'nothing, yet');
14 my $pid = fork // xbail "fork: $!";
17 syswrite $fh, "hi\n" // xbail "syswrite: $!";
21 is_deeply(\@x, [ "hi\n" ], 'got line');
22 waitpid($pid, 0) // xbail "waitpid: $!";
23 is($?, 0, 'writer done');
25 $pid = fork // xbail "fork: $!";
28 unlink $f // xbail "unlink($f): $!";
29 open $fh, '>>', $f or xbail $!;
30 syswrite $fh, "bye\n" // xbail "syswrite: $!";
34 is_deeply(\@x, [ "bye\n" ], 'got line after reopen');
35 waitpid($pid, 0) // xbail "waitpid: $!";
36 is($?, 0, 'writer done');