App-perlbrew

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

	- Released at 2023-05-12T22:33:42+0900
	- Thanks to our contributors: Elvin Aslanov, Graham Knop, Shoichi Kaji, Tomasz Konojacki, brian greenfield
	- The documentation of `clone-module` and `list-modules` are improved.
	- No longer depends on Pod::Parser. Github PR #760
	- Bugfix for csh users: Github PR #770

0.96
	- Released at 2022-07-31T15:42:39+0900
	- Thanks to our contributors: Rolf Stöckli
	- `install-cpm` is now properly documented. Thanks to Tekki.
	- Let `install` hint for `init` when PERLBREW_ROOT does not exist. .RT #57669.
	- Reveal the actual error code of curl/wget etc. Github issue #748.

0.95
	- Released at 2022-05-15T22:59:11+0800
	- Thanks to our contributors: Leon Timmermans
	- Now we use metacpan api for fetching perl versions and for downloading. Github PR #743
	- `--verbose` flag now also enable verbosity of underlying curl/wget commands. Github PR #740.
	- Avoid perl test errors when NO_COLOR is set. Github PR #738

0.94

README  view on Meta::CPAN

    run with system perl. The minimum required version of system perl is
    5.8.0, which should be good enough for most of the OSes these days.

    A fat-packed version of patchperl is also installed to
    ~/perl5/perlbrew/bin, which is required to build old perls.

    The directory ~/perl5/perlbrew will contain all install perl
    executables, libraries, documentations, lib, site_libs. In the
    documentation, that directory is referred as perlbrew root. If you need
    to set it to somewhere else because, say, your HOME has limited quota,
    you can do that by setting PERLBREW_ROOT environment variable before
    running the installer:

        export PERLBREW_ROOT=/opt/perl5
        curl -L https://install.perlbrew.pl | bash

    As a result, different users on the same machine can all share the same
    perlbrew root directory (although only original user that made the
    installation would have the permission to perform perl installations.)

    You may also install perlbrew from CPAN:

        cpan App::perlbrew

lib/App/perlbrew.pm  view on Meta::CPAN

# ref: https://github.com/gugod/App-perlbrew/pull/404
$ENV{SHELL} ||= App::Perlbrew::Path->new( "/proc", getppid, "exe" )->readlink if -d "/proc";

local $SIG{__DIE__} = sub {
    my $message = shift;
    warn $message;
    exit(1);
};

our $CONFIG;
our $PERLBREW_ROOT;
our $PERLBREW_HOME;

my @flavors = (
    {
        d_option => 'usethreads',
        implies  => 'multi',
        common   => 1,
        opt      => 'thread|threads'
    },    # threads is for backward compatibility

script/perlbrew  view on Meta::CPAN

    list           List perl installations
    use            Use the specified perl in current shell
    off            Turn off perlbrew in current shell
    switch         Permanently use the specified perl as default
    switch-off     Permanently turn off perlbrew (revert to system perl)
    exec           Execute programs with specified perl environments.

    list-modules   List installed CPAN modules for the current Perl version in use
    clone-modules  Re-installs all CPAN modules from one installation to another

    self-install       Install perlbrew itself under PERLBREW_ROOT/bin
    self-upgrade       Upgrade perlbrew itself.

    install-patchperl  Install patchperl
    install-cpanm      Install cpanm, a friendly companion.
    install-cpm        Install cpm, a faster but still friendly companion.
    install-multiple   Install multiple versions and flavors of perl

    download       Download the specified perl distribution tarball.
    clean          Purge tarballs and build directories
    version        Display version

t/06.installed_perls.t  view on Meta::CPAN

use strict;
use warnings;

use Test::More;
use App::perlbrew;

my $app = App::perlbrew->new();
my @perls = $app->installed_perls;

unless(@perls) {
    plan skip_all => "No perl installation under PERLBREW_ROOT";
    exit;
}

for my $perl (@perls) {
    is ref($perl), 'HASH';
    ok defined $perl->{name},       "Name: $perl->{name}";
    ok defined $perl->{version},    "Version: $perl->{version}";
    ok defined $perl->{is_current}, "Current?: " . ($perl->{is_current} ? "true" : "false");
}

t/08.error_install.t  view on Meta::CPAN

#!/usr/bin/env perl
use strict;
use warnings;

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

use App::perlbrew;

$App::perlbrew::PERLBREW_ROOT = tempdir( CLEANUP => 1 );
$App::perlbrew::PERLBREW_HOME = tempdir( CLEANUP => 1 );
$ENV{PERLBREW_ROOT} = $App::perlbrew::PERLBREW_ROOT;

App::Perlbrew::Path->new ($ENV{PERLBREW_ROOT})->child ("perls")->mkpath;
App::Perlbrew::Path->new ($ENV{PERLBREW_ROOT})->child ("build")->mkpath;
App::Perlbrew::Path->new ($ENV{PERLBREW_ROOT})->child ("dists")->mkpath;

no warnings 'redefine';
sub App::perlbrew::http_download { return "ERROR" }

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

t/11.root_from_arg.t  view on Meta::CPAN

use warnings;
use FindBin;
use lib $FindBin::Bin;
use App::perlbrew;
require "test_helpers.pl";

use File::Temp qw(tempdir);
use Test::Deep qw[];
use Test::Spec;

sub looks_like_perlbrew_root;

local $App::perlbrew::PERLBREW_ROOT = '/perlbrew/root';
local $ENV{PERLBREW_ROOT} = '/env/root';
local $ENV{HOME} = '/home';

describe "App::perlbrew#root method" => sub {
    it "should return \$App::perlbrew::PERLBREW_ROOT if provided" => sub {
        my $app = App::perlbrew->new;

        looks_like_perlbrew_root $app->root, '/perlbrew/root';
    };

    it "should default to \$ENV{PERLBREW_ROOT} if provided" => sub {
        local $App::perlbrew::PERLBREW_ROOT;

        my $app = App::perlbrew->new;

        looks_like_perlbrew_root $app->root, '/env/root';
    };

    it "should default to \$ENV{HOME} subpath" => sub {
        local $App::perlbrew::PERLBREW_ROOT;
        local $ENV{PERLBREW_ROOT};

        my $app = App::perlbrew->new;

        looks_like_perlbrew_root $app->root, '/home/perl5/perlbrew';
    };

    it "should return the instance property of 'root' if set" => sub {
        my $app = App::perlbrew->new;
        $app->root("/fnord");

        looks_like_perlbrew_root $app->root, "/fnord";
    };
};

describe "App::perlbrew->new" => sub {
    it "should accept --root args and treat it as the value of PERLBREW_ROOT for the instance" => sub {
        my $temp_perlbrew_root = tempdir( CLEANUP => 1);

        my $app = App::perlbrew->new("--root" => $temp_perlbrew_root);

        looks_like_perlbrew_root $app->root, $temp_perlbrew_root;
    };
};

runtests unless caller;

sub looks_like_perlbrew_root {
    my ($got, $expected) = @_;

    my ($ok, $stack);

    ($ok, $stack) = Test::Deep::cmp_details "$got", "$expected";
    unless ($ok) {
        fail;
        diag "Return value comparison failed";
        diag Test::Deep::deep_diag $stack;
        return;
    }

    ($ok, $stack) = Test::Deep::cmp_details "$got", "$App::perlbrew::PERLBREW_ROOT";
    unless ($ok) {
        fail;
        diag "Global \$PERLBREW_ROOT comparison failed";
        diag Test::Deep::deep_diag $stack;
        return;
    }

    return Test::Deep::cmp_deeply $got, Isa ('App::Perlbrew::Path::Root');
}

t/12.destdir.t  view on Meta::CPAN

#!perl
use strict;
use Capture::Tiny qw/capture/;
use IO::All;
use App::perlbrew;
use File::Temp qw( tempdir );

$App::perlbrew::PERLBREW_ROOT = tempdir( CLEANUP => 1 );
$App::perlbrew::PERLBREW_HOME = tempdir( CLEANUP => 1 );
$ENV{PERLBREW_ROOT} = $App::perlbrew::PERLBREW_ROOT;
my $DESTDIR = tempdir( CLEANUP => 1 );

use Test::More;

## mock

no warnings 'redefine';

sub App::perlbrew::do_system {
    my ($self, $cmd) = @_;
    if ($cmd =~ /sitelib/) {
        print "sitelib='$ENV{PERLBREW_ROOT}/perls/perl-5.14.2/lib/site_perl/5.14.2';\n";
        print "installprefix='$ENV{PERLBREW_ROOT}/perls/perl-5.14.2';\n";
        print "installstyle='lib';\n";
        return 1;
    }
    elsif ($cmd =~ /Configure/) {
        # pretend to succeed
        return 1;
    }
    else {
        # fail to run
        $? = 1<<8;

t/12.sitecustomize.t  view on Meta::CPAN

#!perl
use strict;
use Capture::Tiny qw/capture/;
use IO::All;
use App::perlbrew;
use File::Temp qw( tempdir );

$App::perlbrew::PERLBREW_ROOT = tempdir( CLEANUP => 1 );
$App::perlbrew::PERLBREW_HOME = tempdir( CLEANUP => 1 );
$ENV{PERLBREW_ROOT} = $App::perlbrew::PERLBREW_ROOT;

use Test::More;

## mock

no warnings 'redefine';

sub App::perlbrew::do_system {
    my ($self, $cmd) = @_;
    if ($cmd =~ /sitelib/) {
        print "sitelib='$ENV{PERLBREW_ROOT}/perls/perl-5.14.2/lib/site_perl/5.14.2';";
        return 1;
    }
    elsif ($cmd =~ /Configure/) {
        # pretend to succeed
        return 1;
    }
    else {
        # fail to run
        $? = 1<<8;
        $! = "Could not run '$cmd'";

t/14.perl_version_parsing.t  view on Meta::CPAN

#!perl
use strict;

use App::perlbrew;
use App::Perlbrew::Util qw(perl_version_to_integer);

use File::Temp qw( tempdir );
$App::perlbrew::PERLBREW_ROOT = tempdir( CLEANUP => 1 );
$App::perlbrew::PERLBREW_HOME = tempdir( CLEANUP => 1 );
$ENV{PERLBREW_ROOT} = $App::perlbrew::PERLBREW_ROOT;

#
# This test checks if the sorting order of parsed version is the same as
# the order of @versions array defined below.
#

my @versions = qw(
                     5.003_07
                     5.004
                     5.004_01

t/15.no-reuse-build-dir.t  view on Meta::CPAN

use strict;
use warnings;
use Test::More tests => 6;
use File::Basename qw(basename);

use FindBin;
use lib $FindBin::Bin;
use App::perlbrew;
require 'test_helpers.pl';

note "PERLBREW_ROOT set to $ENV{PERLBREW_ROOT}";

my $pb = new_ok('App::perlbrew');

my $test_dir = App::Perlbrew::Path->new ($pb->root, qw/build test/);
my $test_file = App::Perlbrew::Path->new ( $test_dir, 3 );
$test_dir->mkpath;
open my $out, '>', $test_file
    or die "Couldn't create $test_file: $!";

ok -e $test_file, 'Test file 3 created';

t/16.release-detail.t  view on Meta::CPAN

#!perl
use strict;
use App::perlbrew;
use File::Temp qw( tempdir );
$App::perlbrew::PERLBREW_ROOT = tempdir( CLEANUP => 1 );
$App::perlbrew::PERLBREW_HOME = tempdir( CLEANUP => 1 );
$ENV{PERLBREW_ROOT} = $App::perlbrew::PERLBREW_ROOT;

use Test::More;

subtest 'parse "perl-5.18.2"' => sub {
    my $app = App::perlbrew->new();

    my $rd = $app->release_detail("perl-5.18.2");

    ok defined( $rd->{type} );
    ok defined( $rd->{version} );

t/18.release-detail-perl-local.t  view on Meta::CPAN

#!perl
use strict;
use App::perlbrew;
use File::Temp qw( tempdir );
$App::perlbrew::PERLBREW_ROOT = tempdir( CLEANUP => 1 );
$App::perlbrew::PERLBREW_HOME = tempdir( CLEANUP => 1 );
$ENV{PERLBREW_ROOT} = $App::perlbrew::PERLBREW_ROOT;

use Test::More;

my $app = App::perlbrew->new();
$app->cpan_mirror("https://www.cpan.org");

my $rd = { type => "perl", "version" => "5.18.2" };
my ($error, undef) = $app->release_detail_perl_local("perl-5.18.2", $rd);

ok !$error;

t/18.release-detail-perl-remote.t  view on Meta::CPAN

#!perl
use strict;
use App::perlbrew;
use File::Temp qw( tempdir );
$App::perlbrew::PERLBREW_ROOT = tempdir( CLEANUP => 1 );
$App::perlbrew::PERLBREW_HOME = tempdir( CLEANUP => 1 );
$ENV{PERLBREW_ROOT} = $App::perlbrew::PERLBREW_ROOT;

use Test::More;

unless ($ENV{TEST_LIVE}) {
    plan skip_all => 'These tests send HTTP requests. Set env TEST_LIVE=1 to really run them.';
}

my $app = App::perlbrew->new();
$app->cpan_mirror("https://www.cpan.org");

t/19.find_similar_commands.t  view on Meta::CPAN

#!perl
use strict;
use warnings;
use Test::More;

use App::perlbrew;
use File::Temp qw( tempdir );

$ENV{PERLBREW_ROOT} = $App::perlbrew::PERLBREW_ROOT = tempdir( CLEANUP => 1 );
$App::perlbrew::PERLBREW_HOME = tempdir( CLEANUP => 1 );

my $app = App::perlbrew->new;
diag join ", ", sort $app->commands;

subtest "exact result", sub {
    my @commands = $app->find_similar_commands( "install" );
    is 0+@commands, 1;
    is $commands[0], "install";
};

t/bashrc_content.t  view on Meta::CPAN

use strict;
use warnings;

use App::perlbrew;

use Test::Spec;

local $App::perlbrew::PERLBREW_ROOT;
local %ENV;

sub describe_bashrc_content;

describe "App::perlbrew->BASHRC_CONTENT()" => sub {
    context "should not export custom PERLBREW_ROOT" => sub {
        describe_bashrc_content "with default settings" => (
        );

        describe_bashrc_content "when set only via global variable" => (
            PERLBREW_ROOT => 'perlbrew/root',
        );
    };

    context "should export custom PERLBREW_ROOT" => sub {
        describe_bashrc_content "when env variable PERLBREW_ROOT is set" => (
            ENV_PERLBREW_ROOT => 'env/root',
            should_match => 'env/root',
        );

        describe_bashrc_content "when provided via argument" => (
            args => [qw[ --root arg/root ]],
            should_match => "arg/root",
        );

        describe_bashrc_content "when provided via argument (favor over env)" => (
            args => [qw[ --root arg/root ]],
            ENV_PERLBREW_ROOT => 'env/root',
            should_match => "arg/root",
        );
    };
};

runtests unless caller;

sub describe_bashrc_content {
    my ($title, %params) = @_;

    it $title => sub {
        local %ENV = (
            HOME => 'default/home',
            (PERLBREW_ROOT => $params{ENV_PERLBREW_ROOT}) x!! exists $params{ENV_PERLBREW_ROOT},
        );
        local $App::perlbrew::PERLBREW_ROOT = $params{PERLBREW_ROOT} || $ENV{PERLBREW_ROOT};

        my $app = App::perlbrew->new (@{ $params{args} || [] });

        return ok $app->BASHRC_CONTENT =~ m{^export PERLBREW_ROOT=\Q$params{should_match}\E}m
        if $params{should_match};

        return ok $app->BASHRC_CONTENT !~ m{^export PERLBREW_ROOT=}m;
    };
}

t/builddir.t  view on Meta::CPAN

use FindBin;
use lib $FindBin::Bin;
use App::perlbrew;
require "test_helpers.pl";

use Test::Spec;

sub looks_like_perlbrew_builddir;

describe "App::perlbrew#builddir method" => sub {
    it "should return path in \$App::perlbrew::PERLBREW_ROOT normally" => sub {
        local $App::perlbrew::PERLBREW_ROOT = '/perlbrew/root';
        my $app = App::perlbrew->new;

        looks_like_perlbrew_builddir $app->builddir, '/perlbrew/root/build';
    };

    it "should return path relative to root" => sub {
        my $app = App::perlbrew->new;
        $app->root("/fnord");

        looks_like_perlbrew_builddir $app->builddir, "/fnord/build";
    };
};

describe "App::perlbrew->new" => sub {
    it "should accept --builddir args" => sub {
        local $App::perlbrew::PERLBREW_ROOT = '/perlbrew/root';
        my $app = App::perlbrew->new("--builddir" => "/perlbrew/buildroot");

        looks_like_perlbrew_builddir $app->builddir, "/perlbrew/buildroot";
    };
};

runtests unless caller;

sub looks_like_perlbrew_builddir {
    my ($got, $expected) = @_;

t/command-available.t  view on Meta::CPAN

#!/usr/bin/env perl
use strict;
use warnings;
use Test::Spec;
use File::Temp qw( tempdir );
use Test::Output;

use App::perlbrew;
$App::perlbrew::PERLBREW_ROOT = my $perlbrew_root = tempdir( CLEANUP => 1 );
$App::perlbrew::PERLBREW_HOME = my $perlbrew_home = tempdir( CLEANUP => 1 );

my %available_perl_dists = (
    'perl-5.27.4'  => 'http://www.cpan.org/src/5.0/perl-5.27.4.tar.gz',
    'perl-5.26.1'  => 'http://www.cpan.org/src/5.0/perl-5.26.1.tar.gz',
    'perl-5.24.3'  => 'http://www.cpan.org/src/5.0/perl-5.24.3.tar.gz',
    'perl-5.22.4'  => 'http://www.cpan.org/src/5.0/perl-5.22.4.tar.gz',
    'perl-5.20.3'  => 'http://www.cpan.org/src/5.0/perl-5.20.3.tar.gz',
    'perl-5.18.4'  => 'http://www.cpan.org/src/5.0/perl-5.18.4.tar.gz',
    'perl-5.16.3'  => 'http://www.cpan.org/src/5.0/perl-5.16.3.tar.gz',

t/command-display-rc.t  view on Meta::CPAN

#!/usr/bin/env perl
use strict;
use warnings;
use Test::Spec;
use File::Temp qw( tempdir );

$ENV{PERLBREW_ROOT} = my $perlbrew_root = tempdir( CLEANUP => 1 );
$ENV{PERLBREW_HOME} = my $perlbrew_home = tempdir( CLEANUP => 1 );

use App::perlbrew;

describe "App::perlbrew" => sub {
    my $app;

    before each => sub {
        $app = App::perlbrew->new;
    };

t/command-env.t  view on Meta::CPAN


    describe "when invoked with a perl installation name,", sub {
        it "displays environment variables that should be set to use the given perl." => sub {
            my $app = App::perlbrew->new("env", "perl-5.14.1");

            stdout_is {
                $app->run;
            } <<"OUT";
unset PERL5LIB
unset PERLBREW_LIB
export PERLBREW_MANPATH="$App::perlbrew::PERLBREW_ROOT/perls/perl-5.14.1/man"
export PERLBREW_PATH="$App::perlbrew::PERLBREW_ROOT/bin:$App::perlbrew::PERLBREW_ROOT/perls/perl-5.14.1/bin"
export PERLBREW_PERL="perl-5.14.1"
export PERLBREW_ROOT="$App::perlbrew::PERLBREW_ROOT"
export PERLBREW_VERSION="$App::perlbrew::VERSION"
unset PERL_LOCAL_LIB_ROOT
OUT
        };
    };

    describe "when invoked with a perl installation name with lib name,", sub {
        it "displays local::lib-related environment variables that should be set to use the given perl." => sub {
            note 'perlbrew env perl-5.14.1@nobita';

            my $PERL5LIB_maybe = $ENV{PERL5LIB} ? ":\$PERL5LIB" : "";
            my $app = App::perlbrew->new("env", 'perl-5.14.1@nobita');

            my $lib_dir = "$App::perlbrew::PERLBREW_HOME/libs/perl-5.14.1\@nobita";
            stdout_is {
                $app->run;
            } <<"OUT";
export PERL5LIB="$lib_dir/lib/perl5${PERL5LIB_maybe}"
export PERLBREW_LIB="nobita"
export PERLBREW_MANPATH="$lib_dir/man:$App::perlbrew::PERLBREW_ROOT/perls/perl-5.14.1/man"
export PERLBREW_PATH="$lib_dir/bin:$App::perlbrew::PERLBREW_ROOT/bin:$App::perlbrew::PERLBREW_ROOT/perls/perl-5.14.1/bin"
export PERLBREW_PERL="perl-5.14.1"
export PERLBREW_ROOT="$App::perlbrew::PERLBREW_ROOT"
export PERLBREW_VERSION="$App::perlbrew::VERSION"
export PERL_LOCAL_LIB_ROOT="$lib_dir"
export PERL_MB_OPT="--install_base "$lib_dir""
export PERL_MM_OPT="INSTALL_BASE=$lib_dir"
OUT
        }
    };

    describe "when invoked with a perl installation name with lib name and PERLBREW_LIB_PREFIX set,", sub {
        it "displays PERL5LIB with PERLBREW_LIB_PREFIX value first." => sub {

t/command-install-cpanm.t  view on Meta::CPAN

#!/usr/bin/env perl
use strict;
use warnings;
use Test::Spec;
use File::Temp qw( tempdir );

use App::perlbrew;
$App::perlbrew::PERLBREW_ROOT = my $perlbrew_root = tempdir( CLEANUP => 1 );
$App::perlbrew::PERLBREW_HOME = my $perlbrew_home = tempdir( CLEANUP => 1 );

{
    no warnings 'redefine';
    sub App::perlbrew::http_get {
        my ($url) = @_;
        like $url, qr/cpanm$/, "GET cpanm url: $url";
        return "#!/usr/bin/env perl\n# The content of cpanm";
    }
}

describe "App::perlbrew->install_cpanm" => sub {
    it "should produce 'cpanm' in the bin dir" => sub {
        my $app = App::perlbrew->new("install-cpanm", "-q");
        $app->run();

        my $cpanm = App::Perlbrew::Path->new ($perlbrew_root, "bin", "cpanm");
        ok -f $cpanm, "cpanm is produced. $cpanm";
        ok -x $cpanm, "cpanm should be an executable.";
    };
};

runtests unless caller;

t/command-install-cpm.t  view on Meta::CPAN

#!/usr/bin/env perl
use strict;
use warnings;
use Test::Spec;
use File::Temp qw( tempdir );

use App::perlbrew;
$App::perlbrew::PERLBREW_ROOT = my $perlbrew_root = tempdir( CLEANUP => 1 );
$App::perlbrew::PERLBREW_HOME = my $perlbrew_home = tempdir( CLEANUP => 1 );

{
    no warnings 'redefine';
    sub App::perlbrew::http_get {
        my ($url) = @_;
        like $url, qr/cpm$/, "GET cpm url: $url";
        return "#!/usr/bin/env perl\n# The content of cpm";
    }
}

describe "App::perlbrew->install_cpm" => sub {
    it "should produce 'cpm' in the bin dir" => sub {
        my $app = App::perlbrew->new("install-cpm", "-q");
        $app->run();

        my $cpm = App::Perlbrew::Path->new($perlbrew_root, "bin", "cpm");
        ok -f $cpm, "cpm is produced. $cpm";
        ok -x $cpm, "cpm should be an executable.";
    };
};

runtests unless caller;

t/command-install-patchperl.t  view on Meta::CPAN

#!/usr/bin/env perl
use strict;
use warnings;
use Test::Spec;
use File::Temp qw( tempdir );

use App::perlbrew;
$App::perlbrew::PERLBREW_ROOT = my $perlbrew_root = tempdir( CLEANUP => 1 );
$App::perlbrew::PERLBREW_HOME = my $perlbrew_home = tempdir( CLEANUP => 1 );

{
    no warnings 'redefine';
    sub App::perlbrew::http_get {
        my ($url) = @_;
        like $url, qr/patchperl$/, "GET patchperl url: $url";
        return "#!/usr/bin/env perl\n# The content of patchperl";
    }
}

describe "App::perlbrew->install_patchperl" => sub {
    it "should produce 'patchperl' in the bin dir" => sub {
        my $app = App::perlbrew->new("install-patchperl", "-q");
        $app->run();

        my $patchperl = App::Perlbrew::Path->new ($perlbrew_root, "bin", "patchperl");
        ok -f $patchperl, "patchperl is produced. $patchperl";
        ok -x $patchperl, "patchperl should be an executable.";
    };
};

runtests unless caller;

t/command-list.t  view on Meta::CPAN

#!/usr/bin/env perl
use strict;
use warnings;

BEGIN {
    delete $ENV{PERLBREW_HOME};
    delete $ENV{PERLBREW_ROOT};
    delete $ENV{PERLBREW_LIB};
}

use FindBin;
use lib $FindBin::Bin;

use App::perlbrew;
require "test_helpers.pl";

use File::Spec::Functions qw( catdir );

t/error-http_download-exec-error.t  view on Meta::CPAN


BEGIN {
    *CORE::GLOBAL::system = sub {
        return $? = -1
    };
}

use App::Perlbrew::Path;
use App::Perlbrew::HTTP qw(http_download);

local $ENV{PERLBREW_ROOT} = $App::perlbrew::PERLBREW_ROOT = tempdir( CLEANUP => 1 );

subtest "The exit status code of curl", sub {
    my $error = http_download( "https://example.com/whatever.tar.gz",
        App::Perlbrew::Path->new($App::perlbrew::PERLBREW_ROOT)->child("whatever.tar.gz") );

    like $error, qr/^ERROR: Failed to execute the command/;
};

done_testing;

t/error-http_download-exit-nonzero.t  view on Meta::CPAN


BEGIN {
    *CORE::GLOBAL::system = sub {
        return $? = $actual_status_code << 8;
    };
}

use App::Perlbrew::Path;
use App::Perlbrew::HTTP qw(http_download);

local $ENV{PERLBREW_ROOT} = $App::perlbrew::PERLBREW_ROOT = tempdir( CLEANUP => 1 );

subtest "The exit status code of curl", sub {
    my $error = http_download( "https://example.com/whatever.tar.gz",
        App::Perlbrew::Path->new($App::perlbrew::PERLBREW_ROOT)->child("whatever.tar.gz") );

    like $error, qr/^ERROR .+ Exit\ code: .+ ${actual_status_code}/xs;
};

done_testing;

t/error-install-before-init.t  view on Meta::CPAN


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;

t/failure-command-install-cpanm.t  view on Meta::CPAN

#!/usr/bin/env perl
use strict;
use warnings;
use Test::Spec;
use File::Temp qw( tempdir );

use App::perlbrew;
$App::perlbrew::PERLBREW_ROOT = my $perlbrew_root = tempdir( CLEANUP => 1 );
$App::perlbrew::PERLBREW_HOME = my $perlbrew_home = tempdir( CLEANUP => 1 );

{
    no warnings 'redefine';
    sub App::perlbrew::http_get {
        my ($url) = @_;
        like $url, qr/cpanm$/, "GET cpanm url: $url";
        return "404 not found.";
    }
}

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 2.026 seconds using v1.00-cache-2.02-grep-82fe00e-cpan-3b7f77b76a6c )