oops, some of these variables aren't always initialized
[p5sagit/local-lib.git] / t / bad_variables.t
CommitLineData
1b0fe50a 1use strict;
2use warnings;
3use Test::More tests => 5;
4use File::Temp 'tempdir';
5use local::lib ();
6
7# remember the original value of this, in case we are already running inside a
8# local::lib
0d174bf6 9my $orig_llr = $ENV{PERL_LOCAL_LIB_ROOT} || '';
1b0fe50a 10
11my $dir1 = tempdir('test_local_lib-XXXXX', DIR => Cwd::abs_path('t'), CLEANUP => 1);
12my $dir2 = tempdir('test_local_lib-XXXXX', DIR => Cwd::abs_path('t'), CLEANUP => 1);
13my $dir3 = tempdir('test_local_lib-XXXXX', DIR => Cwd::abs_path('t'), CLEANUP => 1);
14
15ok(!(grep { $dir1 eq $_ } @INC), 'new dir is not already in @INC');
0d174bf6 16ok(!(grep { $dir1 eq $_ } split /:/, ($ENV{PERL5LIB}||'')), 'new dir is not already in PERL5LIB');
1b0fe50a 17
18local::lib->import($dir1);
19local::lib->import($dir2);
20
21# we have junk in here now
22$ENV{PERL_LOCAL_LIB_ROOT} .= ':' . $dir3;
23
24local::lib->import($dir1);
25
26is(
27 $ENV{PERL_LOCAL_LIB_ROOT},
0d174bf6 28 join(':', (grep { $_ } $orig_llr, $dir2, $dir1)),
1b0fe50a 29 'dir1 should have been removed and added back in at the top',
30);
31
32ok((grep { /\Q$dir1\E/ } @INC), 'new dir has been added to @INC');
33ok((grep { /\Q$dir1\E/ } split /:/, $ENV{PERL5LIB}), 'new dir has been added to PERL5LIB');
34