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