Class: RSpec::Parallel::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/parallel/runner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Runner

Returns a new instance of Runner.

Parameters:

  • args (Array<String>)

    command line arguments



13
14
15
16
17
18
19
20
21
# File 'lib/rspec/parallel/runner.rb', line 13

def initialize(args)
  @args = args
  @pids = []

  # Configure RSpec core before initialize master instance and spawning
  # worker processes to share its configuration.
  configure_rspec
  @master = Master.new(args)
end

Instance Attribute Details

#pidsArray<Integer> (readonly)

Returns array of pids of spawned worker processes.

Returns:

  • (Array<Integer>)

    array of pids of spawned worker processes



10
11
12
# File 'lib/rspec/parallel/runner.rb', line 10

def pids
  @pids
end

Instance Method Details

#startvoid

This method returns an undefined value.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/rspec/parallel/runner.rb', line 24

def start
  RSpec::Parallel.configuration.concurrency.times do
    spawn_worker
  end
  master.run
  Process.waitall
ensure
  pids.each.with_index do |pid, index|
    puts "----> output from worker[#{index}]"
    File.open(output_file_path(pid)) do |file|
      puts file.read
    end
  end
end