}
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'};
+}
+END {
+ $ENV{'SYS$LOGIN'} = $saved_sys_login;
+}
# 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);
# 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 {
$IsVMS ? uc(rel2abs(curdir)) : rel2abs(curdir);
}
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" );
}
}
+sub clean_env {
+ delete $ENV{$_} foreach @magic_envs;
+ # 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 = () if !$IsVMS;
+ clean_env;
$ENV{$key} = catdir $Cwd, ($IsVMS ? 'OP' : 'op');
check_env($key);
}
{
- local %ENV = () if !$IsVMS;
+ clean_env;
ok( !chdir(), 'chdir() w/o any ENV set' );
is( abs_path, $Cwd, ' abs_path() agrees' );