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