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