summaryrefslogtreecommitdiff
path: root/lib/App/DocKnot/Dist.pm
diff options
context:
space:
mode:
authorRuss Allbery <rra@cpan.org>2019-07-14 16:39:44 -0700
committerRuss Allbery <rra@cpan.org>2019-07-14 16:40:43 -0700
commit69c77df2a4f29fa15d3ed2fba78f5e3438c34169 (patch)
treec4f9d363424254166ef3ee4d2ceae83d1baf948b /lib/App/DocKnot/Dist.pm
parent65f6bda9a030cdb85549cd1a16e81ff215ac9ca4 (diff)
Allow the path to Perl to be configured for dist
Allow the path to Perl to be configured in App::DocKnot::Dist. This is used primarily for testing so that we can try building a distribution using Module::Build with the same Perl used to run the test suite. This is exposed by the module API but (intentially) not exposed on the docknot command line. Thanks, Slaven Rezic. (#129958)
Diffstat (limited to 'lib/App/DocKnot/Dist.pm')
-rw-r--r--lib/App/DocKnot/Dist.pm36
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/App/DocKnot/Dist.pm b/lib/App/DocKnot/Dist.pm
index 43be295..5cfb4b2 100644
--- a/lib/App/DocKnot/Dist.pm
+++ b/lib/App/DocKnot/Dist.pm
@@ -89,6 +89,26 @@ sub _move_tarballs {
return;
}
+# Given a command with arguments, replace a command of "perl" with the
+# configured path to Perl, if any. Assumes that the perl configuration
+# parameter is set in the object and should not be called if this is not true.
+#
+# $self - The App::DocKnot::Dist object
+# $command_ref - Reference to an array representing a command with arguments
+#
+# Returns: Reference to an array representing a command with arguments, with
+# the command replaced with the configured path to Perl if it was
+# "perl"
+sub _replace_perl_path {
+ my ($self, $command_ref) = @_;
+ if ($command_ref->[0] ne 'perl') {
+ return $command_ref;
+ }
+ my @command = $command_ref->@*;
+ $command[0] = $self->{perl};
+ return [@command];
+}
+
##############################################################################
# Public interface
##############################################################################
@@ -100,6 +120,7 @@ sub _move_tarballs {
# $args - Anonymous hash of arguments with the following keys:
# distdir - Path to the directory for distribution tarball
# metadata - Path to the directory containing package metadata
+# perl - Path to Perl to use (default: search the user's PATH)
#
# Returns: Newly created object
# Throws: Text exceptions on invalid metadata directory path
@@ -126,6 +147,7 @@ sub new {
my $self = {
config => $config->config(),
distdir => $distdir,
+ perl => $args_ref->{perl},
};
bless($self, $class);
return $self;
@@ -143,6 +165,14 @@ sub commands {
my $type = $self->{config}{build}{type};
my @commands = map { [@$_] } $COMMANDS{$type}->@*;
+ # Special-case: If a specific path to Perl was configured, use that path
+ # rather than searching for perl in the user's PATH. This is used
+ # primarily by the test suite, which wants to run a Module::Build Build.PL
+ # and thus has to use the same perl binary as the one running the tests.
+ if (defined($self->{perl})) {
+ @commands = map { $self->_replace_perl_path($_) } @commands;
+ }
+
# Special-case: Autoconf packages with C++ support should also attempt a
# build with a C++ compiler.
if ($type eq 'Autoconf' && $self->{config}{build}{cplusplus}) {
@@ -256,6 +286,12 @@ Required.
The path to the directory containing metadata for a package. Default:
F<docs/metadata> relative to the current directory.
+=item perl
+
+The path to the Perl executable to use for build steps that require it. Used
+primarily in the test suite. Default: The binary named C<perl> on the user's
+PATH.
+
=back
=back