This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Upgrade to ExtUtils-MakeMaker-6.48
[perl5.git] / t / lib / MakeMaker / Test / Utils.pm
index 9cbd015..2e9e725 100644 (file)
@@ -20,6 +20,41 @@ our @EXPORT = qw(which_perl perl_lib makefile_name makefile_backup
                 );
 
 
+# Setup the code to clean out %ENV
+{
+    # Environment variables which might effect our testing
+    my @delete_env_keys = qw(
+        PERL_MM_OPT
+        PERL_MM_USE_DEFAULT
+        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;
+        }
+    }
+}
+clean_env();
+
+
 =head1 NAME
 
 MakeMaker::Test::Utils - Utility routines for testing MakeMaker