File: excluded-dirs.t

package info (click to toggle)
libfile-changenotify-perl 0.16-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 196 kB
  • ctags: 59
  • sloc: perl: 967; makefile: 2
file content (43 lines) | stat: -rw-r--r-- 996 bytes parent folder | download | duplicates (3)
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
40
41
42
43
use strict;
use warnings;

use FindBin;
use File::ChangeNotify::Watcher;
use File::Spec;

use Test::More;

my $root = File::Spec->catfile( $FindBin::Bin, '..' );
sub f { File::Spec->catfile( $root, @_ ) }

my $watcher = File::ChangeNotify::Watcher->new(
    directories => f(),
    exclude     => [
        f('foo'),
        f('bar'),
        f( 'excluded', 'dir' ),
        qr{(?:\\|/)r[^\\/]+$},
        qr{(?:\\|/)\.[^\\/]*$},
    ]
);

ok( !$watcher->_path_is_excluded( f('quux') ), 'included dir' );
ok( $watcher->_path_is_excluded( f('foo') ),   'excluded dir' );
ok(
    !$watcher->_path_is_excluded( f( 'foo', 'bar' ) ),
    'subdirs not excluded with string exclusion'
);
ok(
    $watcher->_path_is_excluded( f( 'left', 'right' ) ),
    'excluded by regex'
);
ok(
    $watcher->_path_is_excluded( f('.hidden') ),
    'excluding hidden dirs with regex'
);
ok(
    !$watcher->_path_is_excluded( f( '.hidden', 'file' ) ),
    'hidden dir regex does not exclude subdirs'
);

done_testing();