Sha256: 4d967efbaaa14aaf7bd80409acb84846e7c3c8df62e89073ab1b45ece5dc125f

Contents?: true

Size: 794 Bytes

Versions: 1

Compression:

Stored size: 794 Bytes

Contents

module ThreadedRspec
  class ExampleGroupRunner < Spec::Runner::ExampleGroupRunner
    def initialize(options)
      super(options)
      @options = options
      @thread_count = 1

      parser = OptionParser.new do |p|
        p.on('--thread-count N', Integer,
             'Number of concurrent threads.') do |n|
          @thread_count = n
        end
      end
      parser.parse!(options.argv)
    end

    def run
      prepare
      queue = Queue.new
      example_groups.each{|b| queue << b}

      success = true
      threads = []
      @thread_count.times do
        threads << Thread.new(queue, @options) do |q, opts|
          success &= q.pop.run(opts) while !q.empty?
        end
      end
      threads.each{|t| t.join}

      success
    ensure
      finish
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
GICodeWarrior-threaded-rspec-0.2.0 lib/threaded_rspec/example_group_runner.rb