From: Graham Knop Date: Tue, 5 Nov 2013 21:53:32 +0000 (-0500) Subject: bootstrapping test X-Git-Tag: v2.000_000~61 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3f7d1689c55252ffda33bbaedc930b884060d3df;p=p5sagit%2Flocal-lib.git bootstrapping test --- diff --git a/xt/bootstrap.t b/xt/bootstrap.t new file mode 100755 index 0000000..54a1e59 --- /dev/null +++ b/xt/bootstrap.t @@ -0,0 +1,61 @@ +use strict; +use warnings; +BEGIN { + if (@ARGV && $ARGV[0] eq '--check-version') { + my $module = $ARGV[1]; + (my $file = "$module.pm") =~ s{::}{/}g; + eval { + require $file; + my $version = do { no strict; ${"${module}::VERSION"} }; + print eval $version; + }; + exit; + } +} + +use Test::More; +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 @modules = ( + [ 'ExtUtils::MakeMaker' => 6.74 ], + [ 'ExtUtils::Install' => 1.43 ], + [ '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"; + } +} + +$ENV{HOME} = my $home = File::Temp::tempdir( CLEANUP => 1 ); +local::lib->import; + +system($^X, 'Makefile.PL', '--bootstrap'); +is $?, 0, 'Makefile.PL ran successfully'; + +for my $module (@modules) { + my $version = check_version($module->[0]); + cmp_ok $version, '>=', $module->[1], "bootstrap installed new enough $module->[0]"; +}