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

Ruslan Zakirov ruz at bestpractical.com
Mon Jun 1 10:59:44 EDT 2009


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

Summary of changes:
 lib/Test/Chimps/Smoker.pm |   30 ++++++++++++++++++++++--------
 1 files changed, 22 insertions(+), 8 deletions(-)

- Log -----------------------------------------------------------------
commit c714db23a827b9c9e2a6cf1b444e77842446f210
Author: Ruslan Zakirov <Ruslan.Zakirov at gmail.com>
Date:   Mon Jun 1 18:58:57 2009 +0400

    * allow to set values of options using other options

diff --git a/lib/Test/Chimps/Smoker.pm b/lib/Test/Chimps/Smoker.pm
index 762dffa..e2bb662 100644
--- a/lib/Test/Chimps/Smoker.pm
+++ b/lib/Test/Chimps/Smoker.pm
@@ -396,11 +396,6 @@ sub _checkout_project {
       'blib/lib', @{ $project->{libs} || [] };
     $self->meta->{ $project->{'name'} }{'libs'} = [@libs];
 
-    $self->_push_onto_env_stack({
-        $project->{env}? (%{$project->{env}}) : (),
-        'CHIMPS_'. uc($project->{'name'}) .'_ROOT' => $projectdir,
-    });
-
     my @otherlibs;
     if (defined $project->{dependencies}) {
         foreach my $dep (@{$project->{dependencies}}) {
@@ -417,6 +412,11 @@ sub _checkout_project {
         }
     }
 
+    $self->_push_onto_env_stack({
+        $project->{env}? (%{$project->{env}}) : (),
+        'CHIMPS_'. uc($project->{'name'}) .'_ROOT' => $projectdir,
+    });
+
     my %seen;
     @libs = grep {not $seen{$_}++} @libs, @otherlibs;
 
@@ -479,21 +479,35 @@ sub _push_onto_env_stack {
     my $self = shift;
     my $vars = shift;
 
+    my @with_subst = ();
+
     my $frame = {};
-    foreach my $var (keys %$vars) {
+    while ( my ($var, $value) = each %$vars ) {
         if (exists $ENV{$var}) {
             $frame->{$var} = $ENV{$var};
         } else {
             $frame->{$var} = undef;
         }
-        my $value = $vars->{$var};
 
         # old value substitution
-        $value =~ s/\$$var/$ENV{$var}/g;
+        if ( $value =~ /\$/ ) {
+            push @with_subst, $var;
+            next;
+        }
+
+        print "setting environment variable $var to $value\n";
+        $ENV{$var} = $value;
+    }
 
+    for my $var (@with_subst) {
+        my $value = $vars->{$var};
+        while ( my ($use) = ($value =~ /\$(\S+)/) ) {
+            $value =~ s/\$\Q$use/$ENV{$use}/ge;
+        }
         print "setting environment variable $var to $value\n";
         $ENV{$var} = $value;
     }
+
     push @{$self->_env_stack}, $frame;
 }
 

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



More information about the Bps-public-commit mailing list