3 use Test::More tests => 5;
4 use File::Temp 'tempdir';
8 use lib 't/lib'; use TempDir;
10 # remember the original value of this, in case we are already running inside a
12 my $orig_llr = $ENV{PERL_LOCAL_LIB_ROOT} || '';
13 $orig_llr = '' if $orig_llr eq $Config{path_sep};
15 my $dir1 = mk_temp_dir('test_local_lib-XXXXX');
16 my $dir2 = mk_temp_dir('test_local_lib-XXXXX');
17 my $dir3 = mk_temp_dir('test_local_lib-XXXXX');
19 ok(!(grep { $dir1 eq $_ } @INC), 'new dir is not already in @INC');
20 ok(!(grep { $dir1 eq $_ } split /\Q$Config{path_sep}\E/, ($ENV{PERL5LIB}||'')), 'new dir is not already in PERL5LIB');
22 local::lib->import($dir1);
23 local::lib->import($dir2);
25 # we have junk in here now
26 $ENV{PERL_LOCAL_LIB_ROOT} .= $Config{path_sep} . $dir3;
28 local::lib->import($dir1);
31 $ENV{PERL_LOCAL_LIB_ROOT},
32 join($Config{path_sep}, (grep { defined $_ and $_ ne '' } $orig_llr, $dir2, $dir1)),
33 'dir1 should have been removed and added back in at the top (PERL_LOCAL_LIB_ROOT was ' . $orig_llr . ')',
36 ok((grep { /\Q$dir1\E/ } @INC), 'new dir has been added to @INC');
37 ok((grep { /\Q$dir1\E/ } split /\Q$Config{path_sep}\E/, $ENV{PERL5LIB}), 'new dir has been added to PERL5LIB');