lib/runner/job.rb in testbot-0.5.8 vs lib/runner/job.rb in testbot-0.5.9

- old
+ new

@@ -12,10 +12,11 @@ def jruby? @ruby_interpreter == 'jruby' end 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};" @@ -26,19 +27,30 @@ Server.put("/jobs/#{@id}", :body => { :result => result, :success => success?, :time => run_time }) puts "Job #{@id} finished." end + def kill!(build_id) + if @build_id == build_id && @test_process + # The child process that runs the tests is a shell, we need to kill it's child process + system("pkill -KILL -P #{@test_process.pid}") + @killed = true + end + end + private def measure_run_time start_time = Time.now yield (Time.now - start_time) * 100 end def run_and_return_result(command) - `#{command} 2>&1` + @test_process = open("|#{command} 2>&1", 'r') + output = @test_process.read + @test_process.close + output end def success? $?.exitstatus == 0 end