X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=xt%2Fbootstrap.t;h=3df6e7edc5977b6f2c0f9bf931985b640ce11096;hb=65d67789387eed86a17ca399ae07e6bf098881a7;hp=54a1e5919bcf8a09eb7e75fa886f9d588f5f1733;hpb=3f7d1689c55252ffda33bbaedc930b884060d3df;p=p5sagit%2Flocal-lib.git diff --git a/xt/bootstrap.t b/xt/bootstrap.t index 54a1e59..3df6e7e 100755 --- 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}; + + 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; + $ENV{HOME} = my $home = File::Temp::tempdir( CLEANUP => 1 ); + 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; + + local::lib->setup_env_hash_for($ll); -for my $module (@modules) { - my $version = check_version($module->[0]); - cmp_ok $version, '>=', $module->[1], "bootstrap installed new enough $module->[0]"; + 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}"; + + } }