Class: Purobu::Runner
- Inherits:
-
Object
- Object
- Purobu::Runner
- Defined in:
- lib/purobu/runner.rb
Instance Attribute Summary collapse
-
#tests ⇒ Object
readonly
Returns the value of attribute tests.
-
#thread_count ⇒ Object
readonly
Returns the value of attribute thread_count.
Instance Method Summary collapse
-
#initialize ⇒ Runner
constructor
A new instance of Runner.
- #run ⇒ Object
Constructor Details
#initialize ⇒ Runner
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
#tests ⇒ Object (readonly)
Returns the value of attribute tests.
4 5 6 |
# File 'lib/purobu/runner.rb', line 4 def tests @tests end |
#thread_count ⇒ Object (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
#run ⇒ Object
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 |