Author: schwern
Date: Sun Sep 28 13:57:01 2008
New Revision: 11898

Modified:
   Module-Build/trunk/   (props changed)
   Module-Build/trunk/t/lib/MBTest.pm

Log:
 [EMAIL PROTECTED]:  schwern | 2008-09-28 16:56:43 -0400
 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.


Modified: Module-Build/trunk/t/lib/MBTest.pm
==============================================================================
--- Module-Build/trunk/t/lib/MBTest.pm  (original)
+++ Module-Build/trunk/t/lib/MBTest.pm  Sun Sep 28 13:57:01 2008
@@ -5,9 +5,43 @@
 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.
@@ -58,6 +92,8 @@
 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

Reply via email to