summaryrefslogtreecommitdiffstats
path: root/gnu/usr.bin/perl/cpan/File-Path/t/FilePathTest.pm
diff options
context:
space:
mode:
authorafresh1 <afresh1@openbsd.org>2017-08-14 13:49:42 +0000
committerafresh1 <afresh1@openbsd.org>2017-08-14 13:49:42 +0000
commit014083a11f84d6dcab30ffba851221532a9e3cce (patch)
treed11a58ceb41f5f6f3d2e6e5449a515c9a70f5010 /gnu/usr.bin/perl/cpan/File-Path/t/FilePathTest.pm
parentFix merge issues, remove excess files - match perl-5.24.2 dist (diff)
downloadwireguard-openbsd-014083a11f84d6dcab30ffba851221532a9e3cce.tar.xz
wireguard-openbsd-014083a11f84d6dcab30ffba851221532a9e3cce.zip
Apply local patches - perl-5.24.2
OK bluhm@, Reads ok sthen@
Diffstat (limited to 'gnu/usr.bin/perl/cpan/File-Path/t/FilePathTest.pm')
-rw-r--r--gnu/usr.bin/perl/cpan/File-Path/t/FilePathTest.pm44
1 files changed, 38 insertions, 6 deletions
diff --git a/gnu/usr.bin/perl/cpan/File-Path/t/FilePathTest.pm b/gnu/usr.bin/perl/cpan/File-Path/t/FilePathTest.pm
index f9e82893119..88b411d4bb3 100644
--- a/gnu/usr.bin/perl/cpan/File-Path/t/FilePathTest.pm
+++ b/gnu/usr.bin/perl/cpan/File-Path/t/FilePathTest.pm
@@ -3,18 +3,26 @@ use strict;
use warnings;
use base 'Exporter';
use SelectSaver;
+use Carp;
use Cwd;
use File::Spec::Functions;
+use File::Path ();
+use Test::More ();
-our @EXPORT = qw(_run_for_warning _run_for_verbose _basedir
- _cannot_delete_safe_mode
- _verbose_expected);
+our @EXPORT_OK = qw(
+ _run_for_warning
+ _run_for_verbose
+ _cannot_delete_safe_mode
+ _verbose_expected
+ create_3_level_subdirs
+ cleanup_3_level_subdirs
+);
sub _basedir {
- return catdir( curdir(),
- sprintf( 'test-%x-%x-%x', time, $$, rand(99999) ),
+ return catdir(
+ curdir(),
+ sprintf( 'test-%x-%x-%x', time, $$, rand(99999) ),
);
-
}
sub _run_for_warning {
@@ -109,4 +117,28 @@ END
}
}
+sub create_3_level_subdirs {
+ my @dirnames = @_;
+ my %seen = map {$_ => 1} @dirnames;
+ croak "Need 3 distinct names for subdirectories"
+ unless scalar(keys %seen) == 3;
+ my $tdir = File::Spec::Functions::tmpdir();
+ my $least_deep = catdir($tdir, $dirnames[0]);
+ my $next_deepest = catdir($least_deep, $dirnames[1]);
+ my $deepest = catdir($next_deepest, $dirnames[2]);
+ return ($least_deep, $next_deepest, $deepest);
+}
+
+sub cleanup_3_level_subdirs {
+ # runs 2 tests
+ my $least_deep = shift;
+ croak "Must provide path of least subdirectory"
+ unless (length($least_deep) and (-d $least_deep));
+ my $x;
+ my $opts = { error => \$x };
+ File::Path::remove_tree($least_deep, $opts);
+ Test::More::ok(! -d $least_deep, "directory '$least_deep' removed, as expected");
+ Test::More::is(scalar(@{$x}), 0, "no error messages using remove_tree() with \$opts");
+}
+
1;