changelog shortlog tags changeset manifest revisions annotate raw

vendor/plugins/rspec/examples/pure/multi_threaded_behaviour_runner.rb

changeset 15: 64acf98d15f4
author: moriq@moriq.com
date: Mon Mar 10 10:12:58 2008 +0900 (16 years ago)
permissions: -rw-r--r--
description: add plugins rspec
1class MultiThreadedExampleGroupRunner < Spec::Runner::ExampleGroupRunner
2 def initialize(options, arg)
3 super(options)
4 # configure these
5 @thread_count = 4
6 @thread_wait = 0
7 end
8
9 def run
10 @threads = []
11 q = Queue.new
12 example_groups.each { |b| q << b}
13 success = true
14 @thread_count.times do
15 @threads << Thread.new(q) do |queue|
16 while not queue.empty?
17 example_group = queue.pop
18 success &= example_group.suite.run(nil)
19 end
20 end
21 sleep @thread_wait
22 end
23 @threads.each {|t| t.join}
24 success
25 end
26end
27
28MultiThreadedBehaviourRunner = MultiThreadedExampleGroupRunner