bootstrapping test
[p5sagit/local-lib.git] / xt / bootstrap.t
CommitLineData
3f7d1689 1use strict;
2use warnings;
3BEGIN {
4 if (@ARGV && $ARGV[0] eq '--check-version') {
5 my $module = $ARGV[1];
6 (my $file = "$module.pm") =~ s{::}{/}g;
7 eval {
8 require $file;
9 my $version = do { no strict; ${"${module}::VERSION"} };
10 print eval $version;
11 };
12 exit;
13 }
14}
15
16use Test::More;
17use File::Temp;
18use File::Spec;
19use local::lib ();
20
21delete $ENV{PERL5LIB};
22delete $ENV{PERL_LOCAL_LIB_ROOT};
23delete $ENV{PERL_MM_OPT};
24delete $ENV{PERL_MB_OPT};
25
26#my @ll_path = File::Spec->splitpath($INC{'local/lib.pm'});
27#my @ll_dir = File::Spec->splitdir($ll_path[1]);
28#my $ll_dir = File::Spec->catpath($ll_path[0], File::Spec->catdir(@ll_dir[0 .. $#_-1]), '');
29
30sub check_version {
31 my $module = shift;
32 my $version = `$^X $0 --check-version $module`;
33 chomp $version;
34 length $version ? $version : undef;
35}
36
37my @modules = (
38 [ 'ExtUtils::MakeMaker' => 6.74 ],
39 [ 'ExtUtils::Install' => 1.43 ],
40 [ 'Module::Build' => 0.36 ],
41 [ 'CPAN' => 1.82 ],
42);
43plan tests => 1+@modules;
44
45for my $module (@modules) {
46 my $version = check_version($module->[0]);
47 if ($version && $version >= $module->[1]) {
48 warn "Can't test bootstrap of $module->[0], version $version already meets requirement of $module->[1]\n";
49 }
50}
51
52$ENV{HOME} = my $home = File::Temp::tempdir( CLEANUP => 1 );
53local::lib->import;
54
55system($^X, 'Makefile.PL', '--bootstrap');
56is $?, 0, 'Makefile.PL ran successfully';
57
58for my $module (@modules) {
59 my $version = check_version($module->[0]);
60 cmp_ok $version, '>=', $module->[1], "bootstrap installed new enough $module->[0]";
61}