X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fstackable.t;h=6029a3a27297a681a0cfb02a8d766bb8cb489f24;hb=c1ed5f4bf162501712d308bde66c8cb1d162ddc2;hp=0c639983760eba12002fd7d7793b2bb289909ef7;hpb=6369ed6d3bce0305b6497564c2bd42c82c900e99;p=p5sagit%2Flocal-lib.git diff --git a/t/stackable.t b/t/stackable.t index 0c63998..6029a3a 100644 --- a/t/stackable.t +++ b/t/stackable.t @@ -6,22 +6,39 @@ use Cwd; plan tests => 19; -my $dir1 = tempdir('test_local_lib-XXXXX', DIR => Cwd::abs_path('t'), CLEANUP => 1); -my $dir2 = tempdir('test_local_lib-XXXXX', DIR => Cwd::abs_path('t'), CLEANUP => 1); - use local::lib (); +sub mk_temp_dir +{ + my $name_template = shift; + + my $path = tempdir($name_template, DIR => Cwd::abs_path('t'), CLEANUP => 1); + local::lib->ensure_dir_structure_for($path); + # On Win32 the path where the distribution is built usually contains + # spaces. This is a problem for some parts of the CPAN toolchain, so + # local::lib uses the GetShortPathName trick do get an alternate + # representation of the path that doesn't constain spaces. + return ($^O eq 'MSWin32') + ? Win32::GetShortPathName($path) + : $path +} + +my $dir1 = mk_temp_dir('test_local_lib-XXXXX'); +my $dir2 = mk_temp_dir('test_local_lib-XXXXX'); + +my $prev_active = () = local::lib->active_paths; + local::lib->import($dir1); -is +() = local::lib->active_paths, 1, 'one active path'; +is +() = local::lib->active_paths, $prev_active + 1, 'one active path'; like $ENV{PERL_LOCAL_LIB_ROOT}, qr/\Q$dir1/, 'added one dir in root'; like $ENV{PERL5LIB}, qr/\Q$dir1/, 'added one dir in lib'; like $ENV{PERL_MM_OPT}, qr/\Q$dir1/, 'first path is installation target'; local::lib->import($dir1); -is +() = local::lib->active_paths, 1, 'still one active path after adding it twice'; +is +() = local::lib->active_paths, $prev_active + 1, 'still one active path after adding it twice'; local::lib->import($dir2); -is +() = local::lib->active_paths, 2, 'two active paths'; +is +() = local::lib->active_paths, $prev_active + 2, 'two active paths'; like $ENV{PERL_LOCAL_LIB_ROOT}, qr/\Q$dir2/, 'added another dir in root'; like $ENV{PERL5LIB}, qr/\Q$dir2/, 'added another dir in lib'; like $ENV{PERL_LOCAL_LIB_ROOT}, qr/\Q$dir1/, 'first dir is still in root'; @@ -30,7 +47,7 @@ like $ENV{PERL_MM_OPT}, qr/\Q$dir2/, 'second path is installation target'; local::lib->import($dir1); my @active = local::lib->active_paths; -is @active, 2, 'still two active dirs after re-adding first'; +is @active, $prev_active + 2, 'still two active dirs after re-adding first'; is $active[-1], $dir1, 'first dir was re-added on top'; like $ENV{PERL_MM_OPT}, qr/\Q$dir1/, 'first path is installation target again';