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

Ruslan Zakirov ruz at bestpractical.com
Wed May 20 08:32:00 EDT 2009


The branch, master has been updated
       via  6a7a7cb7e1626c92eca868df4917363816c27a63 (commit)
       via  afef526f0e437bfa9a233939b86d9cb3accbb7b8 (commit)
       via  3d2c2a861da6ec6e4f777913637ae866694450b9 (commit)
       via  efea9725b3278a2119d08ca3242cf68ca9c51680 (commit)
      from  0fcf2e1cae5ae78c73710de19af1f05ecb5d8507 (commit)

Summary of changes:
 lib/Test/Chimps/Smoker.pm |   78 +++++++++++++++++++++++++++++----------------
 t/05-client-basic.t       |    1 +
 2 files changed, 51 insertions(+), 28 deletions(-)

- Log -----------------------------------------------------------------
commit efea9725b3278a2119d08ca3242cf68ca9c51680
Author: Ruslan Zakirov <Ruslan.Zakirov at gmail.com>
Date:   Wed May 20 13:54:57 2009 +0400

    * make config and checkout_paths not private
    * make checkout_paths a hash
    * deal with recursive dependencies and multiple project depending on one thing

diff --git a/lib/Test/Chimps/Smoker.pm b/lib/Test/Chimps/Smoker.pm
index 56f4953..013e424 100644
--- a/lib/Test/Chimps/Smoker.pm
+++ b/lib/Test/Chimps/Smoker.pm
@@ -66,7 +66,7 @@ file.
 use base qw/Class::Accessor/;
 __PACKAGE__->mk_ro_accessors(qw/server config_file simulate/);
 __PACKAGE__->mk_accessors(
-  qw/_env_stack _checkout_paths _config projects iterations/);
+  qw/_env_stack checkout_paths config projects iterations/);
 
 # add a signal handler so destructor gets run
 $SIG{INT} = sub {print "caught sigint.  cleaning up...\n"; exit(1)};
@@ -109,14 +109,30 @@ sub _init {
     $self->{$key} = $args{$key};
   }
   $self->_env_stack([]);
-  $self->_checkout_paths([]);
+  $self->checkout_paths({});
 
-  $self->_config(LoadFile($self->config_file));
+  $self->load_config;
+}
+
+sub load_config {
+    my $self = shift;
+
+    my $cfg = $self->config(LoadFile($self->config_file));
+    $cfg->{$_}->{'name'} = $_ foreach keys %$cfg;
+}
+
+sub update_revision {
+    my $self = shift;
+    my ($project, $revision) = @_;
+
+    my $tmp = LoadFile($self->config_file));
+    $tmp->{$project}->{revision} = $self->config->{$project}->{revision} = $revision;
+    DumpFile($self->config_file, $tmp);
 }
 
 sub DESTROY {
   my $self = shift;
-  foreach my $tmpdir (@{$self->_checkout_paths}) {
+  foreach my $tmpdir (values %{$self->checkout_paths}) {
     _remove_tmpdir($tmpdir);
   }
 }
@@ -124,7 +140,7 @@ sub DESTROY {
 sub _smoke_once {
   my $self = shift;
   my $project = shift;
-  my $config = $self->_config;
+  my $config = $self->config;
 
   return 1 if $config->{$project}->{dependency_only};
 
@@ -154,9 +170,9 @@ sub _smoke_once {
   my @libs = $self->_checkout_project($config->{$project}, $revision);
   unless (@libs) {
     print "Skipping report report for $project revision $revision due to build failure\n";
-    $self->_config(LoadFile($self->config_file));
-    $self->_config->{$project}->{revision} = $revision;
-    DumpFile($self->config_file, $self->_config);
+    $self->config(LoadFile($self->config_file));
+    $self->config->{$project}->{revision} = $revision;
+    DumpFile($self->config_file, $self->config);
     return 0;
   }
   my @dbs = $self->_list_dbs;
@@ -188,10 +204,10 @@ sub _smoke_once {
 
   chdir(File::Spec->rootdir);
 
-  foreach my $tmpdir (@{$self->_checkout_paths}) {
+  foreach my $tmpdir (values %{$self->checkout_paths}) {
     _remove_tmpdir($tmpdir);
   }
-  $self->_checkout_paths([]);
+  $self->checkout_paths({});
 
   $self->_clean_dbs(@dbs);
 
@@ -210,9 +226,7 @@ sub _smoke_once {
 
   if ($status) {
     print "Sumbitted smoke report for $project revision $revision\n";
-    $self->_config(LoadFile($self->config_file));
-    $self->_config->{$project}->{revision} = $revision;
-    DumpFile($self->config_file, $self->_config);
+    $self->update_revision( $project => $revision );
     return 1;
   } else {
     print "Error: the server responded: $msg\n";
@@ -243,7 +257,6 @@ sub _smoke_n_times {
 sub _smoke_projects {
   my $self = shift;
   my $projects = shift;
-  my $config = $self->_config;
 
   foreach my $project (@$projects) {
     $self->_smoke_once($project);
@@ -279,7 +292,7 @@ projects will be smoked.  Defaults to 'all'.
 
 sub smoke {
   my $self = shift;
-  my $config = $self->_config;
+  my $config = $self->config;
 
   my %args = validate_with(
     params => \@_,
@@ -317,7 +330,7 @@ sub _validate_projects_opt {
 
   foreach my $project (@$projects) {
     die "no such project: '$project'"
-      unless exists $self->_config->{$project};
+      unless exists $self->config->{$project};
   }
 }
 
@@ -327,7 +340,7 @@ sub _checkout_project {
   my $revision = shift;
 
   my $tmpdir = tempdir("chimps-svn-XXXXXXX", TMPDIR => 1);
-  unshift @{$self->_checkout_paths}, $tmpdir;
+  $self->checkout_paths->{ $project->{'name'} } = $tmpdir;
 
   system("svn", "co", "-r", $revision, $project->{svn_uri}, $tmpdir);
 
@@ -338,8 +351,10 @@ sub _checkout_project {
   my @otherlibs;
   if (defined $project->{dependencies}) {
     foreach my $dep (@{$project->{dependencies}}) {
+      next if $self->checkout_paths->{ $dep };
+
       print "processing dependency $dep\n";
-      my @deplibs = $self->_checkout_project($self->_config->{$dep}, 'HEAD');
+      my @deplibs = $self->_checkout_project($self->config->{$dep}, 'HEAD');
       if (@deplibs) {
           push @otherlibs, @deplibs;
       } else {
diff --git a/t/05-client-basic.t b/t/05-client-basic.t
index 33c9253..b164e4c 100644
--- a/t/05-client-basic.t
+++ b/t/05-client-basic.t
@@ -4,6 +4,7 @@ use Test::More tests => 6;
 
 BEGIN {
   use_ok( 'Test::Chimps::Client' );
+  use_ok( 'Test::TAP::Model::Visual' );
 }
 
 my $m = Test::TAP::Model::Visual->new_with_tests('t-data/bogus-tests/00-basic.t');

commit 3d2c2a861da6ec6e4f777913637ae866694450b9
Author: Ruslan Zakirov <Ruslan.Zakirov at gmail.com>
Date:   Wed May 20 13:59:29 2009 +0400

    * use update_revision thing

diff --git a/lib/Test/Chimps/Smoker.pm b/lib/Test/Chimps/Smoker.pm
index 013e424..5c8e2c1 100644
--- a/lib/Test/Chimps/Smoker.pm
+++ b/lib/Test/Chimps/Smoker.pm
@@ -170,9 +170,7 @@ sub _smoke_once {
   my @libs = $self->_checkout_project($config->{$project}, $revision);
   unless (@libs) {
     print "Skipping report report for $project revision $revision due to build failure\n";
-    $self->config(LoadFile($self->config_file));
-    $self->config->{$project}->{revision} = $revision;
-    DumpFile($self->config_file, $self->config);
+    $self->update_revision( $project => $revision );
     return 0;
   }
   my @dbs = $self->_list_dbs;

commit afef526f0e437bfa9a233939b86d9cb3accbb7b8
Author: Ruslan Zakirov <Ruslan.Zakirov at gmail.com>
Date:   Wed May 20 16:23:45 2009 +0400

    * add remove_checkouts method
    * replace checkout_paths with meta that holds all info we need
    * store checkout, root and libs in the meta

diff --git a/lib/Test/Chimps/Smoker.pm b/lib/Test/Chimps/Smoker.pm
index 5c8e2c1..faaf2d2 100644
--- a/lib/Test/Chimps/Smoker.pm
+++ b/lib/Test/Chimps/Smoker.pm
@@ -66,7 +66,7 @@ file.
 use base qw/Class::Accessor/;
 __PACKAGE__->mk_ro_accessors(qw/server config_file simulate/);
 __PACKAGE__->mk_accessors(
-  qw/_env_stack checkout_paths config projects iterations/);
+  qw/_env_stack meta config projects iterations/);
 
 # add a signal handler so destructor gets run
 $SIG{INT} = sub {print "caught sigint.  cleaning up...\n"; exit(1)};
@@ -109,7 +109,7 @@ sub _init {
     $self->{$key} = $args{$key};
   }
   $self->_env_stack([]);
-  $self->checkout_paths({});
+  $self->meta({});
 
   $self->load_config;
 }
@@ -131,10 +131,8 @@ sub update_revision {
 }
 
 sub DESTROY {
-  my $self = shift;
-  foreach my $tmpdir (values %{$self->checkout_paths}) {
-    _remove_tmpdir($tmpdir);
-  }
+    my $self = shift;
+    $self->remove_checkouts;
 }
 
 sub _smoke_once {
@@ -202,10 +200,7 @@ sub _smoke_once {
 
   chdir(File::Spec->rootdir);
 
-  foreach my $tmpdir (values %{$self->checkout_paths}) {
-    _remove_tmpdir($tmpdir);
-  }
-  $self->checkout_paths({});
+  $self->remove_checkouts;
 
   $self->_clean_dbs(@dbs);
 
@@ -232,6 +227,16 @@ sub _smoke_once {
   }
 }
 
+sub remove_checkouts {
+    my $self = shift;
+
+    my $meta = $self->meta;
+    foreach my $tmpdir (grep length && defined, map $_->{'checkout'}, values %$meta ) {
+        _remove_tmpdir($tmpdir);
+    }
+    delete @{$_}{'checkout'} foreach values %$meta;
+}
+
 sub _smoke_n_times {
   my $self = shift;
   my $n = shift;
@@ -338,18 +343,26 @@ sub _checkout_project {
   my $revision = shift;
 
   my $tmpdir = tempdir("chimps-svn-XXXXXXX", TMPDIR => 1);
-  $self->checkout_paths->{ $project->{'name'} } = $tmpdir;
+  $self->meta->{ $project->{'name'} }{'checkout'} = $tmpdir;
 
   system("svn", "co", "-r", $revision, $project->{svn_uri}, $tmpdir);
 
   $self->_push_onto_env_stack($project->{env});
 
-  my $projectdir = File::Spec->catdir($tmpdir, $project->{root_dir});
+  my $projectdir = $self->meta->{ $project->{'name'} }{'root'}
+    = File::Spec->catdir($tmpdir, $project->{root_dir});
+
+  my @libs = map File::Spec->catdir($projectdir, $_),
+    'blib/lib', @{ $project->{libs} || [] };
+  $self->meta->{ $project->{'name'} }{'libs'} = [@libs];
 
   my @otherlibs;
   if (defined $project->{dependencies}) {
     foreach my $dep (@{$project->{dependencies}}) {
-      next if $self->checkout_paths->{ $dep };
+      if ( $self->meta->{ $dep }{'checkout'} ) {
+          push @otherlibs, @{ $self->meta->{ $dep }{'libs'} };
+          next;
+      }
 
       print "processing dependency $dep\n";
       my @deplibs = $self->_checkout_project($self->config->{$dep}, 'HEAD');
@@ -362,10 +375,6 @@ sub _checkout_project {
     }
   }
 
-  my @libs = qw{blib/lib};
-  push @libs, @{$project->{libs}} if $project->{libs};
-  @libs = map {File::Spec->catdir($tmpdir, $project->{root_dir}, $_)} @libs;
-
   my %seen;
   @libs = grep {not $seen{$_}++} @libs, @otherlibs;
 

commit 6a7a7cb7e1626c92eca868df4917363816c27a63
Author: Ruslan Zakirov <Ruslan.Zakirov at gmail.com>
Date:   Wed May 20 16:30:47 2009 +0400

    * typo

diff --git a/lib/Test/Chimps/Smoker.pm b/lib/Test/Chimps/Smoker.pm
index faaf2d2..fff9fe0 100644
--- a/lib/Test/Chimps/Smoker.pm
+++ b/lib/Test/Chimps/Smoker.pm
@@ -125,7 +125,7 @@ sub update_revision {
     my $self = shift;
     my ($project, $revision) = @_;
 
-    my $tmp = LoadFile($self->config_file));
+    my $tmp = LoadFile($self->config_file);
     $tmp->{$project}->{revision} = $self->config->{$project}->{revision} = $revision;
     DumpFile($self->config_file, $tmp);
 }

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



More information about the Bps-public-commit mailing list