Class: Purobu::Runner

Inherits:
Object
  • Object
show all
Includes:
HerokuHelpers
Defined in:
lib/purobu/runner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from HerokuHelpers

#heroku, #heroku_api

Constructor Details

#initializeRunner

Returns a new instance of Runner.



8
9
10
11
# File 'lib/purobu/runner.rb', line 8

def initialize
  @tests        = Queue.new
  @thread_count = Configuration.thread_count || 1
end

Instance Attribute Details

#testsObject (readonly)

Returns the value of attribute tests.



6
7
8
# File 'lib/purobu/runner.rb', line 6

def tests
  @tests
end

#thread_countObject (readonly)

Returns the value of attribute thread_count.



6
7
8
# File 'lib/purobu/runner.rb', line 6

def thread_count
  @thread_count
end

Instance Method Details

#runObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/purobu/runner.rb', line 13

def run
  Purobu.log(global_setup: true) do
    run_global_setup
  end
  pool = Array.new(thread_count) do
    Thread.new do
      loop do
        begin
          test = tests.pop(true)
          test.run
          test.report_result
        rescue
          Thread.exit
        end
      end
    end
  end
  pool.each(&:join)
  Purobu.log(global_teardown: true) do
    run_global_teardown
  end
end