xref: /openbsd/gnu/usr.bin/perl/cpan/File-Path/t/Path.t (revision 3d8817e4)
1# Path.t -- tests for module File::Path
2
3use strict;
4
5use Test::More tests => 129;
6use Config;
7
8BEGIN {
9    use_ok('Cwd');
10    use_ok('File::Path', qw(rmtree mkpath make_path remove_tree));
11    use_ok('File::Spec::Functions');
12}
13
14eval "use Test::Output";
15my $has_Test_Output = $@ ? 0 : 1;
16
17my $Is_VMS = $^O eq 'VMS';
18
19# first check for stupid permissions second for full, so we clean up
20# behind ourselves
21for my $perm (0111,0777) {
22    my $path = catdir(curdir(), "mhx", "bar");
23    mkpath($path);
24    chmod $perm, "mhx", $path;
25
26    my $oct = sprintf('0%o', $perm);
27    ok(-d "mhx", "mkdir parent dir $oct");
28    ok(-d $path, "mkdir child dir $oct");
29
30    rmtree("mhx");
31    ok(! -e "mhx", "mhx does not exist $oct");
32}
33
34# find a place to work
35my ($error, $list, $file, $message);
36my $tmp_base = catdir(
37    curdir(),
38    sprintf( 'test-%x-%x-%x', time, $$, rand(99999) ),
39);
40
41# invent some names
42my @dir = (
43    catdir($tmp_base, qw(a b)),
44    catdir($tmp_base, qw(a c)),
45    catdir($tmp_base, qw(z b)),
46    catdir($tmp_base, qw(z c)),
47);
48
49# create them
50my @created = mkpath([@dir]);
51
52is(scalar(@created), 7, "created list of directories");
53
54# pray for no race conditions blowing them out from under us
55@created = mkpath([$tmp_base]);
56is(scalar(@created), 0, "skipped making existing directory")
57    or diag("unexpectedly recreated @created");
58
59# create a file
60my $file_name = catfile( $tmp_base, 'a', 'delete.me' );
61my $file_count = 0;
62if (open OUT, "> $file_name") {
63    print OUT "this file may be deleted\n";
64    close OUT;
65    ++$file_count;
66}
67else {
68    diag( "Failed to create file $file_name: $!" );
69}
70
71SKIP: {
72    skip "cannot remove a file we failed to create", 1
73        unless $file_count == 1;
74    my $count = rmtree($file_name);
75    is($count, 1, "rmtree'ed a file");
76}
77
78@created = mkpath('');
79is(scalar(@created), 0, "Can't create a directory named ''");
80
81my $dir;
82my $dir2;
83
84sub gisle {
85    # background info: @_ = 1; !shift # gives '' not 0
86    # Message-Id: <3C820CE6-4400-4E91-AF43-A3D19B356E68@activestate.com>
87    # http://www.nntp.perl.org/group/perl.perl5.porters/2008/05/msg136625.html
88    mkpath(shift, !shift, 0755);
89}
90
91sub count {
92    opendir D, shift or return -1;
93    my $count = () = readdir D;
94    closedir D or return -1;
95    return $count;
96}
97
98{
99    mkdir 'solo', 0755;
100    chdir 'solo';
101    open my $f, '>', 'foo.dat';
102    close $f;
103    my $before = count(curdir());
104    cmp_ok($before, '>', 0, "baseline $before");
105
106    gisle('1st', 1);
107    is(count(curdir()), $before + 1, "first after $before");
108
109    $before = count(curdir());
110    gisle('2nd', 1);
111    is(count(curdir()), $before + 1, "second after $before");
112
113    chdir updir();
114    rmtree 'solo';
115}
116
117{
118    mkdir 'solo', 0755;
119    chdir 'solo';
120    open my $f, '>', 'foo.dat';
121    close $f;
122    my $before = count(curdir());
123    cmp_ok($before, '>', 0, "ARGV $before");
124    {
125        local @ARGV = (1);
126        mkpath('3rd', !shift, 0755);
127    }
128    is(count(curdir()), $before + 1, "third after $before");
129
130    $before = count(curdir());
131    {
132        local @ARGV = (1);
133        mkpath('4th', !shift, 0755);
134    }
135    is(count(curdir()), $before + 1, "fourth after $before");
136
137    chdir updir();
138    rmtree 'solo';
139}
140
141SKIP: {
142    # tests for rmtree() of ancestor directory
143    my $nr_tests = 6;
144    my $cwd = getcwd() or skip "failed to getcwd: $!", $nr_tests;
145    my $dir  = catdir($cwd, 'remove');
146    my $dir2 = catdir($cwd, 'remove', 'this', 'dir');
147
148    skip "failed to mkpath '$dir2': $!", $nr_tests
149        unless mkpath($dir2, {verbose => 0});
150    skip "failed to chdir dir '$dir2': $!", $nr_tests
151        unless chdir($dir2);
152
153    rmtree($dir, {error => \$error});
154    my $nr_err = @$error;
155    is($nr_err, 1, "ancestor error");
156
157    if ($nr_err) {
158        my ($file, $message) = each %{$error->[0]};
159        is($file, $dir, "ancestor named");
160        my $ortho_dir = $^O eq 'MSWin32' ? File::Path::_slash_lc($dir2) : $dir2;
161        $^O eq 'MSWin32' and $message
162            =~ s/\A(cannot remove path when cwd is )(.*)\Z/$1 . File::Path::_slash_lc($2)/e;
163        is($message, "cannot remove path when cwd is $ortho_dir", "ancestor reason");
164        ok(-d $dir2, "child not removed");
165        ok(-d $dir, "ancestor not removed");
166    }
167    else {
168        fail( "ancestor 1");
169        fail( "ancestor 2");
170        fail( "ancestor 3");
171        fail( "ancestor 4");
172    }
173    chdir $cwd;
174    rmtree($dir);
175    ok(!(-d $dir), "ancestor now removed");
176};
177
178my $count = rmtree({error => \$error});
179is( $count, 0, 'rmtree of nothing, count of zero' );
180is( scalar(@$error), 0, 'no diagnostic captured' );
181
182@created = mkpath($tmp_base, 0);
183is(scalar(@created), 0, "skipped making existing directories (old style 1)")
184    or diag("unexpectedly recreated @created");
185
186$dir = catdir($tmp_base,'C');
187# mkpath returns unix syntax filespecs on VMS
188$dir = VMS::Filespec::unixify($dir) if $Is_VMS;
189@created = make_path($tmp_base, $dir);
190is(scalar(@created), 1, "created directory (new style 1)");
191is($created[0], $dir, "created directory (new style 1) cross-check");
192
193@created = mkpath($tmp_base, 0, 0700);
194is(scalar(@created), 0, "skipped making existing directories (old style 2)")
195    or diag("unexpectedly recreated @created");
196
197$dir2 = catdir($tmp_base,'D');
198# mkpath returns unix syntax filespecs on VMS
199$dir2 = VMS::Filespec::unixify($dir2) if $Is_VMS;
200@created = make_path($tmp_base, $dir, $dir2);
201is(scalar(@created), 1, "created directory (new style 2)");
202is($created[0], $dir2, "created directory (new style 2) cross-check");
203
204$count = rmtree($dir, 0);
205is($count, 1, "removed directory unsafe mode");
206
207$count = rmtree($dir2, 0, 1);
208my $removed = $Is_VMS ? 0 : 1;
209is($count, $removed, "removed directory safe mode");
210
211# mkdir foo ./E/../Y
212# Y should exist
213# existence of E is neither here nor there
214$dir = catdir($tmp_base, 'E', updir(), 'Y');
215@created =mkpath($dir);
216cmp_ok(scalar(@created), '>=', 1, "made one or more dirs because of ..");
217cmp_ok(scalar(@created), '<=', 2, "made less than two dirs because of ..");
218ok( -d catdir($tmp_base, 'Y'), "directory after parent" );
219
220@created = make_path(catdir(curdir(), $tmp_base));
221is(scalar(@created), 0, "nothing created")
222    or diag(@created);
223
224$dir  = catdir($tmp_base, 'a');
225$dir2 = catdir($tmp_base, 'z');
226
227rmtree( $dir, $dir2,
228    {
229        error     => \$error,
230        result    => \$list,
231        keep_root => 1,
232    }
233);
234
235is(scalar(@$error), 0, "no errors unlinking a and z");
236is(scalar(@$list),  4, "list contains 4 elements")
237    or diag("@$list");
238
239ok(-d $dir,  "dir a still exists");
240ok(-d $dir2, "dir z still exists");
241
242$dir = catdir($tmp_base,'F');
243# mkpath returns unix syntax filespecs on VMS
244$dir = VMS::Filespec::unixify($dir) if $Is_VMS;
245
246@created = mkpath($dir, undef, 0770);
247is(scalar(@created), 1, "created directory (old style 2 verbose undef)");
248is($created[0], $dir, "created directory (old style 2 verbose undef) cross-check");
249is(rmtree($dir, undef, 0), 1, "removed directory 2 verbose undef");
250
251@created = mkpath($dir, undef);
252is(scalar(@created), 1, "created directory (old style 2a verbose undef)");
253is($created[0], $dir, "created directory (old style 2a verbose undef) cross-check");
254is(rmtree($dir, undef), 1, "removed directory 2a verbose undef");
255
256@created = mkpath($dir, 0, undef);
257is(scalar(@created), 1, "created directory (old style 3 mode undef)");
258is($created[0], $dir, "created directory (old style 3 mode undef) cross-check");
259is(rmtree($dir, 0, undef), 1, "removed directory 3 verbose undef");
260
261$dir = catdir($tmp_base,'G');
262$dir = VMS::Filespec::unixify($dir) if $Is_VMS;
263
264@created = mkpath($dir, undef, 0200);
265is(scalar(@created), 1, "created write-only dir");
266is($created[0], $dir, "created write-only directory cross-check");
267is(rmtree($dir), 1, "removed write-only dir");
268
269# borderline new-style heuristics
270if (chdir $tmp_base) {
271    pass("chdir to temp dir");
272}
273else {
274    fail("chdir to temp dir: $!");
275}
276
277$dir   = catdir('a', 'd1');
278$dir2  = catdir('a', 'd2');
279
280@created = make_path( $dir, 0, $dir2 );
281is(scalar @created, 3, 'new-style 3 dirs created');
282
283$count = remove_tree( $dir, 0, $dir2, );
284is($count, 3, 'new-style 3 dirs removed');
285
286@created = make_path( $dir, $dir2, 1 );
287is(scalar @created, 3, 'new-style 3 dirs created (redux)');
288
289$count = remove_tree( $dir, $dir2, 1 );
290is($count, 3, 'new-style 3 dirs removed (redux)');
291
292@created = make_path( $dir, $dir2 );
293is(scalar @created, 2, 'new-style 2 dirs created');
294
295$count = remove_tree( $dir, $dir2 );
296is($count, 2, 'new-style 2 dirs removed');
297
298if (chdir updir()) {
299    pass("chdir parent");
300}
301else {
302    fail("chdir parent: $!");
303}
304
305SKIP: {
306    skip "This is not a MSWin32 platform", 1
307        unless $^O eq 'MSWin32';
308
309    my $UNC_path_taint = $ENV{PERL_FILE_PATH_UNC_TESTDIR};
310    skip "PERL_FILE_PATH_UNC_TESTDIR environment variable not set", 1
311        unless defined($UNC_path_taint);
312
313    my ($UNC_path) = ($UNC_path_taint =~ m{^([/\\]{2}\w+[/\\]\w+[/\\]\w+)$});
314
315    skip "PERL_FILE_PATH_UNC_TESTDIR environment variable does not point to a directory", 1
316        unless -d $UNC_path;
317
318    my $removed = rmtree($UNC_path);
319    cmp_ok($removed, '>', 0, "removed $removed entries from $UNC_path");
320}
321
322SKIP: {
323    # test bug http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=487319
324    skip "Don't need Force_Writeable semantics on $^O", 4
325        if grep {$^O eq $_} qw(amigaos dos epoc MSWin32 MacOS os2);
326    skip "Symlinks not available", 4 unless $Config{d_symlink};
327    $dir  = 'bug487319';
328    $dir2 = 'bug487319-symlink';
329    @created = make_path($dir, {mask => 0700});
330    is(scalar @created, 1, 'bug 487319 setup');
331    symlink($dir, $dir2);
332    ok(-e $dir2, "debian bug 487319 setup symlink") or diag($dir2);
333
334    chmod 0500, $dir;
335    my $mask_initial = (stat $dir)[2];
336    remove_tree($dir2);
337
338    my $mask = (stat $dir)[2];
339    is( $mask, $mask_initial, 'mask of symlink target dir unchanged (debian bug 487319)');
340
341    # now try a file
342    my $file = catfile($dir, 'file');
343    open my $out, '>', $file;
344    close $out;
345
346    chmod 0500, $file;
347    $mask_initial = (stat $file)[2];
348
349    my $file2 = catfile($dir, 'symlink');
350    symlink($file, $file2);
351    remove_tree($file2);
352
353    $mask = (stat $file)[2];
354    is( $mask, $mask_initial, 'mask of symlink target file unchanged (debian bug 487319)');
355
356    remove_tree($dir);
357}
358
359# see what happens if a file exists where we want a directory
360SKIP: {
361    my $entry = catdir($tmp_base, "file");
362    skip "Cannot create $entry", 4 unless open OUT, "> $entry";
363    print OUT "test file, safe to delete\n", scalar(localtime), "\n";
364    close OUT;
365    ok(-e $entry, "file exists in place of directory");
366
367    mkpath( $entry, {error => \$error} );
368    is( scalar(@$error), 1, "caught error condition" );
369    ($file, $message) = each %{$error->[0]};
370    is( $entry, $file, "and the message is: $message");
371
372    eval {@created = mkpath($entry, 0, 0700)};
373    $error = $@;
374    chomp $error; # just to remove silly # in TAP output
375    cmp_ok( $error, 'ne', "", "no directory created (old-style) err=$error" )
376        or diag(@created);
377}
378
379my $extra =  catdir(curdir(), qw(EXTRA 1 a));
380
381SKIP: {
382    skip "extra scenarios not set up, see eg/setup-extra-tests", 14
383        unless -e $extra;
384    skip "Symlinks not available", 14 unless $Config{d_symlink};
385
386    my ($list, $err);
387    $dir = catdir( 'EXTRA', '1' );
388    rmtree( $dir, {result => \$list, error => \$err} );
389    is(scalar(@$list), 2, "extra dir $dir removed");
390    is(scalar(@$err), 1, "one error encountered");
391
392    $dir = catdir( 'EXTRA', '3', 'N' );
393    rmtree( $dir, {result => \$list, error => \$err} );
394    is( @$list, 1, q{remove a symlinked dir} );
395    is( @$err,  0, q{with no errors} );
396
397    $dir = catdir('EXTRA', '3', 'S');
398    rmtree($dir, {error => \$error});
399    is( scalar(@$error), 1, 'one error for an unreadable dir' );
400    eval { ($file, $message) = each %{$error->[0]}};
401    is( $file, $dir, 'unreadable dir reported in error' )
402        or diag($message);
403
404    $dir = catdir('EXTRA', '3', 'T');
405    rmtree($dir, {error => \$error});
406    is( scalar(@$error), 1, 'one error for an unreadable dir T' );
407    eval { ($file, $message) = each %{$error->[0]}};
408    is( $file, $dir, 'unreadable dir reported in error T' );
409
410    $dir = catdir( 'EXTRA', '4' );
411    rmtree($dir,  {result => \$list, error => \$err} );
412    is( scalar(@$list), 0, q{don't follow a symlinked dir} );
413    is( scalar(@$err),  2, q{two errors when removing a symlink in r/o dir} );
414    eval { ($file, $message) = each %{$err->[0]} };
415    is( $file, $dir, 'symlink reported in error' );
416
417    $dir  = catdir('EXTRA', '3', 'U');
418    $dir2 = catdir('EXTRA', '3', 'V');
419    rmtree($dir, $dir2, {verbose => 0, error => \$err, result => \$list});
420    is( scalar(@$list),  1, q{deleted 1 out of 2 directories} );
421    is( scalar(@$error), 1, q{left behind 1 out of 2 directories} );
422    eval { ($file, $message) = each %{$err->[0]} };
423    is( $file, $dir, 'first dir reported in error' );
424}
425
426{
427    $dir = catdir($tmp_base, 'ZZ');
428    @created = mkpath($dir);
429    is(scalar(@created), 1, "create a ZZ directory");
430
431    local @ARGV = ($dir);
432    rmtree( [grep -e $_, @ARGV], 0, 0 );
433    ok(!-e $dir, "blow it away via \@ARGV");
434}
435
436SKIP: {
437    my $skip_count = 8; # DRY
438    skip "getpwent() not implemented on $^O", $skip_count
439        unless $Config{d_getpwent};
440    skip "getgrent() not implemented on $^O", $skip_count
441        unless $Config{d_getgrent};
442    skip 'not running as root', $skip_count
443        unless $< == 0;
444    skip "darwin's nobody and nogroup are -1", $skip_count
445        if $^O eq 'darwin';
446
447    my $dir_stem = $dir = catdir($tmp_base, 'owned-by');
448
449    # find the highest uid ('nobody' or similar)
450    my $max_uid   = 0;
451    my $max_user = undef;
452    while (my @u = getpwent()) {
453        if ($max_uid < $u[2]) {
454            $max_uid  = $u[2];
455            $max_user = $u[0];
456        }
457    }
458    skip 'getpwent() appears to be insane', $skip_count
459        unless $max_uid > 0;
460
461    # find the highest gid ('nogroup' or similar)
462    my $max_gid   = 0;
463    my $max_group = undef;
464    while (my @g = getgrent()) {
465        if ($max_gid < $g[2]) {
466            $max_gid = $g[2];
467            $max_group = $g[0];
468        }
469    }
470    skip 'getgrent() appears to be insane', $skip_count
471        unless $max_gid > 0;
472
473    $dir = catdir($dir_stem, 'aaa');
474    @created = make_path($dir, {owner => $max_user});
475    is(scalar(@created), 2, "created a directory owned by $max_user...");
476    my $dir_uid = (stat $created[0])[4];
477    is($dir_uid, $max_uid, "... owned by $max_uid");
478
479    $dir = catdir($dir_stem, 'aab');
480    @created = make_path($dir, {group => $max_group});
481    is(scalar(@created), 1, "created a directory owned by group $max_group...");
482    my $dir_gid = (stat $created[0])[5];
483    is($dir_gid, $max_gid, "... owned by group $max_gid");
484
485    $dir = catdir($dir_stem, 'aac');
486    @created = make_path($dir, {user => $max_user, group => $max_group});
487    is(scalar(@created), 1, "created a directory owned by $max_user:$max_group...");
488    ($dir_uid, $dir_gid) = (stat $created[0])[4,5];
489    is($dir_uid, $max_uid, "... owned by $max_uid");
490    is($dir_gid, $max_gid, "... owned by group $max_gid");
491
492    SKIP: {
493        skip 'Test::Output not available', 1
494               unless $has_Test_Output;
495
496        # invent a user and group that don't exist
497        do { ++$max_user  } while (getpwnam($max_user));
498        do { ++$max_group } while (getgrnam($max_group));
499
500        $dir = catdir($dir_stem, 'aad');
501        stderr_like(
502            sub {make_path($dir, {user => $max_user, group => $max_group})},
503            qr{\Aunable to map $max_user to a uid, ownership not changed: .* at \S+ line \d+
504unable to map $max_group to a gid, group ownership not changed: .* at \S+ line \d+\b},
505            "created a directory not owned by $max_user:$max_group..."
506        );
507    }
508}
509
510SKIP: {
511    skip 'Test::Output not available', 14
512        unless $has_Test_Output;
513
514    SKIP: {
515        $dir = catdir('EXTRA', '3');
516        skip "extra scenarios not set up, see eg/setup-extra-tests", 3
517            unless -e $dir;
518
519        $dir = catdir('EXTRA', '3', 'U');
520        stderr_like(
521            sub {rmtree($dir, {verbose => 0})},
522            qr{\Acannot make child directory read-write-exec for [^:]+: .* at \S+ line \d+},
523            q(rmtree can't chdir into root dir)
524        );
525
526        $dir = catdir('EXTRA', '3');
527        stderr_like(
528            sub {rmtree($dir, {})},
529            qr{\Acannot make child directory read-write-exec for [^:]+: .* at (\S+) line (\d+)
530cannot make child directory read-write-exec for [^:]+: .* at \1 line \2
531cannot make child directory read-write-exec for [^:]+: .* at \1 line \2
532cannot remove directory for [^:]+: .* at \1 line \2},
533            'rmtree with file owned by root'
534        );
535
536        stderr_like(
537            sub {rmtree('EXTRA', {})},
538            qr{\Acannot remove directory for [^:]+: .* at (\S+) line (\d+)
539cannot remove directory for [^:]+: .* at \1 line \2
540cannot make child directory read-write-exec for [^:]+: .* at \1 line \2
541cannot make child directory read-write-exec for [^:]+: .* at \1 line \2
542cannot make child directory read-write-exec for [^:]+: .* at \1 line \2
543cannot remove directory for [^:]+: .* at \1 line \2
544cannot unlink file for [^:]+: .* at \1 line \2
545cannot restore permissions to \d+ for [^:]+: .* at \1 line \2
546cannot make child directory read-write-exec for [^:]+: .* at \1 line \2
547cannot remove directory for [^:]+: .* at \1 line \2},
548            'rmtree with insufficient privileges'
549        );
550    }
551
552    my $base = catdir($tmp_base,'output');
553    $dir  = catdir($base,'A');
554    $dir2 = catdir($base,'B');
555
556    stderr_like(
557        sub { rmtree( undef, 1 ) },
558        qr/\ANo root path\(s\) specified\b/,
559        "rmtree of nothing carps sensibly"
560    );
561
562    stderr_like(
563        sub { rmtree( '', 1 ) },
564        qr/\ANo root path\(s\) specified\b/,
565        "rmtree of empty dir carps sensibly"
566    );
567
568    stderr_is( sub { make_path() }, '', "make_path no args does not carp" );
569    stderr_is( sub { remove_tree() }, '', "remove_tree no args does not carp" );
570
571    stdout_is(
572        sub {@created = mkpath($dir, 1)},
573        "mkdir $base\nmkdir $dir\n",
574        'mkpath verbose (old style 1)'
575    );
576
577    stdout_is(
578        sub {@created = mkpath([$dir2], 1)},
579        "mkdir $dir2\n",
580        'mkpath verbose (old style 2)'
581    );
582
583    stdout_is(
584        sub {$count = rmtree([$dir, $dir2], 1, 1)},
585        "rmdir $dir\nrmdir $dir2\n",
586        'rmtree verbose (old style)'
587    );
588
589    stdout_is(
590        sub {@created = mkpath($dir, {verbose => 1, mask => 0750})},
591        "mkdir $dir\n",
592        'mkpath verbose (new style 1)'
593    );
594
595    stdout_is(
596        sub {@created = mkpath($dir2, 1, 0771)},
597        "mkdir $dir2\n",
598        'mkpath verbose (new style 2)'
599    );
600
601    SKIP: {
602        $file = catdir($dir2, "file");
603        skip "Cannot create $file", 2 unless open OUT, "> $file";
604        print OUT "test file, safe to delete\n", scalar(localtime), "\n";
605        close OUT;
606
607        ok(-e $file, "file created in directory");
608
609        stdout_is(
610            sub {$count = rmtree($dir, $dir2, {verbose => 1, safe => 1})},
611            "rmdir $dir\nunlink $file\nrmdir $dir2\n",
612            'rmtree safe verbose (new style)'
613        );
614    }
615}
616
617SKIP: {
618    skip "extra scenarios not set up, see eg/setup-extra-tests", 11
619        unless -d catdir(qw(EXTRA 1));
620
621    rmtree 'EXTRA', {safe => 0, error => \$error};
622    is( scalar(@$error), 10, 'seven deadly sins' ); # well there used to be 7
623
624    rmtree 'EXTRA', {safe => 1, error => \$error};
625    is( scalar(@$error), 9, 'safe is better' );
626    for (@$error) {
627        ($file, $message) = each %$_;
628        if ($file =~  /[123]\z/) {
629            is(index($message, 'cannot remove directory: '), 0, "failed to remove $file with rmdir")
630                or diag($message);
631        }
632        else {
633            like($message, qr(\Acannot (?:restore permissions to \d+|chdir to child|unlink file): ), "failed to remove $file with unlink")
634                or diag($message)
635        }
636    }
637}
638
639SKIP: {
640    my $nr_tests = 6;
641    my $cwd = getcwd() or skip "failed to getcwd: $!", $nr_tests;
642    rmtree($tmp_base, {result => \$list} );
643    is(ref($list), 'ARRAY', "received a final list of results");
644    ok( !(-d $tmp_base), "test base directory gone" );
645
646    my $p = getcwd();
647    my $x = "x$$";
648    my $xx = $x . "x";
649
650    # setup
651    ok(mkpath($xx), "make $xx");
652    ok(chdir($xx), "... and chdir $xx");
653    END {
654         ok(chdir($p), "... now chdir $p");
655         ok(rmtree($xx), "... and finally rmtree $xx");
656    }
657
658    # create and delete directory
659    my $px = catdir($p, $x);
660    ok(mkpath($px), 'create and delete directory 2.07');
661    ok(rmtree($px), '.. rmtree fails in File-Path-2.07');
662}
663