/usr/lib/ruby/vendor_ruby/rspec/core/drb.rb is in ruby-rspec-core 3.5.0c3e0m0s0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | require 'drb/drb'
module RSpec
module Core
# @private
class DRbRunner
def initialize(options, configuration=RSpec.configuration)
@options = options
@configuration = configuration
end
def drb_port
@options.options[:drb_port] || ENV['RSPEC_DRB'] || 8989
end
def run(err, out)
begin
DRb.start_service("druby://localhost:0")
rescue SocketError, Errno::EADDRNOTAVAIL
DRb.start_service("druby://:0")
end
spec_server = DRbObject.new_with_uri("druby://127.0.0.1:#{drb_port}")
spec_server.run(drb_argv, err, out)
end
def drb_argv
@drb_argv ||= begin
@options.configure_filter_manager(@configuration.filter_manager)
DRbOptions.new(@options.options, @configuration.filter_manager).options
end
end
end
# @private
class DRbOptions
def initialize(submitted_options, filter_manager)
@submitted_options = submitted_options
@filter_manager = filter_manager
end
def options
argv = []
argv << "--color" if @submitted_options[:color]
argv << "--profile" if @submitted_options[:profile_examples]
argv << "--backtrace" if @submitted_options[:full_backtrace]
argv << "--tty" if @submitted_options[:tty]
argv << "--fail-fast" if @submitted_options[:fail_fast]
argv << "--options" << @submitted_options[:custom_options_file] if @submitted_options[:custom_options_file]
argv << "--order" << @submitted_options[:order] if @submitted_options[:order]
add_failure_exit_code(argv)
add_full_description(argv)
add_filter(argv, :inclusion, @filter_manager.inclusions)
add_filter(argv, :exclusion, @filter_manager.exclusions)
add_formatters(argv)
add_libs(argv)
add_requires(argv)
argv + @submitted_options[:files_or_directories_to_run]
end
def add_failure_exit_code(argv)
return unless @submitted_options[:failure_exit_code]
argv << "--failure-exit-code" << @submitted_options[:failure_exit_code].to_s
end
def add_full_description(argv)
return unless @submitted_options[:full_description]
# The argument to --example is regexp-escaped before being stuffed
# into a regexp when received for the first time (see OptionParser).
# Hence, merely grabbing the source of this regexp will retain the
# backslashes, so we must remove them.
@submitted_options[:full_description].each do |description|
argv << "--example" << description.source.delete('\\')
end
end
CONDITIONAL_FILTERS = [:if, :unless]
def add_filter(argv, name, hash)
hash.each_pair do |k, v|
next if CONDITIONAL_FILTERS.include?(k)
tag = name == :inclusion ? k.to_s : "~#{k}"
tag << ":#{v}" if v.is_a?(String)
argv << "--tag" << tag
end unless hash.empty?
end
def add_formatters(argv)
@submitted_options[:formatters].each do |pair|
argv << "--format" << pair[0]
argv << "--out" << pair[1] if pair[1]
end if @submitted_options[:formatters]
end
def add_libs(argv)
@submitted_options[:libs].each do |path|
argv << "-I" << path
end if @submitted_options[:libs]
end
def add_requires(argv)
@submitted_options[:requires].each do |path|
argv << "--require" << path
end if @submitted_options[:requires]
end
end
end
end
|