Class: DeepTest::Spec::Runner

Inherits:
Spec::Runner::ExampleGroupRunner
  • Object
show all
Defined in:
lib/deep_test/spec/runner.rb

Instance Method Summary collapse

Constructor Details

#initialize(options, deep_test_options, blackboard = nil) ⇒ Runner

Returns a new instance of Runner.



4
5
6
7
8
9
10
# File 'lib/deep_test/spec/runner.rb', line 4

def initialize(options, deep_test_options, blackboard = nil)
  super(options)
  @deep_test_options = DeepTest::Options.from_command_line(deep_test_options)
  DeepTest.init(@deep_test_options)
  @blackboard = blackboard
  @workers = @deep_test_options.new_workers
end

Instance Method Details

#blackboardObject



12
13
14
15
16
17
# File 'lib/deep_test/spec/runner.rb', line 12

def blackboard
  # Can't create blackboard as default argument to initialize
  # because ProcessOrchestrator hasn't been invoked at 
  # instantiation time
  @blackboard ||= @deep_test_options.server
end

#load_files(files) ⇒ Object



19
20
21
# File 'lib/deep_test/spec/runner.rb', line 19

def load_files(files)
  @workers.load_files files
end

#process_work_unitsObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/deep_test/spec/runner.rb', line 27

def process_work_units
  prepare

  examples = example_groups.map {|g| g.send(:examples_to_run)}.flatten
  examples_by_location = {}
  examples.each do |example|
    raise "duplicate example: #{example.identifier}" if examples_by_location[example.identifier]
    examples_by_location[example.identifier] = example
    blackboard.write_work Spec::WorkUnit.new(example.identifier)
  end

  success = true

  missing_exmaples = ResultReader.new(blackboard).read(examples_by_location) do |example, result|
    @options.reporter.example_finished(example, result.error)
    success &= result.success?
  end

  success &= missing_exmaples.empty?

  missing_exmaples.each do |identifier, example|
    @options.reporter.example_finished(example, WorkUnitNeverReceivedError.new)
  end

  success
ensure
  finish
end

#runObject



23
24
25
# File 'lib/deep_test/spec/runner.rb', line 23

def run
  ProcessOrchestrator.run(@deep_test_options, @workers, self)
end