Class: Testbot::Runner::Job
- Inherits:
-
Object
- Object
- Testbot::Runner::Job
- Defined in:
- lib/runner/job.rb
Constant Summary collapse
- TIME_TO_WAIT_BETWEEN_POSTING_RESULTS =
5
Instance Attribute Summary collapse
-
#build_id ⇒ Object
readonly
Returns the value of attribute build_id.
-
#project ⇒ Object
readonly
Returns the value of attribute project.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
-
#initialize(runner, id, build_id, project, root, type, ruby_interpreter, files) ⇒ Job
constructor
A new instance of Job.
- #jruby? ⇒ Boolean
- #kill!(build_id) ⇒ Object
- #run(instance) ⇒ Object
Constructor Details
#initialize(runner, id, build_id, project, root, type, ruby_interpreter, files) ⇒ Job
Returns a new instance of Job.
11 12 13 14 15 |
# File 'lib/runner/job.rb', line 11 def initialize(runner, id, build_id, project, root, type, ruby_interpreter, files) @runner, @id, @build_id, @project, @root, @type, @ruby_interpreter, @files = runner, id, build_id, project, root, type, ruby_interpreter, files @success = true end |
Instance Attribute Details
#build_id ⇒ Object (readonly)
Returns the value of attribute build_id.
7 8 9 |
# File 'lib/runner/job.rb', line 7 def build_id @build_id end |
#project ⇒ Object (readonly)
Returns the value of attribute project.
7 8 9 |
# File 'lib/runner/job.rb', line 7 def project @project end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
7 8 9 |
# File 'lib/runner/job.rb', line 7 def root @root end |
Instance Method Details
#jruby? ⇒ Boolean
17 18 19 |
# File 'lib/runner/job.rb', line 17 def jruby? @ruby_interpreter == 'jruby' end |
#kill!(build_id) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/runner/job.rb', line 37 def kill!(build_id) if @build_id == build_id && @pid kill_processes @killed = true end end |
#run(instance) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/runner/job.rb', line 21 def run(instance) return if @killed puts "Running job #{@id} (build #{@build_id})... " test_env_number = (instance == 0) ? '' : instance + 1 result = "\n#{`hostname`.chomp}:#{Dir.pwd}\n" base_environment = "export RAILS_ENV=test; export TEST_ENV_NUMBER=#{test_env_number}; cd #{@project};" adapter = Adapter.find(@type) run_time = measure_run_time do result += run_and_return_result("#{base_environment} #{adapter.command(@project, ruby_cmd, @files)}") end Server.put("/jobs/#{@id}", :body => { :result => SafeResultText.clean(result), :status => status, :time => run_time }) puts "Job #{@id} finished." end |