File: 08_util_withmodule.t

package info (click to toggle)
libtest-file-sharedir-perl 1.001002-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 496 kB
  • ctags: 58
  • sloc: perl: 603; makefile: 2
file content (54 lines) | stat: -rw-r--r-- 1,035 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
49
50
51
52
53
54

use strict;
use warnings;

use Test::More 0.96;
use Test::Fatal;
use FindBin;

use Test::File::ShareDir qw(with_module_dir);
use lib "$FindBin::Bin/08_files/lib";
use Example;
use File::ShareDir qw( module_dir module_file );

with_module_dir(
  { Example => 't/08_files/share' } => sub {
    is(
      exception {
        note module_dir('Example');
      },
      undef,
      'module_dir doesn\'t bail as it finds the dir'
    );

    is(
      exception {
        note module_file( 'Example', 'afile' );
      },
      undef,
      'module_file doesn\'t bail as it finds the file'
    );
  },
);

isnt(
  exception {
    note module_dir('Example');
  },
  undef,
  'dist_dir bails after clear'
);

# Note: This code warns, its a bug in File::ShareDir
# dist_file( 'x', 'y' )
#  -> _dist_dir_new('x') -> Returns undef
#  -> File::Spec->catfile( undef, 'afile' )  # warns about undef in subroutine entry.
isnt(
  exception {
    note module_file( 'Example', 'afile' );
  },
  undef,
  'dist_file bails after clear'
);

done_testing;