Class: ParallelSplitTest::CommandLine

Inherits:
RSpec::Core::Runner
  • Object
show all
Defined in:
lib/parallel_split_test/command_line.rb

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ CommandLine

Returns a new instance of CommandLine.



9
10
11
12
# File 'lib/parallel_split_test/command_line.rb', line 9

def initialize(args)
  @args = args
  super
end

Instance Method Details

#run(err, out) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/parallel_split_test/command_line.rb', line 14

def run(err, out)
  no_summary = @args.delete('--no-summary')
  no_merge = @args.delete('--no-merge')

  @options = RSpec::Core::ConfigurationOptions.new(@args)

  processes = ParallelSplitTest.choose_number_of_processes
  out.puts "Running examples in #{processes} processes"

  results = Parallel.in_processes(processes) do |process_number|
    ParallelSplitTest.example_counter = 0
    ParallelSplitTest.process_number = process_number
    set_test_env_number(process_number)
    modify_out_file_in_args(process_number) if out_file
    out = OutputRecorder.new(out)
    [super(err, out), out.recorded]
  end

  combine_out_files if out_file unless no_merge

  reprint_result_lines(out, results.map(&:last)) unless no_summary
  results.map(&:first).max # combine exit status
end