Class: Purobu::Runner

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRunner

Returns a new instance of Runner.



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

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

Instance Attribute Details

#testsObject (readonly)

Returns the value of attribute tests.



4
5
6
# File 'lib/purobu/runner.rb', line 4

def tests
  @tests
end

#thread_countObject (readonly)

Returns the value of attribute thread_count.



4
5
6
# File 'lib/purobu/runner.rb', line 4

def thread_count
  @thread_count
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
# File 'lib/purobu/runner.rb', line 11

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