Skip to content
This repository has been archived by the owner on Sep 16, 2020. It is now read-only.

Commit

Permalink
Making a build done when all files are done, not all jobs. Prep for #30.
Browse files Browse the repository at this point in the history
  • Loading branch information
joakimk committed Jun 30, 2011
1 parent 5afd608 commit 731de35
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
testbot (0.5.8)
testbot (0.5.9)
acts_as_rails3_generator
daemons (>= 1.0.10)
httparty (>= 0.6.1)
Expand Down
2 changes: 1 addition & 1 deletion lib/server/build.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Testbot::Server
class Build < MemoryModel

def initialize(hash)
super({ :success => true, :done => false, :results => '' }.merge(hash))
super({ :success => true, :done => false, :results => '', :completed_files => [] }.merge(hash))
end

def self.create_and_build_jobs(hash)
Expand Down
6 changes: 4 additions & 2 deletions lib/server/job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ class Job < MemoryModel
def update(hash)
super(hash)
if self.build
done = !Job.all.find { |j| !j.result && j.build == self.build }
all_files = self.build.files.to_s.split
completed_files = self.build.completed_files + self.files.split
done = (all_files.sort == completed_files.sort)
self.build.update(:results => build.results.to_s + self.result.to_s,
:done => done)
:done => done, :completed_files => completed_files.uniq)

build_broken_by_job = (self.success == "false" && build.success)
self.build.update(:success => false) if build_broken_by_job
Expand Down
4 changes: 2 additions & 2 deletions test/server/server_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -392,9 +392,9 @@ def app
end

should "make the related build done if there are no more jobs for the build" do
build = Build.create
build = Build.create :files => 'spec/models/car_spec.rb spec/models/house_spec.rb'
job1 = Job.create :files => 'spec/models/car_spec.rb', :taken_at => Time.now - 30, :build => build
job2 = Job.create :files => 'spec/models/car_spec.rb', :taken_at => Time.now - 30, :build => build
job2 = Job.create :files => 'spec/models/house_spec.rb', :taken_at => Time.now - 30, :build => build
put "/jobs/#{job1.id}", :result => 'test run result 1\n', :success => true
put "/jobs/#{job2.id}", :result => 'test run result 2\n', :success => true
assert_equal true, build.done
Expand Down

0 comments on commit 731de35

Please sign in to comment.