class RSpec::Core::Bisect::ShellCommand

Provides an API to generate shell commands to run the suite for a set of locations, using the given bisect server to capture the results. @private

Constants

RUBY

Path to the currently running Ruby executable, borrowed from Rake: github.com/ruby/rake/blob/v10.4.2/lib/rake/file_utils.rb#L8-L12 Note that we skip ‘ENV` because we don’t have to deal with running RSpec from within a MRI source repository: github.com/ruby/rake/commit/968682759b3b65e42748cd2befb2ff3e982272d9

Attributes

Public Class Methods

# File rspec-core/lib/rspec/core/bisect/shell_command.rb, line 13
def initialize(original_cli_args)
  @original_cli_args = original_cli_args.reject { |arg| arg.start_with?("--bisect") }
end

Public Instance Methods

# File rspec-core/lib/rspec/core/bisect/shell_command.rb, line 47
def bisect_environment_hash
  if ENV.key?('SPEC_OPTS')
    { 'SPEC_OPTS' => spec_opts_without_bisect }
  else
    {}
  end
end
# File rspec-core/lib/rspec/core/bisect/shell_command.rb, line 17
def command_for(locations, server)
  parts = []

  parts << RUBY << load_path
  parts << open3_safe_escape(RSpec::Core.path_to_executable)

  parts << "--format"   << "bisect-drb"
  parts << "--drb-port" << server.drb_port

  parts.concat(reusable_cli_options)
  parts.concat(locations.map { |l| open3_safe_escape(l) })

  parts.join(" ")
end
# File rspec-core/lib/rspec/core/bisect/shell_command.rb, line 43
def original_locations
  parsed_original_cli_options.fetch(:files_or_directories_to_run)
end
# File rspec-core/lib/rspec/core/bisect/shell_command.rb, line 32
def repro_command_from(locations)
  parts = []

  parts.concat environment_repro_parts
  parts << "rspec"
  parts.concat Formatters::Helpers.organize_ids(locations)
  parts.concat original_cli_args_without_locations

  parts.join(" ")
end
# File rspec-core/lib/rspec/core/bisect/shell_command.rb, line 55
def spec_opts_without_bisect
  Shellwords.join(
    Shellwords.split(ENV.fetch('SPEC_OPTS', '')).reject do |arg|
      arg =~ /^--bisect/
    end
  )
end