This is an automated email from the git hooks/post-receive script. guillem pushed a commit to branch master in repository dpkg.
View the commit online: https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=1ddcd026b53f4471433e411ebaf9be18cf08365a commit 1ddcd026b53f4471433e411ebaf9be18cf08365a Author: Guillem Jover <guil...@debian.org> AuthorDate: Mon Sep 28 02:44:10 2020 +0200 test: Refactor root handling in Dpkg::Path unit tests Add support for alternative root directories to Dpkg::Path tests, to make possible to create hierarchies that might trip over conditions in other checks into their own root directory, and to simplify Dpkg_Path unit tests by using the new root and chroot options in %travtype. --- scripts/t/Dpkg_Path.t | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/scripts/t/Dpkg_Path.t b/scripts/t/Dpkg_Path.t index 7d753a274..bfd5b8db5 100644 --- a/scripts/t/Dpkg_Path.t +++ b/scripts/t/Dpkg_Path.t @@ -20,7 +20,7 @@ use Test::More tests => 33; use Test::Dpkg qw(:paths); use Cwd qw(realpath); -use File::Path qw(make_path);; +use File::Path qw(make_path rmtree); use File::Spec::Functions qw(abs2rel); use_ok('Dpkg::Path', 'canonpath', 'resolve_symlink', @@ -168,49 +168,45 @@ my %travtype = ( }, base_out_empty => { fail => 1, + root => $travbase_out, gen => sub { my $basedir = shift; - rename $basedir, "$travbase_out/base_out_empty-disabled"; - symlink abs2rel("$travbase_out/base_out_empty", $travbase), $basedir; - make_path("$travbase_out/base_out_empty"); + rmtree($basedir); + make_path($basedir); }, }, base_out_none => { fail => 1, - gen => sub { - my $basedir = shift; - rename $basedir, "$travbase_out/base_out_none"; - symlink abs2rel("$travbase_out/base_out_none", $travbase), $basedir; - }, + root => $travbase_out, + gen => sub { }, }, base_out_rel => { fail => 1, + root => $travbase_out, gen => sub { my $basedir = shift; - rename $basedir, "$travbase_out/base_out_rel"; - symlink abs2rel("$travbase_out/base_out_rel", $travbase), $basedir; symlink '../../..', "$basedir/rel"; }, }, base_out_abs => { fail => 1, + root => $travbase_out, gen => sub { my $basedir = shift; - rename $basedir, "$travbase_out/base_out_abs"; - symlink abs2rel("$travbase_out/base_out_abs", $travbase), $basedir; symlink '/etc', "$basedir/abs"; }, }, ); -make_path($travbase_out); - foreach my $travtype (sort keys %travtype) { my $trav = $travtype{$travtype}; + my $rootdir = $trav->{chroot} // $trav->{root} // $travbase; + my $hierdir = "$rootdir/$travtype"; my $travdir = "$travbase/$travtype"; - gen_hier_travbase($travdir); - $trav->{gen}->($travdir); + gen_hier_travbase($hierdir); + symlink abs2rel($hierdir, $travbase), $travdir if exists $trav->{root}; + $trav->{gen}->($hierdir); my $catch; eval { -- Dpkg.Org's dpkg