Class: DeepTest::ResultReader

Inherits:
Object
  • Object
show all
Defined in:
lib/deep_test/result_reader.rb

Instance Method Summary collapse

Constructor Details

#initialize(central_command) ⇒ ResultReader

Returns a new instance of ResultReader.



3
4
5
# File 'lib/deep_test/result_reader.rb', line 3

def initialize(central_command)
  @central_command = central_command
end

Instance Method Details

#read(original_work_units_by_id) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/deep_test/result_reader.rb', line 7

def read(original_work_units_by_id)
  work_units_by_id = original_work_units_by_id.dup
  errors = 0

  begin
    until errors == work_units_by_id.size
      Thread.pass
      result = @central_command.take_result
      next if result.nil?

      if Agent::Error === result
        puts result
        errors += 1
      else
        if result.respond_to?(:output) && (output = result.output)
          print output
        end

        work_unit = work_units_by_id.delete(result.identifier)
        yield [work_unit, result]
      end
    end
  rescue CentralCommand::NoAgentsRunningError
    FailureMessage.show "DeepTest Agents Are Not Running", <<-end_msg
      DeepTest's test running agents have not contacted the 
      server to indicate they are still running.
      Shutting down the test run on the assumption that they have died. 
    end_msg
  end

  work_units_by_id
end