Class: DohTest::MasterRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/dohtest/master_runner.rb

Instance Method Summary collapse

Constructor Details

#initialize(output, config, paths) ⇒ MasterRunner

Returns a new instance of MasterRunner.



7
8
9
# File 'lib/dohtest/master_runner.rb', line 7

def initialize(output, config, paths)
  @output, @config, @paths = output, config, paths
end

Instance Method Details

#runObject



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
39
40
# File 'lib/dohtest/master_runner.rb', line 11

def run
  start_time = Time.now
  @config[:pre_test_callback].each do |callback|
    callback.call(@output)
  end
  if @paths.empty?
    unless DohTest.require_paths(@config[:glob], ['.'])
      DohTest.require_paths(@config[:glob], [@config[:root]])
    end
  else
    DohTest.require_paths(@config[:glob], @paths)
  end

  srand(@config[:seed])
  @output.run_begin(@config)
  total_problems = 0
  # sort them to be the same order no matter what (different machines were returning different results)
  TestGroup.descendants.sort{|a,b|a.to_s<=>b.to_s}.shuffle.each do |group_class|
    runner = GroupRunner.new(group_class, @output, @config)
    brink_hit = runner.run
    total_problems += runner.total_problems
    break if brink_hit
  end
  @config[:post_all_callback].each do |proc|
    if !proc.call(total_problems)
      @output.callback_failed(proc.inspect)
    end
  end
  @output.run_end(Time.now - start_time)
end