Commit | Line | Data |
3f7d1689 |
1 | use strict; |
2 | use warnings; |
3 | BEGIN { |
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 | |
16 | use Test::More; |
17 | use File::Temp; |
18 | use File::Spec; |
19 | use local::lib (); |
20 | |
21 | delete $ENV{PERL5LIB}; |
22 | delete $ENV{PERL_LOCAL_LIB_ROOT}; |
23 | delete $ENV{PERL_MM_OPT}; |
24 | delete $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 | |
30 | sub check_version { |
31 | my $module = shift; |
32 | my $version = `$^X $0 --check-version $module`; |
33 | chomp $version; |
34 | length $version ? $version : undef; |
35 | } |
36 | |
37 | my @modules = ( |
38 | [ 'ExtUtils::MakeMaker' => 6.74 ], |
39 | [ 'ExtUtils::Install' => 1.43 ], |
40 | [ 'Module::Build' => 0.36 ], |
41 | [ 'CPAN' => 1.82 ], |
42 | ); |
43 | plan tests => 1+@modules; |
44 | |
45 | for 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 ); |
53 | local::lib->import; |
54 | |
55 | system($^X, 'Makefile.PL', '--bootstrap'); |
56 | is $?, 0, 'Makefile.PL ran successfully'; |
57 | |
58 | for my $module (@modules) { |
59 | my $version = check_version($module->[0]); |
60 | cmp_ok $version, '>=', $module->[1], "bootstrap installed new enough $module->[0]"; |
61 | } |