[Bps-public-commit] Test-Chimps-Client branch, master, updated. 9d6df096c00cfe4f02ad6cd6dc5627be048313bc

Ruslan Zakirov ruz at bestpractical.com
Fri May 29 17:06:35 EDT 2009


The branch, master has been updated
       via  9d6df096c00cfe4f02ad6cd6dc5627be048313bc (commit)
      from  afd941cd781e1659d09189a456d2a9b0813419b5 (commit)

Summary of changes:
 lib/Test/Chimps/Smoker.pm        |   21 +++++++++------------
 lib/Test/Chimps/Smoker/Source.pm |   11 +++++++++++
 2 files changed, 20 insertions(+), 12 deletions(-)

- Log -----------------------------------------------------------------
commit 9d6df096c00cfe4f02ad6cd6dc5627be048313bc
Author: Ruslan Zakirov <Ruslan.Zakirov at gmail.com>
Date:   Sat May 30 01:06:03 2009 +0400

    * add chdir to the source class, chdir on clean

diff --git a/lib/Test/Chimps/Smoker.pm b/lib/Test/Chimps/Smoker.pm
index 03e435d..762dffa 100644
--- a/lib/Test/Chimps/Smoker.pm
+++ b/lib/Test/Chimps/Smoker.pm
@@ -367,15 +367,13 @@ sub _clone_project {
 
     my $source = $self->source( $project->{'name'} );
     if ( $source->cloned ) {
-        chdir $source->directory
-            or die "Couldn't change dir to ". $source->directory .": $!";
+        $source->chdir;
         return 1;
     }
 
     my $tmpdir = tempdir("chimps-XXXXXXX", TMPDIR => 1);
     $source->directory( $tmpdir );
-    chdir $source->directory
-        or die "Couldn't change dir to ". $source->directory .": $!";
+    $source->chdir;
     $source->clone;
 
     $source->cloned(1);
@@ -389,11 +387,10 @@ sub _checkout_project {
     my $revision = shift;
 
     my $source = $self->source( $project->{'name'} );
-    my $co_dir = $source->directory;
-    chdir $co_dir or die "Couldn't change dir to $co_dir: $!";
+    $source->chdir;
     $source->checkout( revision => $revision );
 
-    my $projectdir = File::Spec->catdir($co_dir, $project->{root_dir});
+    my $projectdir = File::Spec->catdir($source->directory, $project->{root_dir});
 
     my @libs = map File::Spec->catdir($projectdir, $_),
       'blib/lib', @{ $project->{libs} || [] };
@@ -423,10 +420,7 @@ sub _checkout_project {
     my %seen;
     @libs = grep {not $seen{$_}++} @libs, @otherlibs;
 
-    unless (chdir($projectdir)) {
-        print "chdir to $projectdir failed -- check value of root_dir?\n";
-        return ();
-    }
+    $source->chdir($project->{root_dir});
 
     local $ENV{PERL5LIB} = join(":", at libs,$ENV{PERL5LIB});
 
@@ -457,6 +451,9 @@ sub _clean_project {
     my $self = shift;
     my $project = shift;
 
+    my $source = $self->source( $project->{'name'} );
+    $source->chdir;
+
     if (defined( my $cmd = $project->{'clean_cmd'} )) {
         my @args = (
             '--project', $project->{'name'},
@@ -469,7 +466,7 @@ sub _clean_project {
         close $fh;
     }
 
-    $self->source( $project->{'name'} )->clean;
+    $source->clean;
 
     if (defined $project->{dependencies}) {
         foreach my $dep (@{$project->{dependencies}}) {
diff --git a/lib/Test/Chimps/Smoker/Source.pm b/lib/Test/Chimps/Smoker/Source.pm
index 2231bd4..45d913d 100644
--- a/lib/Test/Chimps/Smoker/Source.pm
+++ b/lib/Test/Chimps/Smoker/Source.pm
@@ -39,4 +39,15 @@ sub run_cmd {
     return 1;
 }
 
+sub chdir {
+    my $self = shift;
+    my $sub = shift;
+    my $dir = $self->directory;
+    if ( defined $sub && length $sub ) {
+        $dir = File::Spec->catdir( $dir, $sub );
+    }
+    CORE::chdir($dir)
+        or die "Couldn't change dir to '$dir': $!";
+}
+
 1;

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list