Class: RSpec::Core::Bisect::ShellCommand Private
Do not use. This class is for internal use only.
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Instance Chain:
|
|
Inherits: | Object |
Defined in: | rspec-core/lib/rspec/core/bisect/shell_command.rb |
Overview
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.
Constant Summary
-
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
'RUBY'
because we don’t have to deal with running::RSpec
from within a MRI source repository: github.com/ruby/rake/commit/968682759b3b65e42748cd2befb2ff3e982272d9File.join( RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'] + RbConfig::CONFIG['EXEEXT']). sub(/.*\s.*/m, '"\&"')
::RSpec::Core::ShellEscape
- Included
Class Method Summary
- .new(original_cli_args) ⇒ ShellCommand constructor Internal use only
Instance Attribute Summary
- #original_cli_args readonly Internal use only
Instance Method Summary
- #bisect_environment_hash Internal use only
- #command_for(locations, server) Internal use only
- #original_locations Internal use only
- #repro_command_from(locations) Internal use only
- #spec_opts_without_bisect Internal use only
- #environment_repro_parts private Internal use only
- #load_path private Internal use only
-
#open3_safe_escape(shell_command)
private
Alias for ShellEscape#escape.
- #original_cli_args_without_locations private Internal use only
- #parsed_original_cli_options private Internal use only
- #reusable_cli_options private Internal use only
::RSpec::Core::ShellEscape
- Included
Instance Attribute Details
#original_cli_args (readonly)
[ GitHub ]# File 'rspec-core/lib/rspec/core/bisect/shell_command.rb', line 11
attr_reader :original_cli_args
Instance Method Details
#bisect_environment_hash
[ GitHub ]# 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
#command_for(locations, server)
[ GitHub ]# 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( ) parts.concat(locations.map { |l| open3_safe_escape(l) }) parts.join(" ") end
#environment_repro_parts (private)
[ GitHub ]# File 'rspec-core/lib/rspec/core/bisect/shell_command.rb', line 76
def environment_repro_parts bisect_environment_hash.map do |k, v| %Q(#{k}="#{v}") end end
#load_path (private)
[ GitHub ]# File 'rspec-core/lib/rspec/core/bisect/shell_command.rb', line 110
def load_path @load_path ||= "-I#{$LOAD_PATH.map { |p| open3_safe_escape(p) }.join(':')}" end
#open3_safe_escape(shell_command) (private)
Alias for ShellEscape#escape.
# File 'rspec-core/lib/rspec/core/bisect/shell_command.rb', line 70
alias open3_safe_escape quote
#original_cli_args_without_locations (private)
[ GitHub ]# File 'rspec-core/lib/rspec/core/bisect/shell_command.rb', line 99
def original_cli_args_without_locations @original_cli_args_without_locations ||= begin files_or_dirs = .fetch(:files_or_directories_to_run) @original_cli_args - files_or_dirs end end
#original_locations
[ GitHub ]# File 'rspec-core/lib/rspec/core/bisect/shell_command.rb', line 43
def original_locations .fetch(:files_or_directories_to_run) end
#parsed_original_cli_options (private)
[ GitHub ]#repro_command_from(locations)
[ GitHub ]# 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
#reusable_cli_options (private)
[ GitHub ]# File 'rspec-core/lib/rspec/core/bisect/shell_command.rb', line 82
def @reusable_cli_options ||= begin opts = original_cli_args_without_locations if (port = [:drb_port]) opts -= %W[ --drb-port #{port} ] end .fetch(:formatters) { [] }.each do |(name, out)| opts -= %W[ --format #{name} -f -f#{name} ] opts -= %W[ --out #{out} -o -o#{out} ] end opts end end
#spec_opts_without_bisect
[ GitHub ]# 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