Skip to content

Commit

Permalink
r67089@windhund: schwern | 2008-09-28 16:56:43 -0400
Browse files Browse the repository at this point in the history
 Add code to MBTest to clean out any stray environment variables the user
 might have set which could effect our tests.  This solves the
 HARNESS_TIMER problem and any other future ENV issues.


git-svn-id: http://svn.perl.org/modules/Module-Build/trunk@11898 50811bd7-b8ce-0310-adc1-d9db26280581
  • Loading branch information
schwern committed Sep 28, 2008
1 parent 270598d commit b2b582c
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions t/lib/MBTest.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,43 @@ use strict;
use File::Spec;
use File::Path ();


# Setup the code to clean out %ENV
BEGIN {
# Environment variables which might effect our testing
my @delete_env_keys = qw(
DEVEL_COVER_OPTIONS
MODULEBUILDRC
HARNESS_TIMER
HARNESS_OPTIONS
HARNESS_VERBOSE
);

# Remember the ENV values because on VMS %ENV is global
# to the user, not the process.
my %restore_env_keys;

sub clean_env {
for my $key (@delete_env_keys) {
if( exists $ENV{$key} ) {
$restore_env_keys{$key} = delete $ENV{$key};
}
else {
delete $ENV{$key};
}
}
}

END {
while( my($key, $val) = each %restore_env_keys ) {
$ENV{$key} = $val;
}
}
}


BEGIN {
# Make sure none of our tests load the users ~/.modulebuildrc file
$ENV{MODULEBUILDRC} = 'NONE';
clean_env();

# In case the test wants to use our other bundled
# modules, make sure they can be loaded.
Expand Down Expand Up @@ -58,6 +92,8 @@ my @extra_exports = qw(
push @EXPORT, @extra_exports;
__PACKAGE__->export(scalar caller, @extra_exports);
# XXX ^-- that should really happen in import()


########################################################################

{ # Setup a temp directory if it doesn't exist
Expand Down

0 comments on commit b2b582c

Please sign in to comment.