1*f2a19305Safresh1#!./perl 2*f2a19305Safresh1 3*f2a19305Safresh1use strict; 4*f2a19305Safresh1use warnings; 5*f2a19305Safresh1 6*f2a19305Safresh1use File::Find qw( find finddepth ); 7*f2a19305Safresh1use File::Temp qw(); 8*f2a19305Safresh1use Test::More; 9*f2a19305Safresh1 10*f2a19305Safresh1my $warn_msg; 11*f2a19305Safresh1 12*f2a19305Safresh1BEGIN { 13*f2a19305Safresh1 $SIG{'__WARN__'} = sub { 14*f2a19305Safresh1 $warn_msg = $_[0]; 15*f2a19305Safresh1 warn "# $_[0]"; 16*f2a19305Safresh1 return; 17*f2a19305Safresh1 } 18*f2a19305Safresh1} 19*f2a19305Safresh1 20*f2a19305Safresh1sub test_find_correct_paths_with_follow { 21*f2a19305Safresh1 $warn_msg = ''; 22*f2a19305Safresh1 my $dir = File::Temp->newdir('file-find-XXXXXX', TMPDIR => 1, CLEANUP => 1); 23*f2a19305Safresh1 24*f2a19305Safresh1 find( 25*f2a19305Safresh1 { 26*f2a19305Safresh1 follow => 1, 27*f2a19305Safresh1 wanted => sub { return }, 28*f2a19305Safresh1 }, 29*f2a19305Safresh1 $dir, 30*f2a19305Safresh1 ); 31*f2a19305Safresh1 32*f2a19305Safresh1 unlike( 33*f2a19305Safresh1 $warn_msg, 34*f2a19305Safresh1 qr/Couldn't chdir/, 35*f2a19305Safresh1 'find: Derive absolute path correctly with follow => 1', 36*f2a19305Safresh1 ); 37*f2a19305Safresh1} 38*f2a19305Safresh1 39*f2a19305Safresh1sub test_finddepth_correct_paths_with_follow { 40*f2a19305Safresh1 $warn_msg = ''; 41*f2a19305Safresh1 my $dir = File::Temp->newdir('file-find-XXXXXX', TMPDIR => 1, CLEANUP => 1); 42*f2a19305Safresh1 43*f2a19305Safresh1 finddepth( 44*f2a19305Safresh1 { 45*f2a19305Safresh1 follow => 1, 46*f2a19305Safresh1 wanted => sub { return }, 47*f2a19305Safresh1 }, 48*f2a19305Safresh1 $dir, 49*f2a19305Safresh1 ); 50*f2a19305Safresh1 51*f2a19305Safresh1 unlike( 52*f2a19305Safresh1 $warn_msg, 53*f2a19305Safresh1 qr/Couldn't chdir/, 54*f2a19305Safresh1 'finddepth: Derive absolute path correctly with follow => 1', 55*f2a19305Safresh1 ); 56*f2a19305Safresh1} 57*f2a19305Safresh1sub run { 58*f2a19305Safresh1 test_find_correct_paths_with_follow; 59*f2a19305Safresh1 test_finddepth_correct_paths_with_follow; 60*f2a19305Safresh1 done_testing; 61*f2a19305Safresh1} 62*f2a19305Safresh1 63*f2a19305Safresh1run(); 64