Commit | Line | Data |
b0e4e8db |
1 | use strict; |
2 | use warnings; |
3 | use Test::More; |
4 | use File::Temp qw(tempdir); |
5 | use Cwd; |
6 | |
7 | plan tests => 11; |
8 | |
9 | my $dir1 = tempdir('test_local_lib-XXXXX', DIR => Cwd::abs_path('t'), CLEANUP => 1); |
10 | my $dir2 = tempdir('test_local_lib-XXXXX', DIR => Cwd::abs_path('t'), CLEANUP => 1); |
11 | |
12 | use local::lib (); |
13 | |
14 | local::lib->import($dir1); |
15 | like $ENV{PERL_LOCAL_LIB_ROOT}, qr/\Q$dir1/, 'added one dir in root'; |
16 | like $ENV{PERL5LIB}, qr/\Q$dir1/, 'added one dir in lib'; |
17 | |
18 | local::lib->import($dir2); |
19 | like $ENV{PERL_LOCAL_LIB_ROOT}, qr/\Q$dir2/, 'added another dir in root'; |
20 | like $ENV{PERL5LIB}, qr/\Q$dir2/, 'added another dir in lib'; |
21 | like $ENV{PERL_LOCAL_LIB_ROOT}, qr/\Q$dir1/, 'first dir is still in root'; |
22 | like $ENV{PERL5LIB}, qr/\Q$dir1/, 'first dir is still in lib'; |
23 | |
24 | local::lib->import('--deactivate', $dir1); |
25 | unlike $ENV{PERL_LOCAL_LIB_ROOT}, qr/\Q$dir1/, 'first dir was removed from root'; |
26 | unlike $ENV{PERL5LIB}, qr/\Q$dir1/, 'first dir was removed from lib'; |
27 | like $ENV{PERL_LOCAL_LIB_ROOT}, qr/\Q$dir2/, q{second dir didn't go away from root}; |
28 | like $ENV{PERL5LIB}, qr/\Q$dir2/, q{second dir didn't go away from lib}; |
29 | like $ENV{PERL_MM_OPT}, qr/\Q$dir2/, q{second dir stays installation target}; |