X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=xt%2Fbootstrap.t;h=ad6f56103fcc0a9a120b51087c8c00e47ab91671;hb=aab637e3e86c213cf63c65bf4743f6f97260de45;hp=54a1e5919bcf8a09eb7e75fa886f9d588f5f1733;hpb=3f7d1689c55252ffda33bbaedc930b884060d3df;p=p5sagit%2Flocal-lib.git diff --git a/xt/bootstrap.t b/xt/bootstrap.t old mode 100755 new mode 100644 index 54a1e59..ad6f561 --- a/xt/bootstrap.t +++ b/xt/bootstrap.t @@ -13,26 +13,31 @@ BEGIN { } } +sub check_version { + my ($perl, $module) = @_; + my $version = `$perl $0 --check-version $module`; + chomp $version; + length $version ? $version : undef; +} + use Test::More; +use IPC::Open3; use File::Temp; use File::Spec; use local::lib (); -delete $ENV{PERL5LIB}; -delete $ENV{PERL_LOCAL_LIB_ROOT}; -delete $ENV{PERL_MM_OPT}; -delete $ENV{PERL_MB_OPT}; - -#my @ll_path = File::Spec->splitpath($INC{'local/lib.pm'}); -#my @ll_dir = File::Spec->splitdir($ll_path[1]); -#my $ll_dir = File::Spec->catpath($ll_path[0], File::Spec->catdir(@ll_dir[0 .. $#_-1]), ''); - -sub check_version { - my $module = shift; - my $version = `$^X $0 --check-version $module`; - chomp $version; - length $version ? $version : undef; +my @perl; +while (@ARGV) { + my $arg = shift @ARGV; + if ($arg =~ /^--perl(?:=(.*))$/) { + push @perl, ($1 || shift @ARGV); + } + else { + warn "unrecognized option: $arg\n"; + } } +@perl = $^X + unless @perl; my @modules = ( [ 'ExtUtils::MakeMaker' => 6.74 ], @@ -40,22 +45,47 @@ my @modules = ( [ 'Module::Build' => 0.36 ], [ 'CPAN' => 1.82 ], ); -plan tests => 1+@modules; -for my $module (@modules) { - my $version = check_version($module->[0]); - if ($version && $version >= $module->[1]) { - warn "Can't test bootstrap of $module->[0], version $version already meets requirement of $module->[1]\n"; +plan tests => @perl * (1+@modules); + +for my $perl (@perl) { + local @INC = @INC; + local $ENV{PERL5LIB}; + local $ENV{PERL_LOCAL_LIB_ROOT}; + local $ENV{PERL_MM_OPT}; + local $ENV{PERL_MB_OPT}; + delete $ENV{PERL5LIB}; + delete $ENV{PERL_LOCAL_LIB_ROOT}; + delete $ENV{PERL_MM_OPT}; + delete $ENV{PERL_MB_OPT}; + my $home = File::Temp->newdir; + local $ENV{HOME} = $home->dirname; + + diag "testing bootstrap with $perl"; + for my $module (@modules) { + my $version = check_version($perl, $module->[0]); + if ($version && $version >= $module->[1]) { + diag "Can't test bootstrap of $module->[0], version $version already meets requirement of $module->[1]"; + } } -} -$ENV{HOME} = my $home = File::Temp::tempdir( CLEANUP => 1 ); -local::lib->import; + my $ll = File::Spec->catdir($home, 'local-lib'); -system($^X, 'Makefile.PL', '--bootstrap'); -is $?, 0, 'Makefile.PL ran successfully'; + open my $null_in, '<', File::Spec->devnull; + my $pid = open3 $null_in, my $out, undef, $perl, 'Makefile.PL', '--bootstrap='.$ll; + while (my $line = <$out>) { + note $line; + } + waitpid $pid, 0; + + is $?, 0, 'Makefile.PL ran successfully' + or diag $out; -for my $module (@modules) { - my $version = check_version($module->[0]); - cmp_ok $version, '>=', $module->[1], "bootstrap installed new enough $module->[0]"; + local::lib->setup_env_hash_for($ll); + + for my $module (@modules) { + my $version = check_version($perl, $module->[0]); + cmp_ok $version, '>=', $module->[1], "bootstrap installed new enough $module->[0]" + or diag "PERL5LIB: $ENV{PERL5LIB}"; + } }