Skip to content

Commit

Permalink
Merge ba06b6c into b6d6433
Browse files Browse the repository at this point in the history
  • Loading branch information
gugod committed Jul 21, 2022
2 parents b6d6433 + ba06b6c commit c5e0388
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 12 deletions.
6 changes: 6 additions & 0 deletions lib/App/Perlbrew/Path.pm
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ sub new {
bless { path => _joinpath (@path) }, $class;
}

sub exists {
my ($self) = @_;

-e $self->stringify;
}

sub basename {
my ($self, $suffix) = @_;

Expand Down
4 changes: 4 additions & 0 deletions lib/App/perlbrew.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1282,6 +1282,10 @@ sub do_install_release {
sub run_command_install {
my ($self, $dist, $opts) = @_;
unless ($self->root->exists) {
die("ERROR: perlbrew root " . $self->root . " does not exist. Run `perlbrew init` to prepare it first.\n");
}
unless ($dist) {
$self->run_command_help("install");
exit(-1);
Expand Down
6 changes: 0 additions & 6 deletions t/12.destdir.t
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ my $DESTDIR = tempdir( CLEANUP => 1 );

use Test::More;

## setup

App::Perlbrew::Path
->new($ENV{PERLBREW_ROOT})
->rmpath;

## mock

no warnings 'redefine';
Expand Down
6 changes: 0 additions & 6 deletions t/12.sitecustomize.t
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ $ENV{PERLBREW_ROOT} = $App::perlbrew::PERLBREW_ROOT;

use Test::More;

## setup

App::Perlbrew::Path
->new ($ENV{PERLBREW_ROOT})
->rmpath;

## mock

no warnings 'redefine';
Expand Down
24 changes: 24 additions & 0 deletions t/error-install-before-init.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env perl
use strict;
use warnings;

use Test::More;
use Test::Exception;
use File::Temp qw(tempdir);

use App::perlbrew;
use App::Perlbrew::Path;

my $fakehome = tempdir( CLEANUP => 1 );

$ENV{PERLBREW_ROOT} = $App::perlbrew::PERLBREW_ROOT = App::Perlbrew::Path->new($fakehome)->child("perl5")->stringify;

throws_ok(
sub {
my $app = App::perlbrew->new("install", "perl-5.36.0");
$app->run;
},
qr[ERROR: .*perlbrew init.*]
);

done_testing;

0 comments on commit c5e0388

Please sign in to comment.