Update of /cvsroot/module-build/Module-Build/lib/Module/Build
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20639/lib/Module/Build
Modified Files:
Base.pm
Log Message:
Added support for environment variable, 'MODULEBUILDRC', which can be used to specify the full path to an option file to use instead of the default location of ~/.modulebuildrc. A special undocumented setting of 'NONE' tells Module::Build not to load any user settings, so tests can be run without tainting from user options.
The primary motivation for this feature is to make it easy to construct tests without needing to pass in an option to disable reading the rcfile for every Module::Build object created.
Index: Base.pm
===================================================================
RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build/Base.pm,v
retrieving revision 1.501
retrieving revision 1.502
diff -u -d -r1.501 -r1.502
--- Base.pm 20 Oct 2005 09:26:42 -0000 1.501
+++ Base.pm 20 Oct 2005 16:45:19 -0000 1.502
@@ -1537,11 +1537,24 @@
sub read_modulebuildrc {
my( $self, $action ) = @_;
- my $home = $self->_home_dir;
- return () unless defined $home;
+ return () unless $self->use_rcfile;
- my $modulebuildrc = File::Spec->catfile( $home, '.modulebuildrc' );
- return () unless -e $modulebuildrc;
+ my $modulebuildrc;
+ if ( exists($ENV{MODULEBUILDRC}) && $ENV{MODULEBUILDRC} eq 'NONE' ) {
+ return ();
+ } elsif ( exists($ENV{MODULEBUILDRC}) && -e $ENV{MODULEBUILDRC} ) {
+ $modulebuildrc = $ENV{MODULEBUILDRC};
+ } elsif ( exists($ENV{MODULEBUILDRC}) ) {
+ $self->log_warn("WARNING: Can't find resource file " .
+ "'$ENV{MODULEBUILDRC}' defined in environment.\n" .
+ "No options loaded\n");
+ return ();
+ } else {
+ my $home = $self->_home_dir;
+ return () unless defined $home;
+ $modulebuildrc = File::Spec->catfile( $home, '.modulebuildrc' );
+ return () unless -e $modulebuildrc;
+ }
my $fh = IO::File->new( $modulebuildrc )
or die "Can't open $modulebuildrc: $!";
@@ -1614,7 +1627,7 @@
my $self = shift;
my ($args, $action) = $self->read_args(@_);
$self->merge_args($action, %$args);
- $self->merge_modulebuildrc( $action, %$args ) if $self->use_rcfile;
+ $self->merge_modulebuildrc( $action, %$args );
}
sub super_classes {
|