diff options
author | Craig A. Berry <craigberry@mac.com> | 2001-09-29 04:35:33 -0500 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2001-09-29 13:51:49 +0000 |
commit | d6cdadd41a6af58a8a378208d6a87c63df59c125 (patch) | |
tree | d35a930735fbc309ce07f7b3c1ac14390314d9d2 /t/op/chdir.t | |
parent | c6c73c786b4d4a71e6f053b58104cf6488c744a4 (diff) | |
download | perl-d6cdadd41a6af58a8a378208d6a87c63df59c125.tar.gz |
chdir.t finally (I hope)
Message-Id: <a05101000b7db8afde231@[172.16.52.1]>
p4raw-id: //depot/perl@12266
Diffstat (limited to 't/op/chdir.t')
-rw-r--r-- | t/op/chdir.t | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/t/op/chdir.t b/t/op/chdir.t index 9ad99215d4..764e31ae3c 100644 --- a/t/op/chdir.t +++ b/t/op/chdir.t @@ -8,16 +8,23 @@ BEGIN { } 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); } @@ -44,7 +51,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,18 +87,26 @@ WARNING } } +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' ); |