4 use File::Temp qw(tempdir);
11 my $dir1 = tempdir('test_local_lib-XXXXX', DIR => Cwd::abs_path('t'), CLEANUP => 1);
12 $dir1 = local::lib->ensure_dir_structure_for($dir1);
14 my $dir2 = tempdir('test_local_lib-XXXXX', DIR => Cwd::abs_path('t'), CLEANUP => 1);
15 $dir2 = local::lib->ensure_dir_structure_for($dir2);
17 my $prev_active = () = local::lib->active_paths;
19 local::lib->import($dir1);
20 is +() = local::lib->active_paths, $prev_active + 1, 'one active path';
21 like $ENV{PERL_LOCAL_LIB_ROOT}, qr/\Q$dir1/, 'added one dir in root';
22 like $ENV{PERL5LIB}, qr/\Q$dir1/, 'added one dir in lib';
23 like $ENV{PERL_MM_OPT}, qr/\Q$dir1/, 'first path is installation target';
25 local::lib->import($dir1);
26 is +() = local::lib->active_paths, $prev_active + 1, 'still one active path after adding it twice';
28 local::lib->import($dir2);
29 is +() = local::lib->active_paths, $prev_active + 2, 'two active paths';
30 like $ENV{PERL_LOCAL_LIB_ROOT}, qr/\Q$dir2/, 'added another dir in root';
31 like $ENV{PERL5LIB}, qr/\Q$dir2/, 'added another dir in lib';
32 like $ENV{PERL_LOCAL_LIB_ROOT}, qr/\Q$dir1/, 'first dir is still in root';
33 like $ENV{PERL5LIB}, qr/\Q$dir1/, 'first dir is still in lib';
34 like $ENV{PERL_MM_OPT}, qr/\Q$dir2/, 'second path is installation target';
36 local::lib->import($dir1);
37 my @active = local::lib->active_paths;
38 is @active, $prev_active + 2, 'still two active dirs after re-adding first';
39 is $active[-1], $dir1, 'first dir was re-added on top';
40 like $ENV{PERL_MM_OPT}, qr/\Q$dir1/, 'first path is installation target again';
42 local::lib->import('--deactivate', $dir2);
43 unlike $ENV{PERL_LOCAL_LIB_ROOT}, qr/\Q$dir2/, 'second dir was removed from root';
44 unlike $ENV{PERL5LIB}, qr/\Q$dir2/, 'second dir was removed from lib';
45 like $ENV{PERL_LOCAL_LIB_ROOT}, qr/\Q$dir1/, q{first dir didn't go away from root};
46 like $ENV{PERL5LIB}, qr/\Q$dir1/, q{first dir didn't go away from lib};
47 like $ENV{PERL_MM_OPT}, qr/\Q$dir1/, 'first dir stays installation target';