Commit | Line | Data |
---|---|---|
e0678a30 MS |
1 | #!/usr/bin/perl -w |
2 | ||
3 | # Wherein we ensure the INST_* and INSTALL* variables are set correctly | |
4 | # according to the values of PREFIX, SITEPREFIX, INSTALLDIRS, etc... | |
5 | # | |
6 | # Essentially, this test is a Makefile.PL. | |
7 | ||
8 | BEGIN { | |
9 | if( $ENV{PERL_CORE} ) { | |
10 | chdir 't' if -d 't'; | |
11 | @INC = ('../lib', 'lib'); | |
12 | } | |
13 | else { | |
14 | unshift @INC, 't/lib'; | |
15 | } | |
16 | } | |
17 | ||
18 | use strict; | |
19 | use Test::More tests => 17; | |
20 | use MakeMaker::Test::Utils; | |
21 | use ExtUtils::MakeMaker; | |
22 | use File::Spec; | |
23 | use TieOut; | |
24 | use Config; | |
25 | ||
26 | $ENV{PERL_CORE} ? chdir '../lib/ExtUtils/t' : chdir 't'; | |
27 | ||
28 | perl_lib; | |
29 | ||
30 | $| = 1; | |
31 | ||
32 | my $Makefile = makefile_name; | |
33 | my $Curdir = File::Spec->curdir; | |
34 | my $Updir = File::Spec->updir; | |
35 | ||
36 | ok( chdir 'Big-Fat-Dummy', "chdir'd to Big-Fat-Dummy" ) || | |
37 | diag("chdir failed: $!"); | |
38 | ||
39 | my $stdout = tie *STDOUT, 'TieOut' or die; | |
40 | my $mm = WriteMakefile( | |
41 | NAME => 'Big::Fat::Dummy', | |
42 | VERSION_FROM => 'lib/Big/Fat/Dummy.pm', | |
43 | PREREQ_PM => {}, | |
44 | PERL_CORE => $ENV{PERL_CORE}, | |
45 | ); | |
46 | like( $stdout->read, qr{ | |
47 | Writing\ $Makefile\ for\ Big::Fat::Liar\n | |
48 | Big::Fat::Liar's\ vars\n | |
49 | INST_LIB\ =\ \S+\n | |
50 | INST_ARCHLIB\ =\ \S+\n | |
51 | Writing\ $Makefile\ for\ Big::Fat::Dummy\n | |
52 | }x ); | |
53 | undef $stdout; | |
54 | untie *STDOUT; | |
55 | ||
56 | isa_ok( $mm, 'ExtUtils::MakeMaker' ); | |
57 | ||
58 | is( $mm->{NAME}, 'Big::Fat::Dummy', 'NAME' ); | |
59 | is( $mm->{VERSION}, 0.01, 'VERSION' ); | |
60 | ||
61 | my $config_prefix = $^O eq 'VMS' ? VMS::Filespec::unixify($Config{prefix}) | |
62 | : $Config{prefix}; | |
63 | is( $mm->{PREFIX}, $config_prefix, 'PREFIX' ); | |
64 | ||
65 | is( !!$mm->{PERL_CORE}, !!$ENV{PERL_CORE}, 'PERL_CORE' ); | |
66 | ||
67 | my($perl_src, $mm_perl_src); | |
68 | if( $ENV{PERL_CORE} ) { | |
69 | $perl_src = File::Spec->catdir($Updir, $Updir, $Updir, $Updir); | |
70 | $perl_src = File::Spec->canonpath($perl_src); | |
71 | $mm_perl_src = File::Spec->canonpath($mm->{PERL_SRC}); | |
72 | } | |
73 | else { | |
74 | $mm_perl_src = $mm->{PERL_SRC}; | |
75 | } | |
76 | ||
77 | is( $mm_perl_src, $perl_src, 'PERL_SRC' ); | |
78 | ||
79 | ||
80 | # PERM_* | |
81 | is( $mm->{PERM_RW}, 644, 'PERM_RW' ); | |
82 | is( $mm->{PERM_RWX}, 755, 'PERM_RWX' ); | |
83 | ||
84 | ||
85 | # INST_* | |
86 | is( $mm->{INST_ARCHLIB}, | |
87 | $mm->{PERL_CORE} ? $mm->{PERL_ARCHLIB} | |
88 | : File::Spec->catdir($Curdir, 'blib', 'arch'), | |
89 | 'INST_ARCHLIB'); | |
90 | is( $mm->{INST_BIN}, File::Spec->catdir($Curdir, 'blib', 'bin'), | |
91 | 'INST_BIN' ); | |
92 | ||
93 | is( keys %{$mm->{CHILDREN}}, 1 ); | |
94 | my($child_pack) = keys %{$mm->{CHILDREN}}; | |
95 | my $c_mm = $mm->{CHILDREN}{$child_pack}; | |
96 | is( $c_mm->{INST_ARCHLIB}, | |
97 | $c_mm->{PERL_CORE} ? $c_mm->{PERL_ARCHLIB} | |
98 | : File::Spec->catdir($Updir, 'blib', 'arch'), | |
99 | 'CHILD INST_ARCHLIB'); | |
100 | is( $c_mm->{INST_BIN}, File::Spec->catdir($Updir, 'blib', 'bin'), | |
101 | 'CHILD INST_BIN' ); | |
102 | ||
103 | ||
104 | my $inst_lib = File::Spec->catdir($Curdir, 'blib', 'lib'); | |
105 | is( $mm->{INST_LIB}, | |
106 | $mm->{PERL_CORE} ? $mm->{PERL_LIB} : $inst_lib, 'INST_LIB' ); | |
107 | ||
108 | ||
109 | # INSTALL* | |
110 | is( $mm->{INSTALLDIRS}, 'site', 'INSTALLDIRS' ); |