Re: Extra MakeMaker noise in lib/ExtUtils/Embed.t @12791
[p5sagit/p5-mst-13.2.git] / t / op / chdir.t
index 23ac735..c2ec1e0 100644 (file)
@@ -7,26 +7,36 @@ BEGIN {
     @INC = qw(t . lib ../lib);
 }
 
+use Config;
 require "test.pl";
-plan(tests => 25);
+plan(tests => 31);
 
 my $IsVMS = $^O eq 'VMS';
 
+my ($saved_sys_login);
+BEGIN {
+    $saved_sys_login = $ENV{'SYS$LOGIN'} if $^O eq 'VMS'
+}
+END {
+    $ENV{'SYS$LOGIN'} = $saved_sys_login if $^O eq 'VMS';
+}
+
 # Might be a little early in the testing process to start using these,
 # but I can't think of a way to write this test without them.
-use File::Spec::Functions qw(:DEFAULT splitdir rel2abs);
+use File::Spec::Functions qw(:DEFAULT splitdir rel2abs splitpath);
 
 # Can't use Cwd::abs_path() because it has different ideas about
-# path seperators than File::Spec.
+# path separators than File::Spec.
 sub abs_path {
-    rel2abs(curdir);
+    $IsVMS ? uc(rel2abs(curdir)) : rel2abs(curdir);
 }
 
 my $Cwd = abs_path;
 
 # Let's get to a known position
 SKIP: {
-    skip("Already in t/", 2) if (splitdir(abs_path))[-1] eq 't';
+    my ($vol,$dir) = splitpath(abs_path,1);
+    skip("Already in t/", 2) if (splitdir($dir))[-1] eq ($IsVMS ? 'T' : 't');
 
     ok( chdir('t'),     'chdir("t")');
     is( abs_path, catdir($Cwd, 't'),       '  abs_path() agrees' );
@@ -44,7 +54,7 @@ sub check_env {
     if( $key eq 'SYS$LOGIN' && !$IsVMS ) {
         ok( !chdir(),         "chdir() on $^O ignores only \$ENV{$key} set" );
         is( abs_path, $Cwd,   '  abs_path() did not change' );
-        pass( "  no need to chdir back on $^O" );
+        pass( "  no need to test SYS\$LOGIN on $^O" ) for 1..7;
     }
     else {
         ok( chdir(),              "chdir() w/ only \$ENV{$key} set" );
@@ -80,19 +90,32 @@ WARNING
     }
 }
 
+sub clean_env {
+    foreach (@magic_envs) {
+        delete $ENV{$_} unless $IsVMS && $_ eq 'HOME' && !$Config{'d_setenv'};
+    }
+    # The following means we won't really be testing for non-existence,
+    # but in Perl we can only delete from the process table, not the job 
+    # table.
+    $ENV{'SYS$LOGIN'} = '' if $IsVMS;
+}
+
 foreach my $key (@magic_envs) {
     # We're going to be using undefs a lot here.
     no warnings 'uninitialized';
 
-    local %ENV = ();
-    $ENV{$key} = catdir $Cwd, 'op';
-    
+    clean_env;
+    $ENV{$key} = catdir $Cwd, ($IsVMS ? 'OP' : 'op');
+
     check_env($key);
 }
 
 {
-    local %ENV = ();
-
-    ok( !chdir(),                   'chdir() w/o any ENV set' );
+    clean_env;
+    if ($IsVMS && !$Config{'d_setenv'}) {
+        pass("Can't reset HOME, so chdir() test meaningless");
+    } else {
+        ok( !chdir(),                   'chdir() w/o any ENV set' );
+    }
     is( abs_path, $Cwd,             '  abs_path() agrees' );
 }