From: Nicholas Clark Date: Wed, 31 Mar 2004 08:24:29 +0000 (+0000) Subject: Unknowingly for years we've had a test that has assumed the order X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=aaaf2301bad21815040e614ce284ac0058647044;p=p5sagit%2Fp5-mst-13.2.git Unknowingly for years we've had a test that has assumed the order of results from readdir. Fixed. p4raw-id: //depot/perl@22615 --- diff --git a/lib/File/Find/t/find.t b/lib/File/Find/t/find.t index 8c312dd..8512373 100644 --- a/lib/File/Find/t/find.t +++ b/lib/File/Find/t/find.t @@ -15,7 +15,7 @@ BEGIN { $SIG{'__WARN__'} = sub { $warn_msg = $_[0]; warn "# $_[0]"; } } -if ( $symlink_exists ) { print "1..195\n"; } +if ( $symlink_exists ) { print "1..199\n"; } else { print "1..85\n"; } # Uncomment this to see where File::Find is chdir'ing to. Helpful for @@ -122,8 +122,7 @@ sub MkDir($$) { } sub wanted_File_Dir { - print "# \$File::Find::dir => '$File::Find::dir'\n"; - print "# \$_ => '$_'\n"; + printf "# \$File::Find::dir => '$File::Find::dir'\t\$_ => '$_'\n"; s#\.$## if ($^O eq 'VMS' && $_ ne '.'); Check( $Expect_File{$_} ); if ( $FastFileTests_OK ) { @@ -725,7 +724,9 @@ if ( $symlink_exists ) { # the expected paths for %Expect_File %Expect_File = (file_path_name('fa') => 1, - file_path_name('fa', 'fa_ord') => 1, + file_path_name('fa', 'fa_ord') => 2, + # We may encounter the symlink first + file_path_name('fa', 'fa_ord_sl') => 2, file_path_name('fa', 'fsl') => 1, file_path_name('fa', 'fsl', 'fb_ord') => 1, file_path_name('fa', 'fsl', 'fba') => 1, @@ -750,7 +751,9 @@ if ( $symlink_exists ) { follow_skip => 1, no_chdir => 1}, topdir('fa') ); - Check( scalar(keys %Expect_File) == 0 ); + Check( scalar(keys %Expect_File) == 1 ); + # Only the file and its symlink have value 2;< + Check( (values %Expect_File)[0] == 2); unlink file_path('fa', 'fa_ord_sl'); @@ -791,7 +794,10 @@ if ( $symlink_exists ) { file_path_name('fa', 'fab', 'faba') => 1, file_path_name('fa', 'fab', 'faba', 'faba_ord') => 1, file_path_name('fa', 'faa') => 1, - file_path_name('fa', 'faa', 'faa_ord') => 1); + file_path_name('fa', 'faa', 'faa_ord') => 1, + # We may actually encounter the symlink first. + file_path_name('fa', 'faa_sl') => 1, + file_path_name('fa', 'faa_sl', 'faa_ord') => 1); %Expect_Name = (); @@ -805,7 +811,16 @@ if ( $symlink_exists ) { File::Find::find( {wanted => \&wanted_File_Dir, follow => 1, follow_skip => 2, no_chdir => 1}, topdir('fa') ); - Check( scalar(keys %Expect_File) == 0 ); + # If we encountered the symlink first, then the entries corresponding to + # the real name remain, if the real name first then the symlink + my @names = sort keys %Expect_File; + Check( @names == 2 ); + # In sorted order the directory name comes first + Check ($names[1] =~ /^$names[0]/); + # Normalise both to the original name + s/_sl// foreach @names; + Check ($names[0] eq file_path_name('fa', 'faa')); + Check ($names[1] eq file_path_name('fa', 'faa', 'faa_ord')); unlink file_path('fa', 'faa_sl'); }