From dd7cc8375fb18978ad7cc4c8518d5f276ec591f8 Mon Sep 17 00:00:00 2001 From: Kang-min Liu Date: Thu, 1 Jul 2021 07:34:57 +0900 Subject: [PATCH] rewrite the setup part of command-clone-modules.t Now that we have this `list_modules` method, the mocking is a bit more straightforwad. --- t/command-clone-modules.t | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/t/command-clone-modules.t b/t/command-clone-modules.t index 84c378a2..dacd2678 100644 --- a/t/command-clone-modules.t +++ b/t/command-clone-modules.t @@ -16,23 +16,15 @@ mock_perlbrew_install("perl-5.16.0"); no warnings; my ($__from, $__to, $__notest); +sub App::perlbrew::list_modules { + my ($self, $env) = @_; + $__from = $env || $self->current_env; + return ["Foo", "Bar"]; +} + 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) { + if (grep { $_ eq 'cpanm' } @args) { $__to = $args[1]; ($__notest) = grep { $_ eq '--notest' } @{$self->{original_argv}}; }