summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJonathan "Duke" Leto <jonathan@leto.net>2011-01-05 12:30:35 -0800
committerJonathan "Duke" Leto <jonathan@leto.net>2011-01-05 12:30:35 -0800
commitfb555a86932dcb5dc1252f44e3100de590ec9830 (patch)
treeebff7d9092da33dc28d456e707988d55ef90ae4f /lib
parentAdd some useful debug info for the logs (diff)
downloadjitterbug-fb555a86932dcb5dc1252f44e3100de590ec9830.tar.gz
Improve debug info and add some basic jitterbug::Builder tests
Diffstat (limited to 'lib')
-rw-r--r--lib/jitterbug/Builder.pm19
1 files changed, 13 insertions, 6 deletions
diff --git a/lib/jitterbug/Builder.pm b/lib/jitterbug/Builder.pm
index 3b45eaa..bfcb6c7 100644
--- a/lib/jitterbug/Builder.pm
+++ b/lib/jitterbug/Builder.pm
@@ -11,8 +11,10 @@ use Getopt::Long qw/:config no_ignore_case/;
use File::Basename;
use Git::Repository;
use jitterbug::Schema;
+#use Data::Dumper;
local $| = 1;
+use constant DEBUG => 1;
sub new {
my $self = bless {} => shift;
@@ -29,13 +31,17 @@ sub new {
return $self;
}
+sub debug {
+ warn @_ if DEBUG;
+}
+
sub run {
my $self = shift || die "Must call run() from object\n";
my $conf = $self->{'conf'} = LoadFile( $self->{'configfile'} );
my $dbix_conf = $conf->{'plugins'}{'DBIC'}{'schema'};
- warn "Loaded config file: " . $self->{'conf'};
- warn "Connection Info: " . @{ $dbix_conf->{'connect_info'} };
+ debug("Loaded config file: " . $self->{'configfile'});
+ debug("Connection Info: " . join ':', @{ $dbix_conf->{'connect_info'} });
$self->{'schema'} = jitterbug::Schema->connect( @{ $dbix_conf->{'connect_info'} } );
$self->{'interval'} = $self->{'sleep'} ||
@@ -65,7 +71,7 @@ sub build {
sub sleep {
my ($self, $interval) = @_;
$interval ||= $self->{'interval'};
- warn "sleeping for $interval seconds\n";
+ debug("sleeping for $interval seconds\n");
sleep $interval;
}
@@ -93,7 +99,8 @@ sub run_task {
my $repo = $task->project->url . '.git';
my $r = Git::Repository->create( clone => $repo => $build_dir );
- warn "Checking out " . $task->commit->sha256 . " from $repo into $build_dir";
+
+ debug("Checking out " . $task->commit->sha256 . " from $repo into $build_dir\n");
$r->run( 'checkout', $task->commit->sha256 );
my $builder = $conf->{'jitterbug'}{'build_process'}{'builder'};
@@ -130,10 +137,10 @@ sub run_task {
$task->commit->update( {
content => JSON::encode_json($desc),
} );
- warn "Task completed for " . $task->commit->sha256 . "\n";
+ debug("Task completed for " . $task->commit->sha256 . "\n");
$task->delete();
- warn "Task removed from " . $task->project->name . "\n";
+ debug("Task removed from " . $task->project->name . "\n");
}