/usr/lib/ruby/vendor_ruby/rspec/core/bisect/server.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 | require 'drb/drb'
require 'drb/acl'
module RSpec
module Core
# @private
module Bisect
# @private
BisectFailedError = Class.new(StandardError)
# @private
# A DRb server that receives run results from a separate RSpec process
# started by the bisect process.
class Server
def self.run
server = new
server.start
yield server
ensure
server.stop
end
def capture_run_results(files_or_directories_to_run=[], expected_failures=[])
self.expected_failures = expected_failures
self.files_or_directories_to_run = files_or_directories_to_run
self.latest_run_results = nil
run_output = yield
latest_run_results || raise_bisect_failed(run_output)
end
def start
# Only allow remote DRb requests from this machine.
DRb.install_acl ACL.new(%w[ deny all allow localhost allow 127.0.0.1 ])
# We pass `nil` as the first arg to allow it to pick a DRb port.
@drb = DRb.start_service(nil, self)
end
def stop
@drb.stop_service
end
def drb_port
@drb_port ||= Integer(@drb.uri[/\d+$/])
end
# Fetched via DRb by the BisectFormatter to determine when to abort.
attr_accessor :expected_failures
# Set via DRb by the BisectFormatter with the results of the run.
attr_accessor :latest_run_results
# Fetched via DRb to tell clients which files to run
attr_accessor :files_or_directories_to_run
private
def raise_bisect_failed(run_output)
raise BisectFailedError, "Failed to get results from the spec " \
"run. Spec run output:\n\n#{run_output}"
end
end
end
end
end
|