Class: Lax::Runner
- Inherits:
-
Object
- Object
- Lax::Runner
- Defined in:
- lib/lax/runner.rb
Overview
Runner for test cases. Handles callbacks, concurrency, etc. TODO: DRb support!
Instance Attribute Summary collapse
-
#cases ⇒ Object
readonly
Returns the value of attribute cases.
Instance Method Summary collapse
- #go ⇒ Object
-
#initialize(cases, opts = {}) ⇒ Runner
constructor
Takes an array of test cases and an optional hash of options.
Constructor Details
#initialize(cases, opts = {}) ⇒ Runner
Takes an array of test cases and an optional hash of options.
7 8 9 |
# File 'lib/lax/runner.rb', line 7 def initialize(cases, opts={}) @cases, @opts = cases, {threads: 1}.merge(opts) end |
Instance Attribute Details
#cases ⇒ Object (readonly)
Returns the value of attribute cases.
5 6 7 |
# File 'lib/lax/runner.rb', line 5 def cases @cases end |
Instance Method Details
#go ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/lax/runner.rb', line 11 def go (start=@opts[:start]) and start[self] todo = @cases.dup (1..@opts[:threads]).map do Thread.new {after run before todo.shift while todo.any?} end.each &:join (finish=@opts[:finish]) and finish[self] self end |