Class: RSpec::Parallel::Runner

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

Class Method Summary collapse

Class Method Details

.run(args, err = $stderr, out = $stdout) ⇒ Object

Run a suite of RSpec examples.

This is used internally by RSpec to run a suite, but is available for use by any other automation tool.

If you want to run this multiple times in the same process, and you want files like spec_helper.rb to be reloaded, be sure to load load instead of require.

#### Parameters

  • args - an array of command-line-supported arguments

  • err - error stream (Default: $stderr)

  • out - output stream (Default: $stdout)

#### Returns

  • Fixnum - exit status code (0/1)



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/rspec/parallel/runner.rb', line 20

def self.run(args, err=$stderr, out=$stdout)
  trap_interrupt
  options = ConfigurationOptions.new(args)
  options.parse_options

  parallel = (options.options[:thread_maximum].nil?) ? false : true
  drb = options.options[:drb]

  if drb
    require 'rspec/core/drb_command_line'
    begin
      DRbCommandLine.new(options).run(err, out)
    rescue DRb::DRbConnError
      err.puts "No DRb server is running. Running in local process instead ..."
      drb = false
    end
  end

  unless drb
    if parallel
      require 'thread'
      CommandLine.new(options).run_parallel(err, out)
    else
      CommandLine.new(options).run(err, out)
    end
  end
ensure
  RSpec.reset
end