File: rm_create.t

package info (click to toggle)
libfilesys-notify-simple-perl 0.14-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 128 kB
  • sloc: perl: 191; makefile: 2
file content (39 lines) | stat: -rw-r--r-- 738 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use strict;
use Filesys::Notify::Simple;
use Test::More;
use Test::SharedFork;
use FindBin;
use File::Temp qw( tempdir );

my $dir = tempdir( DIR => "$FindBin::Bin/x" );


plan tests => 2;

my $w = Filesys::Notify::Simple->new([ "lib", "$dir" ]);

my $pid = fork;
if ($pid == 0) {
    Test::SharedFork->child;
    sleep 3;
    my $test_file = "$dir/rm_create.data";
    open my $out, ">", $test_file;
    print $out "foo" . time;
    close $out;
    sleep 3;
    unlink $test_file;
} elsif ($pid != 0) {
    Test::SharedFork->parent;
    my $event;
    for (1..2) {
        alarm 10;
        $w->wait(sub { $event = shift }); # create
        like $event->{path}, qr/rm_create\.data/;
    }

    waitpid $pid, 0;
} else {
    die $!;
}