4 my %Expect_File = (); # what we expect for $_
5 my %Expect_Name = (); # what we expect for $File::Find::name/fullname
6 my %Expect_Dir = (); # what we expect for $File::Find::dir
7 my $symlink_exists = eval { symlink("",""); 1 };
13 unshift @INC => '../lib';
15 $SIG{'__WARN__'} = sub { $warn_msg = $_[0]; warn "# $_[0]"; }
18 if ( $symlink_exists ) { print "1..199\n"; }
19 else { print "1..85\n"; }
21 # Uncomment this to see where File::Find is chdir'ing to. Helpful for
22 # debugging its little jaunts around the filesystem.
25 # *CORE::GLOBAL::chdir = sub ($) {
26 # my($file, $line) = (caller)[1,2];
28 # printf "# cwd: %s\n", cwd();
29 # print "# chdir: @_ from $file at $line\n";
30 # my($return) = CORE::chdir($_[0]);
31 # printf "# newcwd: %s\n", cwd();
40 if ($^O eq 'MSWin32' || $^O eq 'cygwin' || $^O eq 'VMS')
42 # This is a hack - at present File::Find does not produce native names on
43 # Win32 or VMS, so force File::Spec to use Unix names.
44 # must be set *before* importing File::Find
45 require File::Spec::Unix;
46 @File::Spec::ISA = 'File::Spec::Unix';
54 $::count_commonsense = 0;
55 find({wanted => sub { ++$::count_commonsense if $_ eq 'commonsense.t'; } },
57 if ($::count_commonsense == 1) {
60 print "not ok 1 # found $::count_commonsense files named 'commonsense.t'\n";
63 $::count_commonsense = 0;
64 finddepth({wanted => sub { ++$::count_commonsense if $_ eq 'commonsense.t'; } },
66 if ($::count_commonsense == 1) {
69 print "not ok 2 # found $::count_commonsense files named 'commonsense.t'\n";
73 my $FastFileTests_OK = 0;
76 if (-d dir_path('for_find')) {
77 chdir(dir_path('for_find'));
79 if (-d dir_path('fa')) {
80 unlink file_path('fa', 'fa_ord'),
81 file_path('fa', 'fsl'),
82 file_path('fa', 'faa', 'faa_ord'),
83 file_path('fa', 'fab', 'fab_ord'),
84 file_path('fa', 'fab', 'faba', 'faba_ord'),
85 file_path('fb', 'fb_ord'),
86 file_path('fb', 'fba', 'fba_ord');
87 rmdir dir_path('fa', 'faa');
88 rmdir dir_path('fa', 'fab', 'faba');
89 rmdir dir_path('fa', 'fab');
91 rmdir dir_path('fb', 'fba');
94 chdir(File::Spec->updir);
95 if (-d dir_path('for_find')) {
96 rmdir dir_path('for_find') or print "# Can't rmdir for_find: $!\n";
106 if ($_[0]) { print "ok $case\n"; }
107 else { print "not ok $case\n"; }
112 if ($_[0]) { print "ok $case\n"; }
113 else { print "not ok $case\n $!\n"; exit 0; }
117 CheckDie( open(my $T,'>',$_[0]) );
121 CheckDie( mkdir($_[0],$_[1]) );
124 sub wanted_File_Dir {
125 printf "# \$File::Find::dir => '$File::Find::dir'\t\$_ => '$_'\n";
126 s#\.$## if ($^O eq 'VMS' && $_ ne '.');
127 Check( $Expect_File{$_} );
128 if ( $FastFileTests_OK ) {
129 delete $Expect_File{ $_}
130 unless ( $Expect_Dir{$_} && ! -d _ );
132 delete $Expect_File{$_}
133 unless ( $Expect_Dir{$_} && ! -d $_ );
137 sub wanted_File_Dir_prune {
139 $File::Find::prune=1 if $_ eq 'faba';
143 my $n = $File::Find::name;
144 $n =~ s#\.$## if ($^O eq 'VMS' && $n ne '.');
145 print "# \$File::Find::name => '$n'\n";
146 my $i = rindex($n,'/');
147 my $OK = exists($Expect_Name{$n});
148 unless ($^O eq 'MacOS') {
150 $OK= exists($Expect_Name{substr($n,0,$i)}) if $i >= 0;
154 delete $Expect_Name{$n};
158 print "# \$_ => '$_'\n";
159 s#\.$## if ($^O eq 'VMS' && $_ ne '.');
160 my $i = rindex($_,'/');
161 my $OK = exists($Expect_File{ $_});
162 unless ($^O eq 'MacOS') {
164 $OK= exists($Expect_File{ substr($_,0,$i)}) if $i >= 0;
168 delete $Expect_File{ $_};
172 print "# \$File::Find::dir => '$File::Find::dir'\n";
173 print "# \$_ => '$_'\n";
180 print "# --preprocess--\n";
181 print "# \$File::Find::dir => '$File::Find::dir' \n";
182 foreach $file (@files) {
183 $file =~ s/\.(dir)?$// if $^O eq 'VMS';
185 delete $Expect_Dir{ $File::Find::dir }->{$file};
187 print "# --end preprocess--\n";
188 Check(scalar(keys %{$Expect_Dir{ $File::Find::dir }}) == 0);
189 if (scalar(keys %{$Expect_Dir{ $File::Find::dir }}) == 0) {
190 delete $Expect_Dir{ $File::Find::dir }
196 print "# postprocess: \$File::Find::dir => '$File::Find::dir' \n";
197 delete $Expect_Dir{ $File::Find::dir};
201 # Use dir_path() to specify a directory path that's expected for
202 # $File::Find::dir (%Expect_Dir). Also use it in file operations like
205 # dir_path() concatenates directory names to form a *relative*
206 # directory path, independent from the platform it's run on, although
207 # there are limitations. Don't try to create an absolute path,
208 # because that may fail on operating systems that have the concept of
209 # volume names (e.g. Mac OS). As a special case, you can pass it a "."
210 # as first argument, to create a directory path like "./fa/dir" on
211 # operating systems other than Mac OS (actually, Mac OS will ignore
212 # the ".", if it's the first argument). If there's no second argument,
213 # this function will return the empty string on Mac OS and the string
217 my $first_arg = shift @_;
219 if ($first_arg eq '.') {
220 if ($^O eq 'MacOS') {
222 # ignore first argument; return a relative path
223 # with leading ":" and with trailing ":"
224 return File::Spec->catdir(@_);
226 return './' unless @_;
227 my $path = File::Spec->catdir(@_);
233 } else { # $first_arg ne '.'
234 return $first_arg unless @_; # return plain filename
235 return File::Spec->catdir($first_arg, @_); # relative path
240 # Use topdir() to specify a directory path that you want to pass to
241 # find/finddepth. Basically, topdir() does the same as dir_path() (see
242 # above), except that there's no trailing ":" on Mac OS.
245 my $path = dir_path(@_);
246 $path =~ s/:$// if ($^O eq 'MacOS');
251 # Use file_path() to specify a file path that's expected for $_
252 # (%Expect_File). Also suitable for file operations like unlink etc.
254 # file_path() concatenates directory names (if any) and a filename to
255 # form a *relative* file path (the last argument is assumed to be a
256 # file). It's independent from the platform it's run on, although
257 # there are limitations. As a special case, you can pass it a "." as
258 # first argument, to create a file path like "./fa/file" on operating
259 # systems other than Mac OS (actually, Mac OS will ignore the ".", if
260 # it's the first argument). If there's no second argument, this
261 # function will return the empty string on Mac OS and the string "./"
265 my $first_arg = shift @_;
267 if ($first_arg eq '.') {
268 if ($^O eq 'MacOS') {
270 # ignore first argument; return a relative path
271 # with leading ":", but without trailing ":"
272 return File::Spec->catfile(@_);
274 return './' unless @_;
275 my $path = File::Spec->catfile(@_);
281 } else { # $first_arg ne '.'
282 return $first_arg unless @_; # return plain filename
283 return File::Spec->catfile($first_arg, @_); # relative path
288 # Use file_path_name() to specify a file path that's expected for
289 # $File::Find::Name (%Expect_Name). Note: When the no_chdir => 1
290 # option is in effect, $_ is the same as $File::Find::Name. In that
291 # case, also use this function to specify a file path that's expected
294 # Basically, file_path_name() does the same as file_path() (see
295 # above), except that there's always a leading ":" on Mac OS, even for
296 # plain file/directory names.
299 my $path = file_path(@_);
300 $path = ":$path" if (($^O eq 'MacOS') && ($path !~ /:/));
306 MkDir( dir_path('for_find'), 0770 );
307 CheckDie(chdir( dir_path('for_find')));
308 MkDir( dir_path('fa'), 0770 );
309 MkDir( dir_path('fb'), 0770 );
310 touch( file_path('fb', 'fb_ord') );
311 MkDir( dir_path('fb', 'fba'), 0770 );
312 touch( file_path('fb', 'fba', 'fba_ord') );
313 if ($^O eq 'MacOS') {
314 CheckDie( symlink(':fb',':fa:fsl') ) if $symlink_exists;
316 CheckDie( symlink('../fb','fa/fsl') ) if $symlink_exists;
318 touch( file_path('fa', 'fa_ord') );
320 MkDir( dir_path('fa', 'faa'), 0770 );
321 touch( file_path('fa', 'faa', 'faa_ord') );
322 MkDir( dir_path('fa', 'fab'), 0770 );
323 touch( file_path('fa', 'fab', 'fab_ord') );
324 MkDir( dir_path('fa', 'fab', 'faba'), 0770 );
325 touch( file_path('fa', 'fab', 'faba', 'faba_ord') );
328 %Expect_File = (File::Spec->curdir => 1, file_path('fsl') => 1,
329 file_path('fa_ord') => 1, file_path('fab') => 1,
330 file_path('fab_ord') => 1, file_path('faba') => 1,
331 file_path('faa') => 1, file_path('faa_ord') => 1);
333 delete $Expect_File{ file_path('fsl') } unless $symlink_exists;
336 %Expect_Dir = ( dir_path('fa') => 1, dir_path('faa') => 1,
337 dir_path('fab') => 1, dir_path('faba') => 1,
338 dir_path('fb') => 1, dir_path('fba') => 1);
340 delete @Expect_Dir{ dir_path('fb'), dir_path('fba') } unless $symlink_exists;
341 File::Find::find( {wanted => \&wanted_File_Dir_prune}, topdir('fa') );
342 Check( scalar(keys %Expect_File) == 0 );
345 print "# check re-entrancy\n";
347 %Expect_File = (File::Spec->curdir => 1, file_path('fsl') => 1,
348 file_path('fa_ord') => 1, file_path('fab') => 1,
349 file_path('fab_ord') => 1, file_path('faba') => 1,
350 file_path('faa') => 1, file_path('faa_ord') => 1);
352 delete $Expect_File{ file_path('fsl') } unless $symlink_exists;
355 %Expect_Dir = ( dir_path('fa') => 1, dir_path('faa') => 1,
356 dir_path('fab') => 1, dir_path('faba') => 1,
357 dir_path('fb') => 1, dir_path('fba') => 1);
359 delete @Expect_Dir{ dir_path('fb'), dir_path('fba') } unless $symlink_exists;
361 File::Find::find( {wanted => sub { wanted_File_Dir_prune();
362 File::Find::find( {wanted => sub
363 {} }, File::Spec->curdir ); } },
366 Check( scalar(keys %Expect_File) == 0 );
369 # no_chdir is in effect, hence we use file_path_name to specify the expected paths for %Expect_File
371 %Expect_File = (file_path_name('fa') => 1,
372 file_path_name('fa', 'fsl') => 1,
373 file_path_name('fa', 'fa_ord') => 1,
374 file_path_name('fa', 'fab') => 1,
375 file_path_name('fa', 'fab', 'fab_ord') => 1,
376 file_path_name('fa', 'fab', 'faba') => 1,
377 file_path_name('fa', 'fab', 'faba', 'faba_ord') => 1,
378 file_path_name('fa', 'faa') => 1,
379 file_path_name('fa', 'faa', 'faa_ord') => 1,);
381 delete $Expect_File{ file_path_name('fa', 'fsl') } unless $symlink_exists;
384 %Expect_Dir = (dir_path('fa') => 1,
385 dir_path('fa', 'faa') => 1,
386 dir_path('fa', 'fab') => 1,
387 dir_path('fa', 'fab', 'faba') => 1,
389 dir_path('fb', 'fba') => 1);
391 delete @Expect_Dir{ dir_path('fb'), dir_path('fb', 'fba') }
392 unless $symlink_exists;
394 File::Find::find( {wanted => \&wanted_File_Dir, no_chdir => 1},
395 topdir('fa') ); Check( scalar(keys %Expect_File) == 0 );
400 %Expect_Name = (File::Spec->curdir => 1,
401 file_path_name('.', 'fa') => 1,
402 file_path_name('.', 'fa', 'fsl') => 1,
403 file_path_name('.', 'fa', 'fa_ord') => 1,
404 file_path_name('.', 'fa', 'fab') => 1,
405 file_path_name('.', 'fa', 'fab', 'fab_ord') => 1,
406 file_path_name('.', 'fa', 'fab', 'faba') => 1,
407 file_path_name('.', 'fa', 'fab', 'faba', 'faba_ord') => 1,
408 file_path_name('.', 'fa', 'faa') => 1,
409 file_path_name('.', 'fa', 'faa', 'faa_ord') => 1,
410 file_path_name('.', 'fb') => 1,
411 file_path_name('.', 'fb', 'fba') => 1,
412 file_path_name('.', 'fb', 'fba', 'fba_ord') => 1,
413 file_path_name('.', 'fb', 'fb_ord') => 1);
415 delete $Expect_Name{ file_path('.', 'fa', 'fsl') } unless $symlink_exists;
417 File::Find::finddepth( {wanted => \&wanted_Name}, File::Spec->curdir );
418 Check( scalar(keys %Expect_Name) == 0 );
421 # no_chdir is in effect, hence we use file_path_name to specify the
422 # expected paths for %Expect_File
424 %Expect_File = (File::Spec->curdir => 1,
425 file_path_name('.', 'fa') => 1,
426 file_path_name('.', 'fa', 'fsl') => 1,
427 file_path_name('.', 'fa', 'fa_ord') => 1,
428 file_path_name('.', 'fa', 'fab') => 1,
429 file_path_name('.', 'fa', 'fab', 'fab_ord') => 1,
430 file_path_name('.', 'fa', 'fab', 'faba') => 1,
431 file_path_name('.', 'fa', 'fab', 'faba', 'faba_ord') => 1,
432 file_path_name('.', 'fa', 'faa') => 1,
433 file_path_name('.', 'fa', 'faa', 'faa_ord') => 1,
434 file_path_name('.', 'fb') => 1,
435 file_path_name('.', 'fb', 'fba') => 1,
436 file_path_name('.', 'fb', 'fba', 'fba_ord') => 1,
437 file_path_name('.', 'fb', 'fb_ord') => 1);
439 delete $Expect_File{ file_path_name('.', 'fa', 'fsl') } unless $symlink_exists;
443 File::Find::finddepth( {wanted => \&wanted_File, no_chdir => 1},
444 File::Spec->curdir );
446 Check( scalar(keys %Expect_File) == 0 );
449 print "# check preprocess\n";
453 File::Spec->curdir => {fa => 1, fb => 1},
454 dir_path('.', 'fa') => {faa => 1, fab => 1, fa_ord => 1},
455 dir_path('.', 'fa', 'faa') => {faa_ord => 1},
456 dir_path('.', 'fa', 'fab') => {faba => 1, fab_ord => 1},
457 dir_path('.', 'fa', 'fab', 'faba') => {faba_ord => 1},
458 dir_path('.', 'fb') => {fba => 1, fb_ord => 1},
459 dir_path('.', 'fb', 'fba') => {fba_ord => 1}
462 File::Find::find( {wanted => \&noop_wanted,
463 preprocess => \&my_preprocess}, File::Spec->curdir );
465 Check( scalar(keys %Expect_Dir) == 0 );
468 print "# check postprocess\n";
472 File::Spec->curdir => 1,
473 dir_path('.', 'fa') => 1,
474 dir_path('.', 'fa', 'faa') => 1,
475 dir_path('.', 'fa', 'fab') => 1,
476 dir_path('.', 'fa', 'fab', 'faba') => 1,
477 dir_path('.', 'fb') => 1,
478 dir_path('.', 'fb', 'fba') => 1
481 File::Find::find( {wanted => \&noop_wanted,
482 postprocess => \&my_postprocess}, File::Spec->curdir );
484 Check( scalar(keys %Expect_Dir) == 0 );
487 print "# checking argument localization\n";
489 ### this checks the fix of perlbug [19977] ###
490 my @foo = qw( a b c d e f );
491 my %pre = map { $_ => } @foo;
493 File::Find::find( sub { } , 'fa' ) for @foo;
494 delete $pre{$_} for @foo;
496 Check( scalar( keys %pre ) == 0 );
499 # see thread starting
500 # http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2004-02/msg00351.html
502 print "# checking that &_ and %_ are still accessible and that\n",
503 "# tie magic on \$_ is not triggered\n";
516 sub FETCH {return 'N'};
517 sub TIESCALAR {bless []};
520 Check( scalar( keys %_ ) == 0 );
524 File::Find::find( sub { $true_count++; $_{$_}++; &_; } , 'fa' ) for @foo;
527 Check( $tie_called == 0);
528 Check( scalar( keys %_ ) == $true_count );
529 Check( $sub == $true_count );
530 Check( scalar( @foo ) == 1);
531 Check( $foo[0] eq 'N' );
534 if ( $symlink_exists ) {
535 print "# --- symbolic link tests --- \n";
536 $FastFileTests_OK= 1;
539 # Verify that File::Find::find will call wanted even if the topdir of
540 # is a symlink to a directory, and it shouldn't follow the link
541 # unless follow is set, which it isn't in this case
542 %Expect_File = ( file_path('fsl') => 1 );
545 File::Find::find( {wanted => \&wanted_File_Dir}, topdir('fa', 'fsl') );
546 Check( scalar(keys %Expect_File) == 0 );
549 %Expect_File = (File::Spec->curdir => 1, file_path('fa_ord') => 1,
550 file_path('fsl') => 1, file_path('fb_ord') => 1,
551 file_path('fba') => 1, file_path('fba_ord') => 1,
552 file_path('fab') => 1, file_path('fab_ord') => 1,
553 file_path('faba') => 1, file_path('faa') => 1,
554 file_path('faa_ord') => 1);
558 %Expect_Dir = (File::Spec->curdir => 1, dir_path('fa') => 1,
559 dir_path('faa') => 1, dir_path('fab') => 1,
560 dir_path('faba') => 1, dir_path('fb') => 1,
561 dir_path('fba') => 1);
563 File::Find::find( {wanted => \&wanted_File_Dir_prune,
564 follow_fast => 1}, topdir('fa') );
566 Check( scalar(keys %Expect_File) == 0 );
569 # no_chdir is in effect, hence we use file_path_name to specify
570 # the expected paths for %Expect_File
572 %Expect_File = (file_path_name('fa') => 1,
573 file_path_name('fa', 'fa_ord') => 1,
574 file_path_name('fa', 'fsl') => 1,
575 file_path_name('fa', 'fsl', 'fb_ord') => 1,
576 file_path_name('fa', 'fsl', 'fba') => 1,
577 file_path_name('fa', 'fsl', 'fba', 'fba_ord') => 1,
578 file_path_name('fa', 'fab') => 1,
579 file_path_name('fa', 'fab', 'fab_ord') => 1,
580 file_path_name('fa', 'fab', 'faba') => 1,
581 file_path_name('fa', 'fab', 'faba', 'faba_ord') => 1,
582 file_path_name('fa', 'faa') => 1,
583 file_path_name('fa', 'faa', 'faa_ord') => 1);
587 %Expect_Dir = (dir_path('fa') => 1,
588 dir_path('fa', 'faa') => 1,
589 dir_path('fa', 'fab') => 1,
590 dir_path('fa', 'fab', 'faba') => 1,
592 dir_path('fb', 'fba') => 1);
594 File::Find::find( {wanted => \&wanted_File_Dir, follow_fast => 1,
595 no_chdir => 1}, topdir('fa') );
597 Check( scalar(keys %Expect_File) == 0 );
601 %Expect_Name = (file_path_name('fa') => 1,
602 file_path_name('fa', 'fa_ord') => 1,
603 file_path_name('fa', 'fsl') => 1,
604 file_path_name('fa', 'fsl', 'fb_ord') => 1,
605 file_path_name('fa', 'fsl', 'fba') => 1,
606 file_path_name('fa', 'fsl', 'fba', 'fba_ord') => 1,
607 file_path_name('fa', 'fab') => 1,
608 file_path_name('fa', 'fab', 'fab_ord') => 1,
609 file_path_name('fa', 'fab', 'faba') => 1,
610 file_path_name('fa', 'fab', 'faba', 'faba_ord') => 1,
611 file_path_name('fa', 'faa') => 1,
612 file_path_name('fa', 'faa', 'faa_ord') => 1);
616 File::Find::finddepth( {wanted => \&wanted_Name,
617 follow_fast => 1}, topdir('fa') );
619 Check( scalar(keys %Expect_Name) == 0 );
621 # no_chdir is in effect, hence we use file_path_name to specify
622 # the expected paths for %Expect_File
624 %Expect_File = (file_path_name('fa') => 1,
625 file_path_name('fa', 'fa_ord') => 1,
626 file_path_name('fa', 'fsl') => 1,
627 file_path_name('fa', 'fsl', 'fb_ord') => 1,
628 file_path_name('fa', 'fsl', 'fba') => 1,
629 file_path_name('fa', 'fsl', 'fba', 'fba_ord') => 1,
630 file_path_name('fa', 'fab') => 1,
631 file_path_name('fa', 'fab', 'fab_ord') => 1,
632 file_path_name('fa', 'fab', 'faba') => 1,
633 file_path_name('fa', 'fab', 'faba', 'faba_ord') => 1,
634 file_path_name('fa', 'faa') => 1,
635 file_path_name('fa', 'faa', 'faa_ord') => 1);
640 File::Find::finddepth( {wanted => \&wanted_File, follow_fast => 1,
641 no_chdir => 1}, topdir('fa') );
643 Check( scalar(keys %Expect_File) == 0 );
646 print "# check dangling symbolic links\n";
647 MkDir( dir_path('dangling_dir'), 0770 );
648 CheckDie( symlink( dir_path('dangling_dir'),
649 file_path('dangling_dir_sl') ) );
650 rmdir dir_path('dangling_dir');
651 touch(file_path('dangling_file'));
652 if ($^O eq 'MacOS') {
653 CheckDie( symlink('dangling_file', ':fa:dangling_file_sl') );
655 CheckDie( symlink('../dangling_file','fa/dangling_file_sl') );
657 unlink file_path('dangling_file');
660 # these tests should also emit a warning
663 %Expect_File = (File::Spec->curdir => 1,
664 file_path('dangling_file_sl') => 1,
665 file_path('fa_ord') => 1,
666 file_path('fsl') => 1,
667 file_path('fb_ord') => 1,
668 file_path('fba') => 1,
669 file_path('fba_ord') => 1,
670 file_path('fab') => 1,
671 file_path('fab_ord') => 1,
672 file_path('faba') => 1,
673 file_path('faba_ord') => 1,
674 file_path('faa') => 1,
675 file_path('faa_ord') => 1);
681 File::Find::find( {wanted => \&wanted_File, follow => 1,
683 sub { $warn_msg = "$_[0] is a dangling symbolic link" }
685 topdir('dangling_dir_sl'), topdir('fa') );
687 Check( scalar(keys %Expect_File) == 0 );
688 Check( $warn_msg =~ m|dangling_file_sl is a dangling symbolic link| );
689 unlink file_path('fa', 'dangling_file_sl'),
690 file_path('dangling_dir_sl');
695 print "# check recursion\n";
696 if ($^O eq 'MacOS') {
697 CheckDie( symlink(':fa:faa',':fa:faa:faa_sl') );
699 CheckDie( symlink('../faa','fa/faa/faa_sl') );
702 eval {File::Find::find( {wanted => \&simple_wanted, follow => 1,
703 no_chdir => 1}, topdir('fa') ); };
704 Check( $@ =~ m|for_find[:/]fa[:/]faa[:/]faa_sl is a recursive symbolic link| );
705 unlink file_path('fa', 'faa', 'faa_sl');
708 print "# check follow_skip (file)\n";
709 if ($^O eq 'MacOS') {
710 CheckDie( symlink(':fa:fa_ord',':fa:fa_ord_sl') ); # symlink to a file
712 CheckDie( symlink('./fa_ord','fa/fa_ord_sl') ); # symlink to a file
716 eval {File::Find::finddepth( {wanted => \&simple_wanted,
718 follow_skip => 0, no_chdir => 1},
721 Check( $@ =~ m|for_find[:/]fa[:/]fa_ord encountered a second time| );
724 # no_chdir is in effect, hence we use file_path_name to specify
725 # the expected paths for %Expect_File
727 %Expect_File = (file_path_name('fa') => 1,
728 file_path_name('fa', 'fa_ord') => 2,
729 # We may encounter the symlink first
730 file_path_name('fa', 'fa_ord_sl') => 2,
731 file_path_name('fa', 'fsl') => 1,
732 file_path_name('fa', 'fsl', 'fb_ord') => 1,
733 file_path_name('fa', 'fsl', 'fba') => 1,
734 file_path_name('fa', 'fsl', 'fba', 'fba_ord') => 1,
735 file_path_name('fa', 'fab') => 1,
736 file_path_name('fa', 'fab', 'fab_ord') => 1,
737 file_path_name('fa', 'fab', 'faba') => 1,
738 file_path_name('fa', 'fab', 'faba', 'faba_ord') => 1,
739 file_path_name('fa', 'faa') => 1,
740 file_path_name('fa', 'faa', 'faa_ord') => 1);
744 %Expect_Dir = (dir_path('fa') => 1,
745 dir_path('fa', 'faa') => 1,
746 dir_path('fa', 'fab') => 1,
747 dir_path('fa', 'fab', 'faba') => 1,
749 dir_path('fb','fba') => 1);
751 File::Find::finddepth( {wanted => \&wanted_File_Dir, follow => 1,
752 follow_skip => 1, no_chdir => 1},
754 Check( scalar(keys %Expect_File) == 0 );
755 unlink file_path('fa', 'fa_ord_sl');
758 print "# check follow_skip (directory)\n";
759 if ($^O eq 'MacOS') {
760 CheckDie( symlink(':fa:faa',':fa:faa_sl') ); # symlink to a directory
762 CheckDie( symlink('./faa','fa/faa_sl') ); # symlink to a directory
766 eval {File::Find::find( {wanted => \&simple_wanted, follow => 1,
767 follow_skip => 0, no_chdir => 1},
770 Check( $@ =~ m|for_find[:/]fa[:/]faa[:/]? encountered a second time| );
775 eval {File::Find::find( {wanted => \&simple_wanted, follow => 1,
776 follow_skip => 1, no_chdir => 1},
779 Check( $@ =~ m|for_find[:/]fa[:/]faa[:/]? encountered a second time| );
781 # no_chdir is in effect, hence we use file_path_name to specify
782 # the expected paths for %Expect_File
784 %Expect_File = (file_path_name('fa') => 1,
785 file_path_name('fa', 'fa_ord') => 1,
786 file_path_name('fa', 'fsl') => 1,
787 file_path_name('fa', 'fsl', 'fb_ord') => 1,
788 file_path_name('fa', 'fsl', 'fba') => 1,
789 file_path_name('fa', 'fsl', 'fba', 'fba_ord') => 1,
790 file_path_name('fa', 'fab') => 1,
791 file_path_name('fa', 'fab', 'fab_ord') => 1,
792 file_path_name('fa', 'fab', 'faba') => 1,
793 file_path_name('fa', 'fab', 'faba', 'faba_ord') => 1,
794 file_path_name('fa', 'faa') => 1,
795 file_path_name('fa', 'faa', 'faa_ord') => 1,
796 # We may actually encounter the symlink first.
797 file_path_name('fa', 'faa_sl') => 1,
798 file_path_name('fa', 'faa_sl', 'faa_ord') => 1);
802 %Expect_Dir = (dir_path('fa') => 1,
803 dir_path('fa', 'faa') => 1,
804 dir_path('fa', 'fab') => 1,
805 dir_path('fa', 'fab', 'faba') => 1,
807 dir_path('fb', 'fba') => 1);
809 File::Find::find( {wanted => \&wanted_File_Dir, follow => 1,
810 follow_skip => 2, no_chdir => 1}, topdir('fa') );
812 # If we encountered the symlink first, then the entries corresponding to
813 # the real name remain, if the real name first then the symlink
814 my @names = sort keys %Expect_File;
815 Check( @names == 1 );
816 # Normalise both to the original name
817 s/_sl// foreach @names;
818 Check ($names[0] eq file_path_name('fa', 'faa', 'faa_ord'));
819 unlink file_path('fa', 'faa_sl');