-
Notifications
You must be signed in to change notification settings - Fork 218
/
Copy pathcommand-env.t
72 lines (61 loc) · 2.4 KB
/
command-env.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/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 File::Temp qw( tempdir );
use File::Spec::Functions qw( catdir );
use Test::Spec;
use Test::Output;
use Config;
mock_perlbrew_install("perl-5.14.1");
mock_perlbrew_lib_create('perl-5.14.1@nobita');
describe "env 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};
};
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";
export PERLBREW_MANPATH="$App::perlbrew::PERLBREW_ROOT/perls/perl-5.14.1/man"
export PERLBREW_PERL="perl-5.14.1"
export PERLBREW_VERSION="$App::perlbrew::VERSION"
export PERLBREW_PATH="$App::perlbrew::PERLBREW_ROOT/bin:$App::perlbrew::PERLBREW_ROOT/perls/perl-5.14.1/bin"
export PERLBREW_ROOT="$App::perlbrew::PERLBREW_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 PERLBREW_PERL="perl-5.14.1"
export PERLBREW_VERSION="$App::perlbrew::VERSION"
export PERL_MB_OPT="--install_base $lib_dir"
export PERL_MM_OPT="INSTALL_BASE=$lib_dir"
export PERL_LOCAL_LIB_ROOT="$lib_dir"
export PERL5LIB="$lib_dir/lib/perl5/$Config{archname}:$lib_dir/lib/perl5${PERL5LIB_maybe}"
export PERLBREW_MANPATH="$lib_dir/man:$App::perlbrew::PERLBREW_ROOT/perls/perl-5.14.1/man"
export PERLBREW_LIB="nobita"
export PERLBREW_PATH="$lib_dir/bin:$App::perlbrew::PERLBREW_ROOT/bin:$App::perlbrew::PERLBREW_ROOT/perls/perl-5.14.1/bin"
export PERLBREW_ROOT="$App::perlbrew::PERLBREW_ROOT"
OUT
}
}
};
runtests unless caller;