From: Craig A. Berry Date: Tue, 23 Oct 2007 03:39:19 +0000 (+0000) Subject: Make the File::Find tests stay under t/ where they X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=dd87e51f1a7ecb68f4d69f1547da6cacf6b8c31f;p=p5sagit%2Fp5-mst-13.2.git Make the File::Find tests stay under t/ where they belong (the first call to cleanup() was leaving us at the top of the Perl source tree). p4raw-id: //depot/perl@32175 --- diff --git a/lib/File/Find/t/find.t b/lib/File/Find/t/find.t index 404086e..33e5264 100644 --- a/lib/File/Find/t/find.t +++ b/lib/File/Find/t/find.t @@ -1,11 +1,12 @@ #!./perl - +use strict; +use Cwd; my %Expect_File = (); # what we expect for $_ my %Expect_Name = (); # what we expect for $File::Find::name/fullname my %Expect_Dir = (); # what we expect for $File::Find::dir my $symlink_exists = eval { symlink("",""); 1 }; -my $warn_msg; +my ($warn_msg, @files, $file); BEGIN { @@ -18,6 +19,8 @@ BEGIN { if ( $symlink_exists ) { print "1..199\n"; } else { print "1..85\n"; } +my $orig_dir = cwd(); + # Uncomment this to see where File::Find is chdir'ing to. Helpful for # debugging its little jaunts around the filesystem. # BEGIN { @@ -73,8 +76,10 @@ my $case = 2; my $FastFileTests_OK = 0; sub cleanup { + chdir($orig_dir); + my $need_updir = 0; if (-d dir_path('for_find')) { - chdir(dir_path('for_find')); + $need_updir = 1 if chdir(dir_path('for_find')); } if (-d dir_path('fa')) { unlink file_path('fa', 'fa_ord'), @@ -91,7 +96,10 @@ sub cleanup { rmdir dir_path('fb', 'fba'); rmdir dir_path('fb'); } - chdir(File::Spec->updir); + if ($need_updir) { + my $updir = $^O eq 'VMS' ? File::Spec::VMS->updir() : File::Spec->updir; + chdir($updir); + } if (-d dir_path('for_find')) { rmdir dir_path('for_find') or print "# Can't rmdir for_find: $!\n"; } diff --git a/lib/File/Find/t/taint.t b/lib/File/Find/t/taint.t index 32c63f5..1d6fb00 100644 --- a/lib/File/Find/t/taint.t +++ b/lib/File/Find/t/taint.t @@ -1,5 +1,5 @@ #!./perl -T - +use strict; my %Expect_File = (); # what we expect for $_ my %Expect_Name = (); # what we expect for $File::Find::name/fullname @@ -46,6 +46,9 @@ use File::Find; use File::Spec; use Cwd; +my $orig_dir = cwd(); +( my $orig_dir_untainted ) = $orig_dir =~ m|^(.+)$|; # untaint it + cleanup(); my $found; @@ -64,8 +67,10 @@ my $case = 2; my $FastFileTests_OK = 0; sub cleanup { + chdir($orig_dir_untainted); + my $need_updir = 0; if (-d dir_path('for_find')) { - chdir(dir_path('for_find')); + $need_updir = 1 if chdir(dir_path('for_find')); } if (-d dir_path('fa')) { unlink file_path('fa', 'fa_ord'), @@ -82,7 +87,10 @@ sub cleanup { rmdir dir_path('fb', 'fba'); rmdir dir_path('fb'); } - chdir File::Spec->updir; + if ($need_updir) { + my $updir = $^O eq 'VMS' ? File::Spec::VMS->updir() : File::Spec->updir; + chdir($updir); + } if (-d dir_path('for_find')) { rmdir dir_path('for_find') or print "# Can't rmdir for_find: $!\n"; }