Sha256: 838d333366def781dc0fd2f4383ee3b98a9e66093bdd82964defd68f4f00711b

Contents?: true

Size: 848 Bytes

Versions: 3

Compression:

Stored size: 848 Bytes

Contents

require File.expand_path(File.dirname(__FILE__) + '/array_extension')
Array.send :include, ArrayExtension

class MultiProcessSpecRunner

  def initialize(max_concurrent_processes = 10)
    @max_concurrent_processes = max_concurrent_processes
  end
  
  def run(spec_files)
    concurrent_processes = [ @max_concurrent_processes, spec_files.size ].min
    spec_files_by_process = spec_files / concurrent_processes
    concurrent_processes.times do |i|
      cmd  = "spec #{spec_files_by_process[i].join(' ')}"
      puts "Launching #{cmd}"
      exec(cmd) if fork == nil
    end
    success = true
    concurrent_processes.times do |i|
      pid, status = Process.wait2
      puts "Test process ##{i} with pid #{pid} completed with #{status}"
      success &&= status.exitstatus.zero?
    end
    
    raise "Build failed" unless success
  end

end

Version data entries

3 entries across 3 versions & 3 rubygems

Version Path
selenium-rspec-dsl-1.0.2 vendor/selenium-grid-1.0.4/examples/ruby/lib/multi_process_behaviour_runner.rb
davidtrogers-selenium-grid-0.0.1 examples/ruby/lib/multi_process_behaviour_runner.rb
statt-0.0.1 lib/selenium-grid/examples/ruby/lib/multi_process_behaviour_runner.rb