use strict;
-use Test::More tests => 72;
+use Test::More tests => 71;
BEGIN {
use_ok('File::Path');
# IOW: File::Spec->catdir( qw(foo bar), File::Spec->updir ) eq 'foo'
# rather than foo/bar/..
skip "updir() canonicalises path on this platform", 2
- if $dir2 eq $tmp_base;
+ if $dir2 eq $tmp_base
+ or $^O eq 'cygwin';
@created = mkpath($dir2, {mask => 0700});
is(scalar(@created), 1, "make directory with trailing parent segment");
my $count = rmtree({error => \$error});
is( $count, 0, 'rmtree of nothing, count of zero' );
-is( scalar(@$error), 1, 'one diagnostic captureed' );
-eval { ($file, $message) = each %{$error->[0]} }; # too early to die, just in case
-is( $@, '', 'decoded diagnostic' );
-is( $file, '', 'general diagnostic' );
-is( $message, 'No root path(s) specified', 'expected diagnostic received' );
+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 $^O eq 'VMS';
@created = mkpath($tmp_base, $dir);
is(scalar(@created), 1, "created directory (new style 1)");
is($created[0], $dir, "created directory (new style 1) cross-check");
or diag("unexpectedly recreated @created");
$dir2 = catdir($tmp_base,'D');
+# mkpath returns unix syntax filespecs on VMS
+$dir2 = VMS::Filespec::unixify($dir2) if $^O eq 'VMS';
@created = mkpath($tmp_base, $dir, $dir2);
is(scalar(@created), 1, "created directory (new style 2)");
is($created[0], $dir2, "created directory (new style 2) cross-check");
is( $file, $dir, 'symlink 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: {
skip 'Test::Output not available', 10
unless $has_Test_Output;
+
SKIP: {
$dir = catdir('EXTRA', '3');
skip "extra scenarios not set up, see eg/setup-extra-tests", 2
$dir2 = catdir($base,'B');
stderr_like(
- \&rmtree,
+ sub { rmtree( undef, 1 ) },
qr/\ANo root path\(s\) specified\b/,
"rmtree of nothing carps sensibly"
);