File: 07_is_in_dir.t

package info (click to toggle)
libtest-checkmanifest-perl 1.43-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 236 kB
  • sloc: perl: 773; makefile: 2
file content (48 lines) | stat: -rw-r--r-- 1,159 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
44
45
46
47
48
#!/usr/bin/env perl

use strict;
use warnings;

use File::Basename;
use File::Spec;
use Test::More;
use Test::CheckManifest;

use Cwd;

my $sub = Test::CheckManifest->can('_is_in_dir');
ok $sub;

my $dir   = Cwd::realpath( dirname __FILE__ );
$dir      =~ s{.t\z}{};
my $t_dir = File::Spec->catdir( $dir, 't' );
my $abs_t_file = File::Spec->rel2abs( __FILE__ );

my @tests = (
    [ '/t/test.txt', '/t', 1 ],
    [ '/t/sub/test.txt', '/t', 1 ],
    [ '/t/test.txt', '/t2', undef ],
    [ '', '/t2', undef ],
    [ '/t/test.txt', '', undef ],
    [ undef, '', undef ],
    [ undef, '/t', undef ],
    [ undef, undef, undef ],
    [ '/t/test.txt', undef, undef ],
    [ '', undef, undef ],
    [ '/t/sub/', '/t', 1 ],
    [ '/t/sub/test', '/t/sub/', 1 ],
    [ '/t/test', '/t/sub/', undef ],
    [ __FILE__, dirname( __FILE__ ), 1 ],
    [ $abs_t_file, $t_dir, 1 ],
);

for my $test ( @tests ) {
    my ($file, $excludes, $expected) = @{$test};
    my $result = $sub->( $file, [$excludes] );

    is $result, $expected, sprintf "%s -> %s",
        ( defined $file ? $file : '<undef>' ),
        ( defined $excludes ? $excludes : '<undef>' );
}

done_testing();