Skip to content

Commit

Permalink
To make testing easier we add ExtUtils::MakeMaker::Config, a thin wra…
Browse files Browse the repository at this point in the history
…pper

around Config which makes it writable and in a centralized location.  This
allows tests to override %Config.

Also add the new MM_* files to the MANIFEST

git-svn-id: http://svn.schwern.org/repos/CPAN/ExtUtils-MakeMaker/trunk@2212 8151f2b9-fde8-0310-94fd-f048d12aab9e
  • Loading branch information
schwern committed Dec 20, 2004
1 parent 669a045 commit 85e8d43
Show file tree
Hide file tree
Showing 15 changed files with 82 additions and 38 deletions.
5 changes: 5 additions & 0 deletions MANIFEST
Expand Up @@ -8,6 +8,7 @@ lib/ExtUtils/Liblist.pm
lib/ExtUtils/Liblist/Kid.pm
lib/ExtUtils/MakeMaker.pm
lib/ExtUtils/MakeMaker/bytes.pm
lib/ExtUtils/MakeMaker/Config.pm
lib/ExtUtils/MakeMaker/FAQ.pod
lib/ExtUtils/MakeMaker/Tutorial.pod
lib/ExtUtils/MakeMaker/vmsish.pm
Expand All @@ -16,16 +17,19 @@ lib/ExtUtils/MANIFEST.SKIP
lib/ExtUtils/Mkbootstrap.pm
lib/ExtUtils/Mksymlists.pm
lib/ExtUtils/MM.pm
lib/ExtUtils/MM_AIX.pm
lib/ExtUtils/MM_Any.pm
lib/ExtUtils/MM_BeOS.pm
lib/ExtUtils/MM_Cygwin.pm
lib/ExtUtils/MM_DOS.pm
lib/ExtUtils/MM_MacOS.pm
lib/ExtUtils/MM_NW5.pm
lib/ExtUtils/MM_OS2.pm
lib/ExtUtils/MM_QNX.pm
lib/ExtUtils/MM_Unix.pm
lib/ExtUtils/MM_UWIN.pm
lib/ExtUtils/MM_VMS.pm
lib/ExtUtils/MM_VOS.pm
lib/ExtUtils/MM_Win32.pm
lib/ExtUtils/MM_Win95.pm
lib/ExtUtils/MY.pm
Expand All @@ -42,6 +46,7 @@ t/backwards.t
t/basic.t
t/bytes.t
t/Command.t
t/config.t
t/dir_target.t
t/hints.t
t/INST.t
Expand Down
2 changes: 1 addition & 1 deletion lib/ExtUtils/MM.pm
@@ -1,7 +1,7 @@
package ExtUtils::MM;

use strict;
use Config;
use ExtUtils::MakeMaker::Config;
use vars qw(@ISA $VERSION);
$VERSION = '0.04_02';

Expand Down
2 changes: 1 addition & 1 deletion lib/ExtUtils/MM_Any.pm
Expand Up @@ -8,7 +8,7 @@ $VERSION = '0.10_02';
# We need $Verbose
use ExtUtils::MakeMaker qw($Verbose);

use Config;
use ExtUtils::MakeMaker::Config;
use File::Spec;


Expand Down
2 changes: 1 addition & 1 deletion lib/ExtUtils/MM_BeOS.pm
Expand Up @@ -18,7 +18,7 @@ the semantics.
=cut

use Config;
use ExtUtils::MakeMaker::Config;
use File::Spec;
require ExtUtils::MM_Any;
require ExtUtils::MM_Unix;
Expand Down
2 changes: 1 addition & 1 deletion lib/ExtUtils/MM_Cygwin.pm
Expand Up @@ -3,7 +3,7 @@ package ExtUtils::MM_Cygwin;
use strict;
use vars qw($VERSION @ISA);

use Config;
use ExtUtils::MakeMaker::Config;
use File::Spec;

require ExtUtils::MM_Any;
Expand Down
2 changes: 1 addition & 1 deletion lib/ExtUtils/MM_NW5.pm
Expand Up @@ -19,7 +19,7 @@ the semantics.
=cut

use strict;
use Config;
use ExtUtils::MakeMaker::Config;
use File::Basename;

use vars qw(@ISA $VERSION);
Expand Down
2 changes: 1 addition & 1 deletion lib/ExtUtils/MM_Unix.pm
Expand Up @@ -6,7 +6,7 @@ use strict;

use Exporter ();
use Carp;
use Config qw(%Config);
use ExtUtils::MakeMaker::Config qw(%Config);
use File::Basename qw(basename dirname);
use DirHandle;

Expand Down
2 changes: 1 addition & 1 deletion lib/ExtUtils/MM_VMS.pm
Expand Up @@ -7,7 +7,7 @@ package ExtUtils::MM_VMS;

use strict;

use Config;
use ExtUtils::MakeMaker::Config;
require Exporter;

BEGIN {
Expand Down
2 changes: 1 addition & 1 deletion lib/ExtUtils/MM_Win32.pm
Expand Up @@ -19,7 +19,7 @@ the semantics.
=cut

use Config;
use ExtUtils::MakeMaker::Config;
use File::Basename;
use File::Spec;
use ExtUtils::MakeMaker qw( neatvalue );
Expand Down
2 changes: 1 addition & 1 deletion lib/ExtUtils/MM_Win95.pm
Expand Up @@ -6,7 +6,7 @@ $VERSION = '0.03_01';
require ExtUtils::MM_Win32;
@ISA = qw(ExtUtils::MM_Win32);

use Config;
use ExtUtils::MakeMaker::Config;
my $DMAKE = $Config{'make'} =~ /^dmake/i;
my $NMAKE = $Config{'make'} =~ /^nmake/i;

Expand Down
2 changes: 1 addition & 1 deletion lib/ExtUtils/MakeMaker.pm
Expand Up @@ -6,7 +6,7 @@ $VERSION = '6.25_02';
($Revision) = q$Revision: 1.147 $ =~ /Revision:\s+(\S+)/;

require Exporter;
use Config;
use ExtUtils::MakeMaker::Config;
use Carp ();
use File::Path;

Expand Down
39 changes: 39 additions & 0 deletions lib/ExtUtils/MakeMaker/Config.pm
@@ -0,0 +1,39 @@
package ExtUtils::MakeMaker::Config;

$VERSION = '0.01_02';

use strict;
use Config ();

# Give us an overridable config.
use vars qw(%Config);
%Config = %Config::Config;

sub import {
my $caller = caller;

no strict 'refs';
*{$caller.'::Config'} = \%Config;
}

1;


=head1 NAME
ExtUtils::MakeMaker::Config - Wrapper around Config.pm
=head1 SYNOPSIS
use ExtUtils::MakeMaker::Config;
print $Config{installbin}; # or whatever
=head1 DESCRIPTION
B<FOR INTERNAL USE ONLY>
A very thin wrapper around Config.pm so MakeMaker is easier to test.
=cut
28 changes: 3 additions & 25 deletions t/INST_PREFIX.t
Expand Up @@ -22,7 +22,7 @@ use MakeMaker::Test::Setup::BFD;
use ExtUtils::MakeMaker;
use File::Spec;
use TieOut;
use Config;
use ExtUtils::MakeMaker::Config;

my $Is_VMS = $^O eq 'VMS';

Expand Down Expand Up @@ -149,11 +149,6 @@ while( my($type, $vars) = each %Install_Vars) {
# Check that when installman*dir isn't set in Config no man pages
# are generated.
{
undef *ExtUtils::MM_Unix::Config;
undef *ExtUtils::MM_Unix::Config_Override;
%ExtUtils::MM_Unix::Config = %Config;
*ExtUtils::MM_VMS::Config = \%ExtUtils::MM_Unix::Config;

_set_config(installman1dir => '');
_set_config(installman3dir => '');

Expand All @@ -175,13 +170,6 @@ while( my($type, $vars) = each %Install_Vars) {
# Check that when installvendorman*dir is set in Config it is honored
# [rt.cpan.org 2949]
{
undef *ExtUtils::MM_Unix::Config;
undef *ExtUtils::MM_Unix::Config_Override;
undef *ExtUtils::MM_VMS::Config;

%ExtUtils::MM_Unix::Config = %Config;
*ExtUtils::MM_VMS::Config = \%ExtUtils::MM_Unix::Config;

_set_config(installvendorman1dir => File::Spec->catdir('foo','bar') );
_set_config(installvendorman3dir => '' );
_set_config(usevendorprefix => 1 );
Expand All @@ -208,11 +196,6 @@ while( my($type, $vars) = each %Install_Vars) {
# Check that when installsiteman*dir isn't set in Config it falls back
# to installman*dir
{
undef *ExtUtils::MM_Unix::Config;
undef *ExtUtils::MM_Unix::Config_Override;
%ExtUtils::MM_Unix::Config = %Config;
*ExtUtils::MM_VMS::Config = \%ExtUtils::MM_Unix::Config;

_set_config(installman1dir => File::Spec->catdir('foo', 'bar') );
_set_config(installman3dir => File::Spec->catdir('foo', 'baz') );
_set_config(installsiteman1dir => '' );
Expand Down Expand Up @@ -246,11 +229,6 @@ while( my($type, $vars) = each %Install_Vars) {
# Check that when usevendoprefix and installvendorman*dir aren't set in
# Config it leaves them unset.
{
undef *ExtUtils::MM_Unix::Config;
undef *ExtUtils::MM_Unix::Config_Override;
%ExtUtils::MM_Unix::Config = %Config;
*ExtUtils::MM_VMS::Config = \%ExtUtils::MM_Unix::Config;

_set_config(installman1dir => File::Spec->catdir('foo', 'bar') );
_set_config(installman3dir => File::Spec->catdir('foo', 'baz') );
_set_config(installsiteman1dir => '' );
Expand Down Expand Up @@ -283,10 +261,10 @@ while( my($type, $vars) = each %Install_Vars) {
sub _set_config {
my($k,$v) = @_;
(my $k_no_install = $k) =~ s/^install//i;
$ExtUtils::MM_Unix::Config{$k} = $v;
$Config{$k} = $v;

# Because VMS's config has traditionally been underpopulated, it will
# fall back to the install-less versions in desperation.
$ExtUtils::MM_Unix::Config{$k_no_install} = $v if $Is_VMS;
$Config{$k_no_install} = $v if $Is_VMS;
return;
}
23 changes: 23 additions & 0 deletions t/config.t
@@ -0,0 +1,23 @@
#!/usr/bin/perl -w

BEGIN {
if( $ENV{PERL_CORE} ) {
chdir 't';
@INC = ('../lib', 'lib/');
}
else {
unshift @INC, 't/lib/';
}
}

use Test::More tests => 3;
use Config ();

BEGIN { use_ok 'ExtUtils::MakeMaker::Config'; }

is $Config{path_sep}, $Config::Config{path_sep};

eval {
$Config{wibble} = 42;
};
is $Config{wibble}, 42;
5 changes: 2 additions & 3 deletions t/prefixify.t
Expand Up @@ -19,7 +19,7 @@ if( $^O eq 'VMS' ) {
else {
plan tests => 3;
}
use Config;
use ExtUtils::MakeMaker::Config;
use File::Spec;
use ExtUtils::MM;

Expand All @@ -41,8 +41,7 @@ is( $mm->{INSTALLBIN}, File::Spec->catdir('something', $default),
SKIP: {
skip "Test for DOSish prefixification", 1 unless $Is_Dosish;

undef *ExtUtils::MM_Unix::Config;
$ExtUtils::MM_Unix::Config{wibble} = 'C:\opt\perl\wibble';
$Config{wibble} = 'C:\opt\perl\wibble';
$mm->prefixify('wibble', 'C:\opt\perl', 'C:\yarrow');

is( $mm->{WIBBLE}, 'C:\yarrow\wibble', 'prefixify Win32 paths' );
Expand Down

0 comments on commit 85e8d43

Please sign in to comment.