diff options
author | 2019-12-30 02:10:02 +0000 | |
---|---|---|
committer | 2019-12-30 02:10:02 +0000 | |
commit | f3efcd0145415b7d44d9da97e0ad5c21b186ac61 (patch) | |
tree | d6abf0994f508740c446dec46e925b7dc7572459 /gnu/usr.bin/perl/cpan/Module-Metadata/t/lib | |
parent | Populate logical disk port WWNs with their RAID volume's WWID (diff) | |
download | wireguard-openbsd-f3efcd0145415b7d44d9da97e0ad5c21b186ac61.tar.xz wireguard-openbsd-f3efcd0145415b7d44d9da97e0ad5c21b186ac61.zip |
Import perl-5.30.1
Timing is good deraadt@, OK sthen@
Diffstat (limited to 'gnu/usr.bin/perl/cpan/Module-Metadata/t/lib')
-rw-r--r-- | gnu/usr.bin/perl/cpan/Module-Metadata/t/lib/GeneratePackage.pm | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/gnu/usr.bin/perl/cpan/Module-Metadata/t/lib/GeneratePackage.pm b/gnu/usr.bin/perl/cpan/Module-Metadata/t/lib/GeneratePackage.pm index 07c92d37133..2a910f89bfe 100644 --- a/gnu/usr.bin/perl/cpan/Module-Metadata/t/lib/GeneratePackage.pm +++ b/gnu/usr.bin/perl/cpan/Module-Metadata/t/lib/GeneratePackage.pm @@ -3,7 +3,7 @@ use warnings; package GeneratePackage; # vim:ts=8:sw=2:et:sta:sts=2 -use base 'Exporter'; +our @ISA = ('Exporter'); our @EXPORT = qw(tmpdir generate_file); use Cwd; @@ -12,14 +12,27 @@ use File::Path; use File::Temp; use IO::File; +BEGIN { + my $cwd = File::Spec->rel2abs(Cwd::cwd); + sub _original_cwd { return $cwd } +} + +my @tmpdirs; sub tmpdir { - File::Temp::tempdir( + my (@args) = @_; + my $tmpdir = File::Temp::tempdir( 'MMD-XXXXXXXX', - CLEANUP => 1, - DIR => ($ENV{PERL_CORE} ? File::Spec->rel2abs(Cwd::cwd) : File::Spec->tmpdir), + CLEANUP => 0, + DIR => ($ENV{PERL_CORE} ? _original_cwd : File::Spec->tmpdir), + @args, ); + Test::More::note "using temp dir $tmpdir"; + push @tmpdirs, $tmpdir; + return $tmpdir; } +my $tmp; + sub generate_file { my ($dir, $rel_filename, $content) = @_; @@ -35,4 +48,14 @@ sub generate_file { return $abs_filename; } +END { + die "tests failed; leaving temp dir $tmp behind" + if $ENV{AUTHOR_TESTING} and not Test::Builder->new->is_passing; + chdir _original_cwd; + foreach my $tmp (@tmpdirs) { + Test::More::note "removing temp dir $tmp"; + File::Path::rmtree($tmp); + } +} + 1; |