From: Karen Etheridge Date: Thu, 12 Sep 2013 16:23:10 +0000 (-0700) Subject: move mk_temp_dir into a lib so we can reuse it X-Git-Tag: 1.008014~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=663a867559c7781df1c6810ec07aa4a3bd3c58ce;p=p5sagit%2Flocal-lib.git move mk_temp_dir into a lib so we can reuse it this hopefully resolves cpantesters issues with 1.008013 on win32: http://www.cpantesters.org/cpan/report/34414d0f-6bfd-1014-9cd9-6654736704e8 --- diff --git a/Changes b/Changes index a431116..edfdff0 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,8 @@ Revision history for local::lib + - fix new test to use alternate path representations on windows, to + handle potential space issues (regression since 1.008012) + 1.008013 2013-09-11 - fix undef value errors when not installing into a local::lib diff --git a/t/bad_variables.t b/t/bad_variables.t index 4aa0229..a7ba32b 100644 --- a/t/bad_variables.t +++ b/t/bad_variables.t @@ -5,13 +5,15 @@ use File::Temp 'tempdir'; use Config; use local::lib (); +use lib 't/lib'; use TempDir; + # remember the original value of this, in case we are already running inside a # local::lib my $orig_llr = $ENV{PERL_LOCAL_LIB_ROOT} || ''; -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); -my $dir3 = tempdir('test_local_lib-XXXXX', DIR => Cwd::abs_path('t'), CLEANUP => 1); +my $dir1 = mk_temp_dir('test_local_lib-XXXXX'); +my $dir2 = mk_temp_dir('test_local_lib-XXXXX'); +my $dir3 = mk_temp_dir('test_local_lib-XXXXX'); ok(!(grep { $dir1 eq $_ } @INC), 'new dir is not already in @INC'); ok(!(grep { $dir1 eq $_ } split /\Q$Config{path_sep}\E/, ($ENV{PERL5LIB}||'')), 'new dir is not already in PERL5LIB'); diff --git a/t/lib/TempDir.pm b/t/lib/TempDir.pm new file mode 100644 index 0000000..61a9de6 --- /dev/null +++ b/t/lib/TempDir.pm @@ -0,0 +1,27 @@ +package TempDir; +use strict; +use warnings; + +use Exporter 'import'; +our @EXPORT = qw(mk_temp_dir); + +use local::lib (); +use Cwd; +use File::Temp qw(tempdir); + +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 +} + +1; diff --git a/t/stackable.t b/t/stackable.t index 514dba0..c3b25b1 100644 --- a/t/stackable.t +++ b/t/stackable.t @@ -1,29 +1,14 @@ use strict; use warnings; use Test::More; -use File::Temp qw(tempdir); use File::Spec; -use Cwd; use Config; plan tests => 24; 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 -} +use lib 't/lib'; use TempDir; my $dir1 = mk_temp_dir('test_local_lib-XXXXX'); my $dir2 = mk_temp_dir('test_local_lib-XXXXX');