From: Craig A. Berry Date: Sat, 29 Sep 2001 09:35:33 +0000 (-0500) Subject: chdir.t finally (I hope) X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d6cdadd41a6af58a8a378208d6a87c63df59c125;p=p5sagit%2Fp5-mst-13.2.git chdir.t finally (I hope) Message-Id: p4raw-id: //depot/perl@12266 --- diff --git a/t/op/chdir.t b/t/op/chdir.t index 9ad9921..764e31a 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' );