lib/pbt/check/runner_methods.rb in pbt-0.1.0 vs lib/pbt/check/runner_methods.rb in pbt-0.1.1
- old
+ new
@@ -73,26 +73,43 @@
# @return [RunExecution] Result of the test.
def run_it(property, source_values, config)
runner = Check::RunnerIterator.new(source_values, property, config[:verbose])
while runner.has_next?
case config[:worker]
+ in :none
+ run_it_in_sequential(property, runner)
in :ractor
run_it_in_ractors(property, runner)
in :process
run_it_in_processes(property, runner)
in :thread
run_it_in_threads(property, runner)
- in :none
- run_it_in_sequential(property, runner)
end
end
runner.run_execution
end
# @param property [Proc]
# @param runner [RunnerIterator]
# @return [void]
+ def run_it_in_sequential(property, runner)
+ runner.each_with_index do |val, index|
+ c = Case.new(val:, index:)
+ begin
+ property.run(val)
+ runner.handle_result(c)
+ rescue => e
+ c.exception = e
+ runner.handle_result(c)
+ break # Ignore the rest of the cases. Just pick up the first failure.
+ end
+ end
+ end
+
+ # @param property [Proc]
+ # @param runner [RunnerIterator]
+ # @return [void]
def run_it_in_ractors(property, runner)
runner.map.with_index { |val, index|
Case.new(val:, index:, ractor: property.run_in_ractor(val))
}.each do |c|
c.ractor.take
@@ -141,26 +158,9 @@
end
end.each do |c|
runner.handle_result(c)
break if c.exception
# Ignore the rest of the cases. Just pick up the first failure.
- end
- end
-
- # @param property [Proc]
- # @param runner [RunnerIterator]
- # @return [void]
- def run_it_in_sequential(property, runner)
- runner.each_with_index do |val, index|
- c = Case.new(val:, index:)
- begin
- property.run(val)
- runner.handle_result(c)
- rescue => e
- c.exception = e
- runner.handle_result(c)
- break # Ignore the rest of the cases. Just pick up the first failure.
- end
end
end
# Load Parallel gem. If it's not installed, raise an error.
# @see https://github.com/grosser/parallel