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

Ruslan Zakirov ruz at bestpractical.com
Thu May 21 19:58:16 EDT 2009


The branch, master has been updated
       via  46dde7bdc08c1264b5e6ecad878c7bc8f509a16d (commit)
       via  9612b296e4f53193acdc6a4ce0a92fb692351f3f (commit)
       via  4e9b393e0e964f2af38d1f0c80c918c2bbc8d119 (commit)
       via  54e6375782e0f480d7c15268debfd9e9e5ea9a1f (commit)
       via  00472f1bd30a30549d9d76dad9a51b77a05df798 (commit)
       via  c13c21b7893946ed5630e7e218b1e7fbdf2a0ca8 (commit)
       via  c139d531dab7416d05469215adf121ee17c9725e (commit)
       via  686445f0a0701870998b3d95c1e0b0b96b67d55f (commit)
       via  b2fe9beb2a95ddb41b1ff25efeacec051ce61dd8 (commit)
       via  dbd81be81ccf7aac597693ac69476927ff2ff35f (commit)
       via  37956d21eae06f1b526b05971b016502b253fa18 (commit)
      from  3cffdb1702ead19c1f7760cf5eedf442672b3413 (commit)

Summary of changes:
 bin/chimps-smoker.pl          |   47 ++++++++++++----------
 lib/Test/Chimps/Smoker.pm     |   89 +++++++++++++++++++++++++++-------------
 lib/Test/Chimps/Smoker/Git.pm |    8 +++-
 lib/Test/Chimps/Smoker/SVN.pm |   35 +++++-----------
 4 files changed, 103 insertions(+), 76 deletions(-)

- Log -----------------------------------------------------------------
commit 37956d21eae06f1b526b05971b016502b253fa18
Author: Ruslan Zakirov <Ruslan.Zakirov at gmail.com>
Date:   Fri May 22 02:16:55 2009 +0400

    * add --sleep option, docs, make server not mandatory, config never was

diff --git a/bin/chimps-smoker.pl b/bin/chimps-smoker.pl
index fdac216..f76bfb4 100755
--- a/bin/chimps-smoker.pl
+++ b/bin/chimps-smoker.pl
@@ -14,15 +14,17 @@ my $iterations = 'inf';
 my $projects = 'all';
 my $help = 0;
 my $jobs = 1;
+my $sleep = 60;
 
-GetOptions("server|s=s",      \$server,
-           "config_file|c=s", \$config_file,
-           "iterations|i=i",  \$iterations,
-           "projects|p=s",    \$projects,
-           "help|h",          \$help,
-           "jobs|j=i",        \$jobs)
-  || pod2usage(-exitval => 2,
-               -verbose => 1);
+GetOptions(
+    "server|s=s",      \$server,
+    "config_file|c=s", \$config_file,
+    "iterations|i=i",  \$iterations,
+    "projects|p=s",    \$projects,
+    "help|h",          \$help,
+    "jobs|j=i",        \$jobs,
+    "sleep=i",         \$sleep,
+) || pod2usage(-exitval => 2, -verbose => 1);
 
 
 if ($help) {
@@ -31,14 +33,8 @@ if ($help) {
             -noperldoc => 1);
 }
 
-if (! defined $server) {
-  print "You must specify a server to upload results to\n";
-  exit 2;
-}
-
-if (! defined $server) {
-  print "You must specify a configuration file\n";
-  exit 2;
+unless ( defined $server ) {
+  print "No server specified, simulation mode enabled\n";
 }
 
 if ($projects ne 'all') {
@@ -49,11 +45,13 @@ my $poller = Test::Chimps::Smoker->new(
   server      => $server,
   config_file => $config_file,
   jobs        => $jobs,
+  sleep       => $sleep,
 );
 
-$poller->smoke(iterations => $iterations,
-               projects => $projects,
-           );
+$poller->smoke(
+  iterations => $iterations,
+  projects => $projects,
+);
   
 __DATA__
 
@@ -64,7 +62,8 @@ chimps-smoker.pl - continually smoke projects
 =head1 SYNOPSIS
 
 chimps-smoker.pl --server SERVER --config_file CONFIG_FILE
-    [--iterations N] [--projects PROJECT1,PROJECT2,... ] [--jobs n]
+    [--iterations N] [--projects PROJECT1,PROJECT2,... ] [--jobs N]
+    [--sleep N]
 
 This program is a wrapper around Test::Chimps::Smoker, which allows
 you to specify common options on the command line.
@@ -78,7 +77,8 @@ about the configuration file format, see L<Test::Chimps::Smoker>.
 
 =head2 --server, -s
 
-Specifies the full path to the chimps server CGI.
+Specifies the full path to the chimps server CGI. Reports are not sent
+anywhere if it's not provided.
 
 =head1 OPTIONS
 
@@ -97,6 +97,11 @@ is provided, all projects will be smoked.  Defaults to 'all'.
 
 The number of parallel processes to use when running tests.
 
+=head2 --sleep
+
+The number of seconds smoker should sleep between checks for updates.
+Defaults to 60 seconds.
+
 =head1 AUTHOR
 
 Zev Benjamin C<< zev at cpan.org >>

commit dbd81be81ccf7aac597693ac69476927ff2ff35f
Author: Ruslan Zakirov <Ruslan.Zakirov at gmail.com>
Date:   Fri May 22 02:21:20 2009 +0400

    * convert config_file path to absolute, so we can update
      it from anywhere
    * delete server if simulate is true (backwards compatibility)

diff --git a/lib/Test/Chimps/Smoker.pm b/lib/Test/Chimps/Smoker.pm
index 9c3303d..a13e034 100644
--- a/lib/Test/Chimps/Smoker.pm
+++ b/lib/Test/Chimps/Smoker.pm
@@ -4,7 +4,7 @@ use warnings;
 use strict;
 
 use Config;
-use File::Basename;
+use Cwd qw(abs_path);
 use File::Path;
 use File::Temp qw/tempdir/;
 use Params::Validate qw/:all/;
@@ -109,6 +109,13 @@ sub _init {
     foreach my $key (keys %args) {
         $self->{$key} = $args{$key};
     }
+
+    # support simulate for a while
+    delete $self->{'server'} if $args{'simulate'};
+
+    # make it absolute so we can update it later from any dir we're in
+    $self->{'config_file'} = abs_path($self->{'config_file'});
+
     $self->_env_stack([]);
     $self->meta({});
 

commit b2fe9beb2a95ddb41b1ff25efeacec051ce61dd8
Author: Ruslan Zakirov <Ruslan.Zakirov at gmail.com>
Date:   Fri May 22 02:25:08 2009 +0400

    * deprecate simulate, just don't provide server, print notes in simulation

diff --git a/lib/Test/Chimps/Smoker.pm b/lib/Test/Chimps/Smoker.pm
index a13e034..e91d0aa 100644
--- a/lib/Test/Chimps/Smoker.pm
+++ b/lib/Test/Chimps/Smoker.pm
@@ -54,7 +54,9 @@ L</"CONFIGURATION FILE">.
 
 Mandatory.  The URI of the server script to upload the reports to.
 
-=item * simulate
+=item * simulate [DEPRECATED]
+
+[DEPRECATED] Just don't provide server to send files to.
 
 Don't actually submit the smoke reports, just run the tests.  This
 I<does>, however, increment the revision numbers in the config
@@ -223,27 +225,25 @@ sub _smoke_once {
 
     $self->_clean_dbs(@dbs);
 
-    my $client = Test::Chimps::Client->new(
-        archive => $tmpfile,
-        server => $self->server
-      );
+    if ( my $server = $self->server ) {
+        my $client = Test::Chimps::Client->new(
+            archive => $tmpfile, server => $server,
+        );
 
-    my ($status, $msg);
-    if ($self->simulate) {
-        $status = 1;
-    } else {
-        print "Sending smoke report for @{[$self->server]}\n";
-        ($status, $msg) = $client->send;
+        print "Sending smoke report for $server\n";
+        my ($status, $msg) = $client->send;
+        unless ( $status ) {
+            print "Error: the server responded: $msg\n";
+            return 0;
+        }
     }
-
-    if ($status) {
-        print "Sumbitted smoke report for $project revision $revision\n";
-        $self->update_revision_in_config( $project => $revision );
-        return 1;
-    } else {
-        print "Error: the server responded: $msg\n";
-        return 0;
+    else {
+        print "Server is not specified, don't send the report\n";
     }
+
+    print "Done smoking revision $revision of $project\n";
+    $self->update_revision_in_config( $project => $revision );
+    return 1;
 }
 
 sub remove_checkouts {

commit 686445f0a0701870998b3d95c1e0b0b96b67d55f
Author: Ruslan Zakirov <Ruslan.Zakirov at gmail.com>
Date:   Fri May 22 02:27:14 2009 +0400

    * implement sleep option

diff --git a/lib/Test/Chimps/Smoker.pm b/lib/Test/Chimps/Smoker.pm
index e91d0aa..f01d216 100644
--- a/lib/Test/Chimps/Smoker.pm
+++ b/lib/Test/Chimps/Smoker.pm
@@ -67,7 +67,7 @@ file.
 =cut
 
 use base qw/Class::Accessor/;
-__PACKAGE__->mk_ro_accessors(qw/server config_file simulate/);
+__PACKAGE__->mk_ro_accessors(qw/server config_file simulate sleep/);
 __PACKAGE__->mk_accessors(
     qw/_env_stack meta config projects iterations/);
 
@@ -104,6 +104,12 @@ sub _init {
                 regex    => qr/^\d+$/,
                 default  => 1,
               },
+            sleep => {
+                optional => 1,
+                type     => SCALAR,
+                regex    => qr/^\d+$/,
+                default  => 60,
+              },
           },
         called => 'The Test::Chimps::Smoker constructor'
       );
@@ -268,12 +274,12 @@ sub _smoke_n_times {
     } elsif ($n eq 'inf') {
         while (1) {
             $self->_smoke_projects($projects);
-            sleep 60;
+            CORE::sleep $self->sleep if $self->sleep;
         }
     } else {
         for (my $i = 0; $i < $n;) {
             $i++ if $self->_smoke_projects($projects);
-            sleep 60;
+            CORE::sleep $self->sleep if $self->sleep;
         }
     }
 }

commit c139d531dab7416d05469215adf121ee17c9725e
Author: Ruslan Zakirov <Ruslan.Zakirov at gmail.com>
Date:   Fri May 22 02:29:21 2009 +0400

    * don't die on absense of way to connect to a DB

diff --git a/lib/Test/Chimps/Smoker.pm b/lib/Test/Chimps/Smoker.pm
index f01d216..a76cd60 100644
--- a/lib/Test/Chimps/Smoker.pm
+++ b/lib/Test/Chimps/Smoker.pm
@@ -443,8 +443,9 @@ sub _checkout_project {
 
 sub _list_dbs {
     local $ENV{DBI_USER} = "postgres";
+    local $@;
     return map {s/.*dbname=(.*)/$1/ ? $_ : () }
-      DBI->data_sources("Pg");
+      eval { DBI->data_sources("Pg") };
 }
 
 sub _clean_dbs {
@@ -453,6 +454,7 @@ sub _clean_dbs {
     local $ENV{DBI_USER} = "postgres";
     my @dbs = grep {not $skip{$_}}
       _list_dbs();
+    return unless @dbs;
 
     my $dbh = DBI->connect("dbi:Pg:dbname=template1","postgres","",{RaiseError => 1});
     $dbh->do("DROP DATABASE $_") for @dbs;

commit c13c21b7893946ed5630e7e218b1e7fbdf2a0ca8
Author: Ruslan Zakirov <Ruslan.Zakirov at gmail.com>
Date:   Fri May 22 02:30:36 2009 +0400

    * instead of removing checkouts, clean project using ->clean in a source

diff --git a/lib/Test/Chimps/Smoker.pm b/lib/Test/Chimps/Smoker.pm
index a76cd60..836e423 100644
--- a/lib/Test/Chimps/Smoker.pm
+++ b/lib/Test/Chimps/Smoker.pm
@@ -148,7 +148,8 @@ sub load_config {
         }
         DumpFile($self->config_file, $cfg) if $found_old_style;
     }
-
+    
+    # store project name in its hash
     $cfg->{$_}->{'name'} = $_ foreach keys %$cfg;
 }
 
@@ -225,9 +226,7 @@ sub _smoke_once {
 
     $self->_unroll_env_stack;
 
-    chdir(File::Spec->rootdir);
-
-    $self->remove_checkouts;
+    $self->_clean_project( $config );
 
     $self->_clean_dbs(@dbs);
 
@@ -441,6 +440,19 @@ sub _checkout_project {
     return @libs;
 }
 
+sub _clean_project {
+    my $self = shift;
+    my $project = shift;
+
+    $self->source( $project->{'name'} )->clean;
+
+    if (defined $project->{dependencies}) {
+        foreach my $dep (@{$project->{dependencies}}) {
+            $self->_clean_project( $self->config->{ $dep } );
+        }
+    }
+}
+
 sub _list_dbs {
     local $ENV{DBI_USER} = "postgres";
     local $@;

commit 00472f1bd30a30549d9d76dad9a51b77a05df798
Author: Ruslan Zakirov <Ruslan.Zakirov at gmail.com>
Date:   Fri May 22 02:31:52 2009 +0400

    * oops, wrong reg exp for commit :)

diff --git a/lib/Test/Chimps/Smoker/Git.pm b/lib/Test/Chimps/Smoker/Git.pm
index 2b29b64..7919009 100644
--- a/lib/Test/Chimps/Smoker/Git.pm
+++ b/lib/Test/Chimps/Smoker/Git.pm
@@ -10,7 +10,7 @@ sub revision_after {
     my $revision = shift;
 
     my $cmd = "git log --reverse $revision..origin";
-    my ($next)  = (`$cmd` =~ m/^commit\s+([a-f0-9])/im);
+    my ($next)  = (`$cmd` =~ m/^commit\s+([a-f0-9]+)$/im);
 
     return $next;
 }

commit 54e6375782e0f480d7c15268debfd9e9e5ea9a1f
Author: Ruslan Zakirov <Ruslan.Zakirov at gmail.com>
Date:   Fri May 22 02:36:20 2009 +0400

    * a code is note cloned if we remove checkout

diff --git a/lib/Test/Chimps/Smoker.pm b/lib/Test/Chimps/Smoker.pm
index 836e423..8f7ca57 100644
--- a/lib/Test/Chimps/Smoker.pm
+++ b/lib/Test/Chimps/Smoker.pm
@@ -260,6 +260,7 @@ sub remove_checkouts {
 
         _remove_tmpdir($dir);
         $source->directory(undef);
+        $source->cloned(0);
     }
 }
 

commit 4e9b393e0e964f2af38d1f0c80c918c2bbc8d119
Author: Ruslan Zakirov <Ruslan.Zakirov at gmail.com>
Date:   Fri May 22 02:37:03 2009 +0400

    * implement ->clean in git

diff --git a/lib/Test/Chimps/Smoker/Git.pm b/lib/Test/Chimps/Smoker/Git.pm
index 7919009..4cd2a57 100644
--- a/lib/Test/Chimps/Smoker/Git.pm
+++ b/lib/Test/Chimps/Smoker/Git.pm
@@ -34,6 +34,12 @@ sub clone {
     return 1;
 }
 
+sub clean {
+    my $self = shift;
+    system qw(git clean -fd);
+    system qw(git checkout master);
+}
+
 sub checkout {
     my $self = shift;
     my %args = @_;

commit 9612b296e4f53193acdc6a4ce0a92fb692351f3f
Author: Ruslan Zakirov <Ruslan.Zakirov at gmail.com>
Date:   Fri May 22 03:39:25 2009 +0400

    * correctly put envs on stack

diff --git a/lib/Test/Chimps/Smoker.pm b/lib/Test/Chimps/Smoker.pm
index 8f7ca57..cc265bb 100644
--- a/lib/Test/Chimps/Smoker.pm
+++ b/lib/Test/Chimps/Smoker.pm
@@ -396,7 +396,10 @@ sub _checkout_project {
       'blib/lib', @{ $project->{libs} || [] };
     $self->meta->{ $project->{'name'} }{'libs'} = [@libs];
 
-    $self->_push_onto_env_stack($project->{env}, 'CHIMPS_'. uc($project->{'name'}) .'_ROOT' => $projectdir);
+    $self->_push_onto_env_stack({
+        $project->{env}? (%{$project->{env}}) : (),
+        'CHIMPS_'. uc($project->{'name'}) .'_ROOT' => $projectdir,
+    });
 
     my @otherlibs;
     if (defined $project->{dependencies}) {

commit 46dde7bdc08c1264b5e6ecad878c7bc8f509a16d
Author: Ruslan Zakirov <Ruslan.Zakirov at gmail.com>
Date:   Fri May 22 03:39:44 2009 +0400

    * implement ->clean for svn, simplify ->next

diff --git a/lib/Test/Chimps/Smoker/SVN.pm b/lib/Test/Chimps/Smoker/SVN.pm
index 4121eb5..8e0f963 100644
--- a/lib/Test/Chimps/Smoker/SVN.pm
+++ b/lib/Test/Chimps/Smoker/SVN.pm
@@ -24,12 +24,6 @@ sub committer {
     return ($self->revision_info( @_ ))[2];
 }
 
-sub is_change_on_revision {
-    my $self = shift;
-    my ($latest_revision, $last_changed) = $self->revision_info(@_);
-    return $latest_revision == $last_changed;
-}
-
 sub checkout {
     my $self = shift;
     my %args = @_;
@@ -37,29 +31,20 @@ sub checkout {
     system("svn", "co", "-r", ($args{'revision'} || 'HEAD'), $self->uri, $self->directory);
 }
 
-sub next {
+sub clean {
     my $self = shift;
-    my ($latest_revision, $last_changed_revision) = $self->revision_info;
-
-    my $old_revision = $self->config->{revision};
-
-    return () unless $last_changed_revision > $old_revision;
-
-    my @revisions = (($old_revision + 1) .. $latest_revision);
-    my $revision;
-    while (@revisions) {
-        $revision = shift @revisions;
-
-# only actually do the check out if the revision and last changed revision match for
-# a particular revision
-        last if $self->is_change_on_revision($revision);
-    }
-    return () unless $revision;
+    system(qw(svn revert -R .));
+}
 
-    my $committer = $self->committer($revision);
+sub next {
+    my $self = shift;
 
+    my $revision = $self->config->{revision};
+    my $cmd = "svn log -l1 -q -r $revision:HEAD ". $self->uri;
+    my ($next, $committer) = (`$cmd` =~ m/^r([0-9]+)\s+\|\s*.*?\s*\|/m);
+    return () unless $next;
 
-    return (revision => $revision, committer => $committer);
+    return (revision => $next, committer => $committer);
 }
 
 1;

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



More information about the Bps-public-commit mailing list