Hello community,

here is the log from the commit of package perl-App-perlbrew for 
openSUSE:Factory checked in at 2012-03-07 13:44:00
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/perl-App-perlbrew (Old)
 and      /work/SRC/openSUSE:Factory/.perl-App-perlbrew.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "perl-App-perlbrew", Maintainer is ""

Changes:
--------
--- /work/SRC/openSUSE:Factory/perl-App-perlbrew/perl-App-perlbrew.changes      
2012-02-08 15:40:54.000000000 +0100
+++ /work/SRC/openSUSE:Factory/.perl-App-perlbrew.new/perl-App-perlbrew.changes 
2012-03-07 13:44:12.000000000 +0100
@@ -1,0 +2,10 @@
+Tue Feb 21 09:03:00 UTC 2012 - [email protected]
+
+- updated to 0.41
+  - Fix installation issue when the specified version is not listed in 
CPAN::Perl::Releases
+  - Fix sub-shell invocation for 'switch' and 'use' command. This is 
particularly for csh users, but it should also work for bash users.
+  - Make the stanalone perlbrew program smaller by using Perl::Strip
+  - use CPAN::Perl::Releases to decide the location of perl tarball -- less 
HTTP hits
+  - Prefer $PERLBREW_ROOT/bin/patchperl if it is there.
+
+-------------------------------------------------------------------

Old:
----
  App-perlbrew-0.39.tar.gz

New:
----
  App-perlbrew-0.41.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ perl-App-perlbrew.spec ++++++
--- /var/tmp/diff_new_pack.lR1rKL/_old  2012-03-07 13:44:21.000000000 +0100
+++ /var/tmp/diff_new_pack.lR1rKL/_new  2012-03-07 13:44:21.000000000 +0100
@@ -16,75 +16,74 @@
 #
 
 
-%if 0%{?suse_version} == 0 || 0%{?suse_version} > 1120
-%define with_test 1
-%endif
-
 Name:           perl-App-perlbrew
-Version:        0.39
-Release:        1
-License:        MIT
+Version:        0.41
+Release:        0
 %define cpan_name App-perlbrew
 Summary:        Manage perl installations in your $HOME
-Url:            http://search.cpan.org/dist/App-perlbrew/
+License:        MIT
 Group:          Development/Libraries/Perl
+Url:            http://search.cpan.org/dist/App-perlbrew/
 Source:         
http://www.cpan.org/authors/id/G/GU/GUGOD/%{cpan_name}-%{version}.tar.gz
 BuildArch:      noarch
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
 BuildRequires:  perl
 BuildRequires:  perl-macros
-BuildRequires:  perl(Devel::PatchPerl) >= 0.46
-BuildRequires:  perl(Path::Class)
-BuildRequires:  perl(IO::All)
-BuildRequires:  perl(Try::Tiny)
-BuildRequires:  perl(File::Path::Tiny)
-BuildRequires:  perl(local::lib) >= 1.008
+BuildRequires:  perl(CPAN::Perl::Releases) >= 0.40
 BuildRequires:  perl(Capture::Tiny) >= 0.13
-%if 0%{?with_test}
+BuildRequires:  perl(Devel::PatchPerl) >= 0.62
+BuildRequires:  perl(File::Path::Tiny) >= 0.1
+BuildRequires:  perl(IO::All)
+BuildRequires:  perl(Path::Class)
+BuildRequires:  perl(Test::Exception)
+BuildRequires:  perl(Test::Output)
 BuildRequires:  perl(Test::Simple) >= 0.98
 BuildRequires:  perl(Test::Spec)
-BuildRequires:  perl(Test::Output)
-BuildRequires:  perl(Test::Exception)
-%endif
-Requires:       perl(Devel::PatchPerl) >= 0.26
-Requires:       perl(Path::Class)
-Requires:       perl(IO::All)
-Requires:       perl(Try::Tiny)
-Requires:       perl(File::Path::Tiny)
+BuildRequires:  perl(local::lib) >= 1.008
+#BuildRequires: perl(App::perlbrew)
+#BuildRequires: perl(inc::Module::Install)
+#BuildRequires: perl(JSON)
+#BuildRequires: perl(LWP::Simple)
+#BuildRequires: perl(Module::Build)
+#BuildRequires: perl(Module::Install::Base)
+#BuildRequires: perl(Parse::CPAN::Meta)
+#BuildRequires: perl(YAML::Tiny)
+Requires:       perl(CPAN::Perl::Releases) >= 0.40
+Requires:       perl(Capture::Tiny) >= 0.13
+Requires:       perl(Devel::PatchPerl) >= 0.62
+Requires:       perl(File::Path::Tiny) >= 0.1
 Requires:       perl(local::lib) >= 1.008
-Requires:       perl(Capture::Tiny)
 %{perl_requires}
 
 %description
 perlbrew is a program to automate the building and installation of perl in
-the users HOME. At the moment, it installs everything to
-'~/perl5/perlbrew', and requires you to tweak your PATH by including a
-bashrc/cshrc file it provides. You then can benefit from not having to run
-'sudo' commands to install cpan modules because those are installed inside
-your HOME too. It's a completely separate perl environment.
+an easy way. It installs everything to '~/perl5/perlbrew', and requires you
+to tweak your PATH by including a bashrc/cshrc file it provides. You then
+can benefit from not having to run 'sudo' commands to install cpan modules
+because those are installed inside your HOME too. It provides multiple
+isolated perl environments, and a mechanism for you to switch between them.
+
+For the documentation of perlbrew usage see the perlbrew manpage command on
+CPAN, or by running 'perlbrew help'. The following documentation features
+the API of 'App::perlbrew' module, and may not be remotely close to what
+your want to read.
 
 %prep
 %setup -q -n %{cpan_name}-%{version}
+find . -type f -print0 | xargs -0 chmod 644
 
 %build
 %{__perl} Makefile.PL INSTALLDIRS=vendor
 %{__make} %{?_smp_mflags}
 
-%if 0%{?with_test}
-
 %check
-PERLBREW_ROOT="$PWD/test-perlbrew-root" \
 %{__make} test
-%endif
 
 %install
 %perl_make_install
 %perl_process_packlist
 %perl_gen_filelist
 
-%clean
-%{__rm} -rf %{buildroot}
-
 %files -f %{name}.files
 %defattr(-,root,root,755)
 %doc Changes doc LICENSE README

++++++ App-perlbrew-0.39.tar.gz -> App-perlbrew-0.41.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/App-perlbrew-0.39/Changes 
new/App-perlbrew-0.41/Changes
--- old/App-perlbrew-0.39/Changes       2011-12-31 17:00:05.000000000 +0100
+++ new/App-perlbrew-0.41/Changes       2012-02-02 04:58:45.000000000 +0100
@@ -1,3 +1,12 @@
+0.41:
+- Fix installation issue when the specified version is not listed in 
CPAN::Perl::Releases
+- Fix sub-shell invocation for 'switch' and 'use' command. This is 
particularly for csh users, but it should also work for bash users.
+
+0.40:
+- Make the stanalone perlbrew program smaller by using Perl::Strip
+- use CPAN::Perl::Releases to decide the location of perl tarball -- less HTTP 
hits
+- Prefer $PERLBREW_ROOT/bin/patchperl if it is there.
+
 0.39:
 - Fix GH #179. lib naming are more consistent.
 - Fix GH #171. bash users are suggestted to upgrad to this version.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/App-perlbrew-0.39/MANIFEST 
new/App-perlbrew-0.41/MANIFEST
--- old/App-perlbrew-0.39/MANIFEST      2011-12-31 16:54:45.000000000 +0100
+++ new/App-perlbrew-0.41/MANIFEST      2012-02-02 04:57:45.000000000 +0100
@@ -38,6 +38,7 @@
 t/11.editdist.t
 t/11.root_from_arg.t
 t/12.sitecustomize.t
+t/13.perl_release.t
 t/command-available.t
 t/command-compgen.t
 t/command-display-rc.t
@@ -48,6 +49,7 @@
 t/command-install-patchperl.t
 t/command-lib.t
 t/command-list.t
+t/current_perl.t
 t/installation-perlbrew.t
 t/installation.t
 t/installation2.t
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/App-perlbrew-0.39/META.yml 
new/App-perlbrew-0.41/META.yml
--- old/App-perlbrew-0.39/META.yml      2011-12-31 17:01:13.000000000 +0100
+++ new/App-perlbrew-0.41/META.yml      2012-02-02 04:59:54.000000000 +0100
@@ -27,12 +27,13 @@
     - inc
     - t
 requires:
+  CPAN::Perl::Releases: 0.40
   Capture::Tiny: 0.13
-  Devel::PatchPerl: 0.46
+  Devel::PatchPerl: 0.62
   File::Path::Tiny: 0.1
   local::lib: 1.008
   perl: 5.8.0
 resources:
   license: http://opensource.org/licenses/mit-license.php
   repository: git://github.com/gugod/App-perlbrew.git
-version: 0.39
+version: 0.41
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/App-perlbrew-0.39/Makefile.PL 
new/App-perlbrew-0.41/Makefile.PL
--- old/App-perlbrew-0.39/Makefile.PL   2011-12-29 03:10:13.000000000 +0100
+++ new/App-perlbrew-0.41/Makefile.PL   2012-01-29 07:24:34.000000000 +0100
@@ -7,10 +7,11 @@
 repository 'git://github.com/gugod/App-perlbrew.git';
 
 requires
-    'File::Path::Tiny'  => '0.1',
-    'Devel::PatchPerl'  => '0.46',
-    'local::lib'        => '1.008',
-    'Capture::Tiny'     => '0.13';
+    'File::Path::Tiny'     => '0.1',
+    'Devel::PatchPerl'     => '0.62',
+    'local::lib'           => '1.008',
+    'Capture::Tiny'        => '0.13',
+    'CPAN::Perl::Releases' => '0.40';
 
 test_requires
     'Test::Simple'    => '0.98',
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/App-perlbrew-0.39/lib/App/perlbrew.pm 
new/App-perlbrew-0.41/lib/App/perlbrew.pm
--- old/App-perlbrew-0.39/lib/App/perlbrew.pm   2011-12-31 17:00:05.000000000 
+0100
+++ new/App-perlbrew-0.41/lib/App/perlbrew.pm   2012-02-02 04:58:45.000000000 
+0100
@@ -7,8 +7,9 @@
 use File::Spec::Functions qw( catfile catdir );
 use File::Path::Tiny;
 use FindBin;
+use CPAN::Perl::Releases;
 
-our $VERSION = "0.39";
+our $VERSION = "0.41";
 our $CONFIG;
 
 our $PERLBREW_ROOT = $ENV{PERLBREW_ROOT} || catdir($ENV{HOME}, "perl5", 
"perlbrew");
@@ -31,8 +32,13 @@
 }
 
 sub current_perl {
-    my ($self) = @_;
-    return $self->env('PERLBREW_PERL')  || ''
+    my ($self, $v) = @_;
+
+    if ($v) {
+        $self->{current_perl} = $v;
+    }
+
+    return $self->{current_perl} || $self->env('PERLBREW_PERL')  || ''
 }
 
 sub BASHRC_CONTENT() {
@@ -291,10 +297,11 @@
         'notest|n!',
         'quiet|q!',
         'verbose|v',
-        'root=s',
         'as=s',
         'help|h',
         'version',
+        'root=s',
+
         # options passed directly to Configure
         'D=s@',
         'U=s@',
@@ -602,6 +609,35 @@
     return @available_versions;
 }
 
+sub perl_release {
+    my ($self, $version) = @_;
+
+    my $tarballs = CPAN::Perl::Releases::perl_tarballs($version);
+
+    my $x = (values %$tarballs)[0];
+
+    if ($x) {
+        my $dist_tarball = (split("/", $x))[-1];
+        my $dist_tarball_url = "http://search.cpan.org//CPAN/authors/id/$x";;
+        return ($dist_tarball, $dist_tarball_url);
+    }
+
+    my $mirror = $self->config->{mirror};
+    my $header = $mirror ? { 'Cookie' => "cpan=$mirror->{url}" } : undef;
+    my $html = http_get("http://search.cpan.org/dist/perl-${version}";, 
$header);
+
+    unless ($html) {
+        die "ERROR: Failed to download perl-${version} tarball.";
+    }
+
+    my ($dist_path, $dist_tarball) =
+        $html =~ m[<a 
href="(/CPAN/authors/id/.+/(perl-${version}.tar.(gz|bz2)))">Download</a>];
+    die "ERROR: Cannot find the tarball for perl-$version\n"
+        if !$dist_path and !$dist_tarball;
+    my $dist_tarball_url = 
"http://search.cpan.org/CPAN/authors/id/${dist_path}";;
+    return ($dist_tarball, $dist_tarball_url);
+}
+
 sub run_command_init {
     my $self = shift;
     my $HOME = $self->env('HOME');
@@ -822,38 +858,37 @@
     my $dist = shift;
 
     my ($dist_name, $dist_version) = $dist =~ m/^(.*)-([\d.]+(?:-RC\d+)?)$/;
-    my $mirror = $self->config->{mirror};
-    my $header = $mirror ? { 'Cookie' => "cpan=$mirror->{url}" } : undef;
-    my $html = http_get("http://search.cpan.org/dist/$dist";, $header);
-
-    unless ($html) {
-        die "ERROR: Failed to download $dist tarball.";
-    }
-
-    my ($dist_path, $dist_tarball) =
-        $html =~ m[<a 
href="(/CPAN/authors/id/.+/(${dist}.tar.(gz|bz2)))">Download</a>];
-    die "ERROR: Cannot find the tarball for $dist\n"
-        if !$dist_path and !$dist_tarball;
 
+    my ($dist_tarball, $dist_tarball_url) = $self->perl_release($dist_version);
     my $dist_tarball_path = catfile($self->root, "dists", $dist_tarball);
-    my $dist_tarball_url  = "http://search.cpan.org${dist_path}";;
 
     if (-f $dist_tarball_path) {
-        print "Use the previously fetched ${dist_tarball}\n";
+        print "Use the previously fetched ${dist_tarball}\n"
+            if $self->{verbose};
     }
     else {
-        print "Fetching $dist as $dist_tarball_path\n";
+        print "Fetching $dist as $dist_tarball_path\n"
+            unless $self->{quiet};
+
+        my $mirror = $self->config->{mirror};
+        my $header = $mirror ? { 'Cookie' => "cpan=$mirror->{url}" } : undef;
+
         http_get(
             $dist_tarball_url,
             $header,
             sub {
                 my ($body) = @_;
+
+                die "ERROR: Failed to download $dist tarball.\n"
+                    unless $body;
+
                 open my $BALL, "> $dist_tarball_path";
                 print $BALL $body;
                 close $BALL;
             }
         );
     }
+
     my $dist_extracted_path = $self->do_extract_tarball($dist_tarball_path);
     $self->do_install_this($dist_extracted_path,$dist_version, $dist);
     return;
@@ -939,6 +974,12 @@
     }
 
     my $perlpath = $self->root . "/perls/$as";
+    my $patchperl = $self->root . "/bin/patchperl";
+
+    unless (-x $patchperl && -f _) {
+        $patchperl = "patchperl";
+    }
+
     unshift @d_options, qq(prefix=$perlpath);
     push @d_options, "usedevel" if $dist_version =~ /5\.1[13579]|git|blead/;
     print "Installing $dist_extracted_dir into " . $self->path_with_tilde("@{[ 
$self->root ]}/perls/$as") . "\n";
@@ -971,7 +1012,7 @@
     (
         "cd $dist_extracted_dir",
         "rm -f config.sh Policy.sh",
-        "patchperl",
+        $patchperl,
         "sh Configure $configure_flags " .
             join( ' ',
                 ( map { qq{'-D$_'} } @d_options ),
@@ -1183,28 +1224,46 @@
     }
 }
 
-sub run_command_use {
-    my $self = shift;
-    my $perl = shift;
 
-    if ( !$perl ) {
-        my $current = $self->current_perl;
-        if ($current) {
-            print "Currently using $current\n";
-        } else {
-            print "No version in use; defaulting to system\n";
+sub launch_sub_shell {
+    my ($self, $name) = @_;
+    my $shell = $self->env('SHELL');
+
+    my $shell_opt = "";
+
+    if ($shell =~ /\/zsh$/) {
+        $shell_opt = "-d -f";
+
+        if ($^O eq 'darwin') {
+            my $root_dir = $self->root;
+            print <<"WARNINGONMAC"
+--------------------------------------------------------------------------------
+WARNING: zsh perlbrew sub-shell is not working on Mac OSX Lion.
+
+It is known that on MacOS Lion, zsh always resets the value of PATH on 
launching
+a sub-shell. Effectively nullify the changes required by perlbrew sub-shell. 
You
+may `echo \$PATH` to examine it and if you see perlbrew related paths are in 
the
+end, instead of in the beginning, you are unfortunate.
+
+You are advertised to include the following line to your ~/.zshenv as a better
+way to work with perlbrew:
+
+    source $root_dir/etc/bashrc
+
+--------------------------------------------------------------------------------
+WARNINGONMAC
         }
-        return;
+    }
+    elsif  ($shell =~ /\/bash$/)  {
+        $shell_opt = "--noprofile --norc";
     }
 
-    my $shell = $self->env('SHELL');
-    my $shell_opt = "";
-    my %env = ($self->perlbrew_env($perl), PERLBREW_SKIP_INIT => 1);
+    my %env = ($self->perlbrew_env($name), PERLBREW_SKIP_INIT => 1);
 
     unless ($ENV{PERLBREW_VERSION}) {
         my $root = $self->root;
         # The user does not source bashrc/csh in their shell initialization.
-        $env{PATH   } = $env{PERLBREW_PATH   } . ":" . join ":", grep { 
!/$root/ } split ":", $ENV{PATH};
+        $env{PATH}    = $env{PERLBREW_PATH}    . ":" . join ":", grep { 
!/$root/ } split ":", $ENV{PATH};
         $env{MANPATH} = $env{PERLBREW_MANPATH} . ":" . join ":", grep { 
!/$root/ } split ":", $ENV{MANPATH};
     }
 
@@ -1214,11 +1273,28 @@
     }
     $command .= " $shell $shell_opt";
 
-    print "\nA sub-shell is launched with $perl as the activated perl. Run 
'exit' to finish it.\n\n";
-
+    print "\nA sub-shell is launched with $name as the activated perl. Run 
'exit' to finish it.\n\n";
     exec($command);
 }
 
+sub run_command_use {
+    my $self = shift;
+    my $perl = shift;
+
+    if ( !$perl ) {
+        my $current = $self->current_perl;
+        if ($current) {
+            print "Currently using $current\n";
+        } else {
+            print "No version in use; defaulting to system\n";
+        }
+        return;
+    }
+
+    $self->launch_sub_shell($perl);
+
+}
+
 sub run_command_switch {
     my ( $self, $dist, $alias ) = @_;
 
@@ -1232,36 +1308,26 @@
     die "Cannot use for alias something that starts with 'perl-'\n"
       if $alias && $alias =~ /^perl-/;
 
-    my $vers = $dist;
-
     die "${dist} is not installed\n" unless -d catdir($self->root, "perls", 
$dist);
 
-    local $ENV{PERLBREW_PERL} = $dist;
-    my $HOME = $self->env('HOME');
-    my $pb_home = $self->env("PERLBREW_HOME") || $PERLBREW_HOME;
+    if ($self->env("PERLBREW_BASHRC_VERSION")) {
+        local $ENV{PERLBREW_PERL} = $dist;
+        my $HOME = $self->env('HOME');
+        my $pb_home = $self->env("PERLBREW_HOME") || $PERLBREW_HOME;
 
-    mkpath($pb_home);
-    system("$0 env $dist > " . catfile($pb_home, "init"));
+        mkpath($pb_home);
+        system("$0 env $dist > " . catfile($pb_home, "init"));
 
-    print "Switched to $vers. To use it immediately, run this line in this 
terminal:\n\n    exec @{[ $self->env('SHELL') ]}\n\n";
+        print "Switched to $dist.\n\n";
+    }
+    else {
+        $self->launch_sub_shell($dist);
+    }
 }
 
 sub run_command_off {
     my $self = shift;
-
-    my $shell = $self->env('SHELL');
-
-    $ENV{PERLBREW_PERL} = "";
-    my %env = ($self->perlbrew_env, PERLBREW_SKIP_INIT => 1);
-
-    my $command = "env ";
-    while (my ($k, $v) = each(%env)) {
-        $command .= "$k=$v ";
-    }
-    $command .= " $shell";
-
-    print "\nA sub-shell is launched with perlbrew turned off. Run 'exit' to 
finish it.\n\n";
-    exec($command);
+    $self->launch_sub_shell;
 }
 
 sub run_command_switch_off {
@@ -1508,17 +1574,24 @@
 
 sub run_command_exec {
     my $self = shift;
-    my @args = @{$self->{original_argv}};
+    my %opts;
 
-    if ($args[0] eq '--root') {
-        shift @args;
-        shift @args;
-    }
+    local (@ARGV) = @{$self->{original_argv}};
 
-    shift @args;
+    shift @ARGV; # "exec"
 
+    Getopt::Long::GetOptions(
+        \%opts,
+        'with=s',
+    );
 
-    for my $i ( $self->installed_perls ) {
+    my @exec_with = $self->installed_perls;
+
+    if ($opts{with}) {
+        @exec_with = grep { $_->{name} eq $opts{with} } @exec_with;
+    }
+
+    for my $i ( @exec_with ) {
         next if -l $self->root . '/perls/' . $i->{name}; # Skip Aliases
         my %env = $self->perlbrew_env($i->{name});
         next if !$env{PERLBREW_PERL};
@@ -1528,7 +1601,7 @@
         local $ENV{MANPATH} = join(':', $env{PERLBREW_MANPATH}, 
$ENV{MANPATH}||"");
 
         print "$i->{name}\n==========\n";
-        system @args;
+        $self->do_system(@ARGV);
         print "\n\n";
         # print "\n<===\n\n\n";
     }
@@ -1848,6 +1921,19 @@
 
 =head1 METHODS
 
+=over 4
+
+=item (Str) current_perl
+
+Return the "current perl" object attribute string, or, if absent, the value of
+PERLBREW_PERL environment variable.
+
+=item (Str) current_perl (Str)
+
+Set the "current_perl" object attribute to the given value.
+
+=back
+
 =head1 PROJECT DEVELOPMENT
 
 perlbrew project uses github
@@ -1862,7 +1948,7 @@
 
 =head1 COPYRIGHT
 
-Copyright (c) 2010, 2011 Kang-min Liu C<< <[email protected]> >>.
+Copyright (c) 2010, 2011, 2012 Kang-min Liu C<< <[email protected]> >>.
 
 =head1 LICENCE
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/App-perlbrew-0.39/t/05.get_current_perl.t 
new/App-perlbrew-0.41/t/05.get_current_perl.t
--- old/App-perlbrew-0.39/t/05.get_current_perl.t       2011-12-23 
07:21:57.000000000 +0100
+++ new/App-perlbrew-0.41/t/05.get_current_perl.t       2012-02-02 
04:58:43.000000000 +0100
@@ -16,11 +16,12 @@
 mock_perlbrew_install("perl-5.14.2");
 
 subtest "perlbrew version" => sub {
-    my $app = App::perlbrew->new();
+
     my $version = $App::perlbrew::VERSION;
     stdout_is(
         sub {
-            $app->run_command('version');
+            my $app = App::perlbrew->new("version");
+            $app->run;
         },
         "t/05.get_current_perl.t  - App::perlbrew/$version\n"
     );
@@ -33,5 +34,16 @@
         is $app->current_perl, $v;
     }
 };
+
+
+subtest "Current perl can be decided from object attribute, which overrides 
env var." => sub {
+    local $ENV{PERLBREW_PERL} = "perl-5.12.3";
+
+    for my $v (qw(perl-5.12.3 perl-5.12.3 perl-5.14.1 perl-5.14.2)) {
+        my $app = App::perlbrew->new;
+        $app->{current_perl} = $v;
+        is $app->current_perl, $v;
+    }
+};
 
 done_testing;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/App-perlbrew-0.39/t/08.error_install.t 
new/App-perlbrew-0.41/t/08.error_install.t
--- old/App-perlbrew-0.39/t/08.error_install.t  2011-08-08 17:02:58.000000000 
+0200
+++ new/App-perlbrew-0.41/t/08.error_install.t  2012-02-02 04:58:43.000000000 
+0100
@@ -5,19 +5,27 @@
 use Test::More;
 use Test::Exception;
 use Path::Class;
-
-BEGIN {
-    $ENV{PERLBREW_ROOT} = file(__FILE__)->dir->subdir("mock_perlbrew_root");
-}
+use File::Temp qw(tempdir);
 
 use App::perlbrew;
 
-App::perlbrew::rmpath( $ENV{PERLBREW_ROOT} );
+$App::perlbrew::PERLBREW_ROOT = tempdir( CLEANUP => 1 );
+$App::perlbrew::PERLBREW_HOME = tempdir( CLEANUP => 1 );
+$ENV{PERLBREW_ROOT} = $App::perlbrew::PERLBREW_ROOT;
+
 App::perlbrew::mkpath( dir($ENV{PERLBREW_ROOT})->subdir("perls") );
 App::perlbrew::mkpath( dir($ENV{PERLBREW_ROOT})->subdir("build") );
+App::perlbrew::mkpath( dir($ENV{PERLBREW_ROOT})->subdir("dists") );
 
 no warnings 'redefine';
-sub App::perlbrew::http_get { "" }
+sub App::perlbrew::http_get {
+    my ($url, $header, $cb) = @_;
+    if (ref($header) eq 'CODE') {
+        $cb = $header;
+        $header = undef;
+    }
+    $cb->(undef);
+}
 
 throws_ok(
     sub {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/App-perlbrew-0.39/t/08.error_install_blead.t 
new/App-perlbrew-0.41/t/08.error_install_blead.t
--- old/App-perlbrew-0.39/t/08.error_install_blead.t    2011-08-08 
17:02:58.000000000 +0200
+++ new/App-perlbrew-0.41/t/08.error_install_blead.t    2012-02-02 
04:58:43.000000000 +0100
@@ -1,15 +1,16 @@
 #!/usr/bin/env perl
 use strict;
 use warnings;
-use lib qw(lib);
+
+use FindBin;
+use lib $FindBin::Bin;
+use App::perlbrew;
+require 'test_helpers.pl';
+
 use Test::More;
 use Test::Exception;
 use Path::Class;
 
-BEGIN {
-    $ENV{PERLBREW_ROOT} = file(__FILE__)->dir->subdir("mock_perlbrew_root");
-}
-
 use App::perlbrew;
 {
     no warnings 'redefine';
@@ -19,10 +20,6 @@
     }
 }
 
-App::perlbrew::rmpath( $ENV{PERLBREW_ROOT} );
-App::perlbrew::mkpath( dir($ENV{PERLBREW_ROOT})->subdir("perls") );
-App::perlbrew::mkpath( dir($ENV{PERLBREW_ROOT})->subdir("build") );
-
 throws_ok(
     sub {
         my $app = App::perlbrew->new("install", "perl-blead");
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/App-perlbrew-0.39/t/08.error_install_cpanm.t 
new/App-perlbrew-0.41/t/08.error_install_cpanm.t
--- old/App-perlbrew-0.39/t/08.error_install_cpanm.t    2011-11-03 
20:03:19.000000000 +0100
+++ new/App-perlbrew-0.41/t/08.error_install_cpanm.t    2012-02-02 
04:58:43.000000000 +0100
@@ -1,13 +1,12 @@
 #!/usr/bin/env perl
 use strict;
 use warnings;
-use Path::Class;
-BEGIN {
-    $ENV{PERLBREW_ROOT} = file(__FILE__)->dir->subdir("mock_perlbrew_root");
-}
-App::perlbrew::rmpath( $ENV{PERLBREW_ROOT} );
 
+use FindBin;
+use lib $FindBin::Bin;
 use App::perlbrew;
+require 'test_helpers.pl';
+
 use Test::More;
 use Test::Exception;
 
@@ -23,5 +22,3 @@
 );
 
 done_testing;
-
-App::perlbrew::rmpath( $ENV{PERLBREW_ROOT} );
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/App-perlbrew-0.39/t/09.exit_status.t 
new/App-perlbrew-0.41/t/09.exit_status.t
--- old/App-perlbrew-0.39/t/09.exit_status.t    2011-10-13 17:29:25.000000000 
+0200
+++ new/App-perlbrew-0.41/t/09.exit_status.t    2012-02-02 04:58:43.000000000 
+0100
@@ -1,19 +1,18 @@
 #!/usr/bin/env perl
 use strict;
 use warnings;
-use lib qw(lib);
+
+use FindBin;
+use lib $FindBin::Bin;
+use App::perlbrew;
+require 'test_helpers.pl';
+
 use Test::More;
 use Test::Exception;
 use Path::Class;
 
-BEGIN {
-    $ENV{PERLBREW_ROOT} = file(__FILE__)->dir->subdir("mock_perlbrew_root");
-}
-
 my $bin_perlbrew = 
file(__FILE__)->dir->parent->subdir("bin")->file("perlbrew");
 
-use App::perlbrew;
-
 throws_ok(
     sub {
         my $app = App::perlbrew->new("unknown-command");
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/App-perlbrew-0.39/t/12.sitecustomize.t 
new/App-perlbrew-0.41/t/12.sitecustomize.t
--- old/App-perlbrew-0.39/t/12.sitecustomize.t  2011-12-28 09:42:41.000000000 
+0100
+++ new/App-perlbrew-0.41/t/12.sitecustomize.t  2012-02-02 04:58:43.000000000 
+0100
@@ -3,13 +3,14 @@
 use Path::Class;
 use Capture::Tiny qw/capture/;
 use IO::All;
-BEGIN {
-    $ENV{PERLBREW_ROOT} = file(__FILE__)->dir->subdir("mock_perlbrew_root");
-}
+use App::perlbrew;
+use File::Temp qw( tempdir );
 
-use Test::More;
+$App::perlbrew::PERLBREW_ROOT = tempdir( CLEANUP => 1 );
+$App::perlbrew::PERLBREW_HOME = tempdir( CLEANUP => 1 );
+$ENV{PERLBREW_ROOT} = $App::perlbrew::PERLBREW_ROOT;
 
-use App::perlbrew;
+use Test::More;
 
 ## setup
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/App-perlbrew-0.39/t/13.perl_release.t 
new/App-perlbrew-0.41/t/13.perl_release.t
--- old/App-perlbrew-0.39/t/13.perl_release.t   1970-01-01 01:00:00.000000000 
+0100
+++ new/App-perlbrew-0.41/t/13.perl_release.t   2012-02-02 04:58:43.000000000 
+0100
@@ -0,0 +1,46 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use FindBin;
+use lib $FindBin::Bin;
+use App::perlbrew;
+require "test_helpers.pl";
+
+use File::Temp qw(tempdir);
+use Test::Spec;
+use Test::Exception;
+
+describe "App::perlbrew#perl_release method" => sub {
+    describe "given a valid perl version" => sub {
+        it "returns the perl dist tarball file name, and its download url" => 
sub {
+            my $app = App::perlbrew->new;
+
+            for my $version (qw(5.14.2 5.10.1 5.10.0 5.003_07 5.004_05)) {
+                my ($ball, $url) = $app->perl_release($version);
+                like $ball, qr/perl-?${version}.tar.(bz2|gz)/;
+                like $url, qr/${ball}$/;
+            }
+        };
+    };
+
+    describe "when the given versionis not found is CPAN::Perl::Releases" => 
sub {
+        no warnings 'redefine';
+
+        my $version = "5.14.2";
+
+        my $orig_sub = \&CPAN::Perl::Releases::perl_tarballs;
+        *App::perlbrew::http_get = sub {
+            return qq{<a 
href="/CPAN/authors/id/SOMEONE/perl-${version}.tar.gz">Download</a>};
+        };
+        *CPAN::Perl::Releases::perl_tarballs = sub {};
+
+        my $app = App::perlbrew->new;
+        my ($ball, $url) = $app->perl_release($version);
+        like $ball, qr/perl-?${version}.tar.(bz2|gz)/, $ball;
+        like $url, qr#authors/id/.+/${ball}$#, $url;
+
+        *CPAN::Perl::Releases::perl_tarballs = $orig_sub;
+    };
+};
+
+runtests unless caller;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/App-perlbrew-0.39/t/command-exec.t 
new/App-perlbrew-0.41/t/command-exec.t
--- old/App-perlbrew-0.39/t/command-exec.t      2011-12-23 07:21:57.000000000 
+0100
+++ new/App-perlbrew-0.41/t/command-exec.t      2012-02-02 04:58:43.000000000 
+0100
@@ -6,70 +6,61 @@
 use App::perlbrew;
 require 'test_helpers.pl';
 
-use Test::More;
-use Path::Class;
-use File::Temp qw( tempdir );
-
-my $root = dir($App::perlbrew::PERLBREW_ROOT);
-
-my @perls = qw( yak needs shave );
-my %exe = (
-    # this enables "perlbrew exec perl -e '...'"
-    perl => {
-        # interpolate $^X to specify current perl and avoid infinite recursion
-        content => qq[#!/bin/sh\nPERLBREW_TEST_PERL="\$0" exec $^X "\$@";\n],
-        # printing $^X is not helpful because these exe's are shell scripts 
that call the same perl
-        args    => [ qw( exec perl -e ), 'open FH, ">>", shift and print FH 
"=$ENV{PERLBREW_TEST_PERL}\n" and close FH' ],
-        output  => join('', sort map { "=$root/perls/$_/bin/perl\n" } @perls),
-    },
-    # also test an exe that isn't "perl" (like a script installed by a module)
-    brewed_app => {
-        content => qq[#!/bin/sh\necho \$0 >> \$1\n],
-        args    => [ qw( exec brewed_app ) ],
-        output  => join('', sort map { "$root/perls/$_/bin/brewed_app\n" } 
@perls),
-    },
-    # test something outside the $perl/bin/ to ensure that the environment is 
setup correctly
-    # NOTE: this script may need to change if the usage of these perlbrew vars 
changes
-    test_env => {
-        content => '', # don't create a file for this one
-        args    => [ qw( exec sh -c ), 'echo "$PERLBREW_PERL--$PERLBREW_PATH" 
>> $0' ],
-        output  => join('', sort map { "$_--$root/bin:$root/perls/$_/bin\n" } 
@perls),
-    },
-);
-
-close STDOUT;
-close STDERR;
-
-# build a fake root with some fake perls (most of this was modified from stuff 
found in t/installation.t)
-foreach my $name ( @perls ) {
-    my $bin = $root->subdir("perls", $name, "bin");
-    App::perlbrew::mkpath($bin) for @perls;
-
-    while ( my ($script, $data) = each %exe ) {
-      next unless $data->{content};
-      my $path = $bin->file($script);
-      io($path)->print( $data->{content} );
-      chmod 0755, $path;
-    }
-}
-
-# exec each script
-while ( my ($script, $data) = each %exe ) {
-  # we need a file to which the subprocesses can append
-  my $file = $root->file("test-exec-output.$script");
-
-  my $app = App::perlbrew->new(@{ $data->{args} }, $file->stringify);
-  $app->run;
-
-  # $file should have output in it
-  if ( -e $file ) {
-    # get output from all execs (ensure same order as above)
-    my $output = do { open(my $fh, '<', $file); join '', sort <$fh>; };
-    is $output, $data->{output}, 'correct exec output';
-  }
-  else {
-    ok 0, 'output file does not exist';
-  }
-}
+use Test::Spec;
 
-done_testing;
+mock_perlbrew_install("perl-5.12.3");
+mock_perlbrew_install("perl-5.12.4");
+mock_perlbrew_install("perl-5.14.1");
+mock_perlbrew_install("perl-5.14.2");
+
+describe 'perlbrew exec perl -E "say 42"' => sub {
+    it "invokes all perls" => sub {
+        my $app = App::perlbrew->new(qw(exec perl -E), "say 42");
+
+        my @perls = $app->installed_perls;
+
+        $app->expects("do_system")->exactly(4)->returns(
+            sub {
+                my ($self, @args) = @_;
+
+                is_deeply \@args, ["perl", "-E", "say 42"];
+
+                my ($perlbrew_bin_path, $perlbrew_perl_bin_path, @paths) = 
split(":", $ENV{PATH});
+
+                my $perl_installation = shift @perls;
+
+                is $perlbrew_bin_path,      
file($App::perlbrew::PERLBREW_ROOT, "bin");
+                is $perlbrew_perl_bin_path, 
file($App::perlbrew::PERLBREW_ROOT, "perls", $perl_installation->{name}, 
"bin"), "perls/". $perl_installation->{name} . "/bin";
+
+                return 0;
+            }
+        );
+
+        $app->run;
+    };
+};
+
+describe 'perlbrew exec --with perl-5.12.3 perl -E "say 42"' => sub {
+    it "invokes perl-5.12.3/bin/perl" => sub {
+        my $app = App::perlbrew->new(qw(exec --with perl-5.12.3 perl -E), "say 
42");
+
+        $app->expects("do_system")->returns(
+            sub {
+                my ($self, @args) = @_;
+
+                is_deeply \@args, ["perl", "-E", "say 42"];
+
+                my ($perlbrew_bin_path, $perlbrew_perl_bin_path, @paths) = 
split(":", $ENV{PATH});
+
+                is $perlbrew_bin_path,      
file($App::perlbrew::PERLBREW_ROOT, "bin");
+                is $perlbrew_perl_bin_path, 
file($App::perlbrew::PERLBREW_ROOT, "perls", "perl-5.12.3", "bin");
+
+                return 0;
+            }
+        );
+
+        $app->run;
+    };
+};
+
+runtests unless caller;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/App-perlbrew-0.39/t/current_perl.t 
new/App-perlbrew-0.41/t/current_perl.t
--- old/App-perlbrew-0.39/t/current_perl.t      1970-01-01 01:00:00.000000000 
+0100
+++ new/App-perlbrew-0.41/t/current_perl.t      2012-02-02 04:58:43.000000000 
+0100
@@ -0,0 +1,49 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use FindBin;
+use lib $FindBin::Bin;
+use App::perlbrew;
+require 'test_helpers.pl';
+
+use Test::Spec;
+
+mock_perlbrew_install("perl-5.12.3");
+mock_perlbrew_install("perl-5.12.4");
+mock_perlbrew_install("perl-5.14.1");
+mock_perlbrew_install("perl-5.14.2");
+
+describe "current perl" => sub {
+    it "is decided from env var PERLBREW_PERL" => sub {
+        for my $v (qw(perl-5.12.3 perl-5.12.3 perl-5.14.1 perl-5.14.2)) {
+            local $ENV{PERLBREW_PERL} = $v;
+            my $app = App::perlbrew->new;
+            is $app->current_perl, $v;
+        }
+    };
+
+    it "can be decided from object attribute, which overrides env var." => sub 
{
+        local $ENV{PERLBREW_PERL} = "perl-5.12.3";
+
+        for my $v (qw(perl-5.12.3 perl-5.12.3 perl-5.14.1 perl-5.14.2)) {
+            my $app = App::perlbrew->new;
+            $app->{current_perl} = $v;
+            is $app->current_perl, $v;
+        }
+    };
+
+    it "can be set with current_perl method." => sub {
+        local $ENV{PERLBREW_PERL} = "perl-5.12.3";
+
+        for my $v (qw(perl-5.12.3 perl-5.12.3 perl-5.14.1 perl-5.14.2)) {
+            my $app = App::perlbrew->new;
+            is $app->current_perl, "perl-5.12.3";
+
+            $app->current_perl($v);
+            is $app->current_perl, $v;
+        }
+    };
+};
+
+runtests unless caller;
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/App-perlbrew-0.39/t/installation-perlbrew.t 
new/App-perlbrew-0.41/t/installation-perlbrew.t
--- old/App-perlbrew-0.39/t/installation-perlbrew.t     2011-12-23 
07:21:57.000000000 +0100
+++ new/App-perlbrew-0.41/t/installation-perlbrew.t     2012-02-02 
04:58:43.000000000 +0100
@@ -10,7 +10,7 @@
 use Path::Class;
 use Test::More;
 
-diag "PERLBREW_ROOT set to $ENV{PERLBREW_ROOT}";
+note "PERLBREW_ROOT set to $ENV{PERLBREW_ROOT}";
 
 subtest "`perlbrew self-install` initialize the required dir structure under 
PERLBREW_ROOT", sub {
     my $app = App::perlbrew->new('--quiet', 'self-install');
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/App-perlbrew-0.39/t/installation.t 
new/App-perlbrew-0.41/t/installation.t
--- old/App-perlbrew-0.39/t/installation.t      2011-08-08 17:02:58.000000000 
+0200
+++ new/App-perlbrew-0.41/t/installation.t      2012-02-02 04:58:43.000000000 
+0100
@@ -1,40 +1,14 @@
 #!/usr/bin/env perl
 use strict;
 use warnings;
-use Path::Class;
-use IO::All;
-BEGIN {
-    $ENV{PERLBREW_ROOT} = file(__FILE__)->dir->subdir("mock_perlbrew_root");
-}
 
-use Test::More;
-use Test::Exception;
+use FindBin;
+use lib $FindBin::Bin;
 use App::perlbrew;
+require 'test_helpers.pl';
 
-## setup
-
-App::perlbrew::rmpath( $ENV{PERLBREW_ROOT} );
-
-## mock
-
-no warnings 'redefine';
-
-sub App::perlbrew::do_install_release {
-    my ($self, $name) = @_;
-
-    $name = $self->{as} if $self->{as};
-
-    my $root = dir($ENV{PERLBREW_ROOT});
-    my $installation_dir = $root->subdir("perls", $name);
-    App::perlbrew::mkpath($installation_dir);
-    App::perlbrew::mkpath($root->subdir("perls", $name, "bin"));
-
-    my $perl = $root->subdir("perls", $name, "bin")->file("perl");
-    io($perl)->print("#!/bin/sh\nperl \"\$@\";\n");
-    chmod 0755, $perl;
-}
-
-use warnings;
+use Test::More;
+use Test::Exception;
 
 ## main
 
@@ -65,8 +39,6 @@
     ok $app->can("is_installed");
     ok $app->is_installed("perl-5.14.0");
     ok !$app->is_installed("perl-5.13.0");
-
-    done_testing;
 };
 
 subtest "do not clobber exitsing user-specified name." => sub {
@@ -82,8 +54,6 @@
         my $app = App::perlbrew->new("install", "perl-5.14.0", "--as", 
"the-dude");
         $app->run;
     } "should die when doing install with existing user-specified name.";
-
-    done_testing;
 };
 
 done_testing;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/App-perlbrew-0.39/t/installation2.t 
new/App-perlbrew-0.41/t/installation2.t
--- old/App-perlbrew-0.39/t/installation2.t     2011-08-08 17:02:58.000000000 
+0200
+++ new/App-perlbrew-0.41/t/installation2.t     2012-02-02 04:58:43.000000000 
+0100
@@ -2,29 +2,20 @@
 use strict;
 use warnings;
 
-use Path::Class;
-BEGIN {
-    $ENV{PERLBREW_ROOT} = file(__FILE__)->dir->subdir("mock_perlbrew_root");
-}
+use FindBin;
+use lib $FindBin::Bin;
+use App::perlbrew;
+require 'test_helpers.pl';
 
 use Test::Spec;
 
-use App::perlbrew;
-
 ## setup
 
-
-
 ##
 
 note "PERLBREW_ROOT set to $ENV{PERLBREW_ROOT}";
 
 describe "App::perlbrew" => sub {
-    before each => sub {
-        App::perlbrew::rmpath( $ENV{PERLBREW_ROOT} );
-        App::perlbrew::mkpath( $ENV{PERLBREW_ROOT} );
-    };
-
     describe "->do_install_url method" => sub {
         it "should accept an URL to perl tarball, and download the tarball." 
=> sub {
             my $app = App::perlbrew->new;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/App-perlbrew-0.39/t/test_helpers.pl 
new/App-perlbrew-0.41/t/test_helpers.pl
--- old/App-perlbrew-0.39/t/test_helpers.pl     2011-12-23 07:21:57.000000000 
+0100
+++ new/App-perlbrew-0.41/t/test_helpers.pl     2012-02-02 04:58:43.000000000 
+0100
@@ -23,6 +23,10 @@
 $App::perlbrew::PERLBREW_HOME = tempdir( CLEANUP => 1 );
 $ENV{PERLBREW_ROOT} = $App::perlbrew::PERLBREW_ROOT;
 
+App::perlbrew::mkpath( dir($ENV{PERLBREW_ROOT})->subdir("perls") );
+App::perlbrew::mkpath( dir($ENV{PERLBREW_ROOT})->subdir("build") );
+App::perlbrew::mkpath( dir($ENV{PERLBREW_ROOT})->subdir("dists") );
+
 no warnings 'redefine';
 
 sub App::perlbrew::do_install_release {
@@ -47,7 +51,7 @@
 
     chmod 0755, $perl;
 
-    diag "(mock) installed $name to $installation_dir";
+    note "(mock) installed $name to $installation_dir";
 }
 
 sub mock_perlbrew_install {

-- 
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to