From e68ca6672c39bc7e6318c8a4a8900708dd744b13 Mon Sep 17 00:00:00 2001 From: Randall Sindlinger Date: Mon, 13 Feb 2017 18:37:44 -0500 Subject: [PATCH] Skip packlist.t if List::MoreUtils is a vendor-pkg... Many distros (eg, RedHat and Debian) provide List::MoreUtils as a vendor-package and don't provide a packlist. This causes the packlist.t test to fail, interrupting many install suites. Added logic detects such an installation (ie, an auto/List/MoreUtils path exists under a perl @INC path, but it does not contain a .packlist) and skips the tests. This behaviour is analogous to a force install, which is what is manually required currently in this scenario. --- README.pod | 4 ++++ lib/Module/Build/CleanInstall.pm | 4 ++++ t/packlist.t | 20 ++++++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/README.pod b/README.pod index b37abfe..49b3f44 100644 --- a/README.pod +++ b/README.pod @@ -39,6 +39,10 @@ L Joel Berger, Ejoel.a.berger@gmail.comE +=head1 ADDITIONAL CONTRIBUTIONS + +Randall Sindlinger, Ersindlin@gmail.comE + =head1 COPYRIGHT AND LICENSE Copyright (C) 2012 by Joel Berger diff --git a/lib/Module/Build/CleanInstall.pm b/lib/Module/Build/CleanInstall.pm index 77bae06..e3d1ef2 100644 --- a/lib/Module/Build/CleanInstall.pm +++ b/lib/Module/Build/CleanInstall.pm @@ -86,6 +86,10 @@ L Joel Berger, Ejoel.a.berger@gmail.comE +=head1 ADDITIONAL CONTRIBUTIONS + +Randall Sindlinger, Ersindlin@gmail.comE + =head1 COPYRIGHT AND LICENSE Copyright (C) 2012 by Joel Berger diff --git a/t/packlist.t b/t/packlist.t index e64d7fb..8ba1927 100644 --- a/t/packlist.t +++ b/t/packlist.t @@ -2,6 +2,8 @@ use strict; use warnings; use Test::More; +use Pod::Perldoc; +use File::Spec::Functions qw/splitpath splitdir catpath catdir/; use Module::Build::CleanInstall; @@ -10,6 +12,24 @@ if (grep { m#List-MoreUtils.*?blib# } @INC) { plan skip_all => "Test irrelevant when not using an installed version of List::MoreUtils"; } +# In distros where List::MoreUtils is a vendor-package, there is no .packlist, +# so ExtUtils::Installed won't see it. Checking for this case. If more than one is +# installed, only looking at first result. +my ($L_MU_path) = Pod::Perldoc->new->grand_search_init(['List::MoreUtils']); +if ($L_MU_path) {note 'List::MoreUtils is available'}; + +# get the _expected_ .packlist directory in a portable way (using File::Spec functions) +my ($vol,$dir,$file) = splitpath ($L_MU_path, 1); #nofile flag +$dir =~ s/.pm$//; +my @dirs = (splitdir($dir)); +my @L_MU_only = splice(@dirs, -2, 2); +my $expected_L_MU_packlist_dir = catdir(@dirs, 'auto', @L_MU_only); + +if (-e catpath($vol, $expected_L_MU_packlist_dir) && + !-e catpath($vol, $expected_L_MU_packlist_dir, '.packlist')) { + plan skip_all => "Test irrelevant when using distro's vendor-package install of List::MoreUtils"; +} + my $packlist = Module::Build::CleanInstall->_get_packlist('List::MoreUtils'); ok ($packlist, 'Found packlist for List::MoreUtils');