From 71baa7558664e5ed502f925419224b5c0e387453 Mon Sep 17 00:00:00 2001 From: Kang-min Liu Date: Tue, 13 Apr 2021 09:49:41 +0900 Subject: [PATCH 1/5] Let clone-modules command passthru '--notest' to cpanm --- lib/App/perlbrew.pm | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/App/perlbrew.pm b/lib/App/perlbrew.pm index 747e2f6d..1342fd0c 100644 --- a/lib/App/perlbrew.pm +++ b/lib/App/perlbrew.pm @@ -2857,15 +2857,15 @@ sub run_command_clone_modules { # create a new application to 'exec' the 'cpanm' # with the specified module list - my $app = $class->new( + my @args = ( qw(--quiet exec --with), $dst_perl, - 'cpanm', - @modules_to_install - ); - - $app->run; + 'cpanm' + ); + push @args, '--notest' if $self->{notest}; + push @args, @modules_to_install; + $class->new(@args)->run; } sub format_info_output From f09773c6e935a5d5b7ec985f08950e525d6b49eb Mon Sep 17 00:00:00 2001 From: Kang-min Liu Date: Tue, 13 Apr 2021 09:53:28 +0900 Subject: [PATCH 2/5] document the --notest option --- script/perlbrew | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/script/perlbrew b/script/perlbrew index 70d4080a..084e5625 100755 --- a/script/perlbrew +++ b/script/perlbrew @@ -640,7 +640,11 @@ which are not necessarily the I module versions you had installed previous =head1 COMMAND: CLONE-MODULES Usage: - perlbrew clone-modules + perlbrew clone-modules [options] + +Options: + + --notest Skip all module tests This command re-installs all CPAN modules found from one installation to another. For example, this list all modules under '5.26.1' and re-install them under '5.27.7': From eda1359a31ed2af904a111596ae2650da6eebd41 Mon Sep 17 00:00:00 2001 From: Kang-min Liu Date: Tue, 13 Apr 2021 20:43:29 +0900 Subject: [PATCH 3/5] add a test for 'clone-modules' command --- t/command-clone-modules.t | 104 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 t/command-clone-modules.t diff --git a/t/command-clone-modules.t b/t/command-clone-modules.t new file mode 100644 index 00000000..84c378a2 --- /dev/null +++ b/t/command-clone-modules.t @@ -0,0 +1,104 @@ +#!/usr/bin/env perl +use strict; +use warnings; + +BEGIN { $ENV{SHELL} = "/bin/bash" } + +use FindBin; +use lib $FindBin::Bin; +use App::perlbrew; +require "test_helpers.pl"; + +use Test::Spec; + +mock_perlbrew_install("perl-5.14.1"); +mock_perlbrew_install("perl-5.16.0"); + +no warnings; +my ($__from, $__to, $__notest); +sub App::perlbrew::run_command_exec { + my ($self, @args) = @_; + + diag "ARGS: @args"; + + if (grep { $_ eq '-MExtUtils::Installed' } @args) { + $__from = $args[1]; + + my ($fn) = $args[5] =~ m{open .+">", "(.+?)";}; + if ($fn) { + open my $fh, ">", $fn; + print $fh "Foo\nBar\n"; + close($fh); + } else { + die "Failed to grok output path."; + } + } elsif (grep { $_ eq 'cpanm' } @args) { + $__to = $args[1]; + ($__notest) = grep { $_ eq '--notest' } @{$self->{original_argv}}; + } + return $self; +} +use warnings; + +describe "clone-modules command," => sub { + before each => sub { + delete $ENV{PERL_MB_OPT}; + delete $ENV{PERL_MM_OPT}; + delete $ENV{PERL_LOCAL_LIB_ROOT}; + delete $ENV{PERLBREW_LIB}; + delete $ENV{PERL5LIB}; + $__from = undef; + $__to = undef; + $__notest = undef; + }; + + describe "when invoked with two arguments, A and B", sub { + it "should display clone modules from A to B", sub { + my $app = App::perlbrew->new( + "clone-modules", "perl-5.14.1", "perl-5.16.0" + ); + $app->run; + is $__from, "perl-5.14.1"; + is $__to, "perl-5.16.0"; + ok(!defined($__notest)); + }; + }; + + describe "when invoked with two arguments, A and B, with `--notest`", sub { + it "should display clone modules from A to B", sub { + my $app = App::perlbrew->new( + "clone-modules", "--notest", "perl-5.14.1", "perl-5.16.0" + ); + $app->run; + is $__from, "perl-5.14.1"; + is $__to, "perl-5.16.0"; + ok(defined($__notest)); + }; + }; + + describe "when invoked with one argument X", sub { + it "should display clone modules from current-perl to X", sub { + my $app = App::perlbrew->new("clone-modules", "perl-5.14.1"); + $app->expects("current_env")->returns("perl-5.16.0")->at_least(1); + $app->run; + + is $__from, "perl-5.16.0"; + is $__to, "perl-5.14.1"; + ok(!defined($__notest)); + }; + }; + + describe "when invoked with one argument X, with `--notest`", sub { + it "should display clone modules from current-perl to X", sub { + my $app = App::perlbrew->new("clone-modules", "--notest", "perl-5.14.1"); + $app->expects("current_env")->returns("perl-5.16.0")->at_least(1); + $app->run; + + is $__from, "perl-5.16.0"; + is $__to, "perl-5.14.1"; + ok(defined($__notest)); + }; + }; +}; + +runtests unless caller; From c24e904500bd1a291b3786178463eaf50b790154 Mon Sep 17 00:00:00 2001 From: Kang-min Liu Date: Tue, 13 Apr 2021 20:48:15 +0900 Subject: [PATCH 4/5] changelog for this feature --- Changes | 1 + 1 file changed, 1 insertion(+) diff --git a/Changes b/Changes index 400a550c..f1cabed2 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,6 @@ - Fix a message mentioning fish config. GitHub PR #712 - Fetch cperl releases from https://github.com/perl11/cperl/releases instead + - Let `clone-modules` command accept `--notest` and skip running module tests 0.91 - Released at 2021-01-31T17:10:27+0900 From 5ab4c602f5070b976a52dfceee0b4f5375ed2932 Mon Sep 17 00:00:00 2001 From: Kang-min Liu Date: Wed, 14 Apr 2021 20:43:56 +0900 Subject: [PATCH 5/5] tabs here. --- Changes | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Changes b/Changes index f1cabed2..04ac75d7 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,6 @@ - Fix a message mentioning fish config. GitHub PR #712 - Fetch cperl releases from https://github.com/perl11/cperl/releases instead - - Let `clone-modules` command accept `--notest` and skip running module tests + - Let `clone-modules` command accept `--notest` and skip running module tests 0.91 - Released at 2021-01-31T17:10:27+0900