File: stackable.t

package info (click to toggle)
liblocal-lib-perl 2.000014-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 308 kB
  • ctags: 72
  • sloc: perl: 727; makefile: 22
file content (57 lines) | stat: -rw-r--r-- 2,478 bytes parent folder | download | duplicates (2)
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
55
56
57
use strict;
use warnings;
use Test::More;
use File::Spec;
use Config;

plan tests => 24;

use local::lib ();

use lib 't/lib'; use TempDir;

delete $ENV{PERL_LOCAL_LIB_ROOT};

my $dir1 = mk_temp_dir('test_local_lib-XXXXX');
my $dir2 = mk_temp_dir('test_local_lib-XXXXX');

my ($dir1_arch, $dir2_arch) = map { File::Spec->catfile($_, qw'lib perl5', $Config{archname}) } $dir1, $dir2;

my $prev_active = () = local::lib->active_paths;

local::lib->import($dir1);
is +() = local::lib->active_paths, $prev_active + 1, 'one active path';
like $ENV{PERL_LOCAL_LIB_ROOT}, qr/\Q$dir1/, 'added one dir in root';
like $ENV{PERL5LIB}, qr/\Q$dir1/, 'added one dir in lib';
unlike $ENV{PERL5LIB}, qr/\Q$dir1_arch/, 'no arch in PERL5LIB';
my $dir1_escape = local::lib::_mm_escape_path($dir1);
like $ENV{PERL_MM_OPT}, qr/\Q$dir1_escape/, 'first path is installation target';

local::lib->import($dir1);
is +() = local::lib->active_paths, $prev_active + 1, 'still one active path after adding it twice';

local::lib->import($dir2);
is +() = local::lib->active_paths, $prev_active + 2, 'two active paths';
like $ENV{PERL_LOCAL_LIB_ROOT}, qr/\Q$dir2/, 'added another dir in root';
like $ENV{PERL5LIB}, qr/\Q$dir2/, 'added another dir in lib';
unlike $ENV{PERL5LIB}, qr/\Q$dir2_arch/, 'no arch in PERL5LIB';
like $ENV{PERL_LOCAL_LIB_ROOT}, qr/\Q$dir1/, 'first dir is still in root';
like $ENV{PERL5LIB}, qr/\Q$dir1/, 'first dir is still in lib';
unlike $ENV{PERL5LIB}, qr/\Q$dir1_arch/, 'no arch in PERL5LIB';
my $dir2_escape = local::lib::_mm_escape_path($dir2);
like $ENV{PERL_MM_OPT}, qr/\Q$dir2_escape/, 'second path is installation target';

local::lib->import($dir1);
my @active = local::lib->active_paths;
is @active, $prev_active + 2, 'still two active dirs after re-adding first';
is $active[0], $dir1, 'first dir was re-added on top';
like $ENV{PERL_MM_OPT}, qr/\Q$dir1_escape/, 'first path is installation target again';

local::lib->import('--deactivate', $dir2);
unlike $ENV{PERL_LOCAL_LIB_ROOT}, qr/\Q$dir2/, 'second dir was removed from root';
unlike $ENV{PERL5LIB}, qr/\Q$dir2/, 'second dir was removed from lib';
unlike $ENV{PERL5LIB}, qr/\Q$dir2_arch/, 'no arch in PERL5LIB';
like $ENV{PERL_LOCAL_LIB_ROOT}, qr/\Q$dir1/, q{first dir didn't go away from root};
like $ENV{PERL5LIB}, qr/\Q$dir1/, q{first dir didn't go away from lib};
unlike $ENV{PERL5LIB}, qr/\Q$dir1_arch/, 'no arch in PERL5LIB';
like $ENV{PERL_MM_OPT}, qr/\Q$dir1_escape/, 'first dir stays installation target';