class RSpec::Parallel::Master
Attributes
args[R]
@param args [Array<String>]
files_to_run[R]
@example
files_to_run #=> ["spec/rspec/parallel_spec.rb", "spec/rspec/parallel/configuration_spec.rb"]
@return [Array<String>]
path[R]
@return [String, nil] path to unix domain socket
server[R]
@return [UNIXServer]
total[R]
@return [Integer]
Public Class Methods
new(args)
click to toggle source
@note RSpec
must be configured ahead @param args [Array<String>] command line arguments
# File lib/rspec/parallel/master.rb, line 18 def initialize(args) @args = args @path = "/tmp/parallel-rspec-#{$PID}.sock" @files_to_run = ::RSpec.configuration.files_to_run.uniq @total = @files_to_run.size @server = ::UNIXServer.new(@path) end
Public Instance Methods
close()
click to toggle source
@return [void]
# File lib/rspec/parallel/master.rb, line 27 def close server.close end
run()
click to toggle source
@return [void]
# File lib/rspec/parallel/master.rb, line 32 def run count = 1 until files_to_run.empty? rs, _ws, _es = IO.select([server]) rs.each do |s| socket = s.accept method, data = socket.gets.strip.split(" ", 2) case method when Protocol::POP path = files_to_run.pop RSpec::Parallel.configuration.logger.info("[#{count} / #{total}] Deliver #{path} to worker[#{data}]") count += 1 socket.write(path) when Protocol::PING socket.write("ok") end socket.close end end close remove_socket_file end
socket_builder()
click to toggle source
Create a socket builder which builds a socket to connect with the master process.
@return [RSpec::Parallel::SocketBuilder]
# File lib/rspec/parallel/master.rb, line 59 def socket_builder SocketBuilder.new(path) end
Private Instance Methods
remove_socket_file()
click to toggle source
@return [void]
# File lib/rspec/parallel/master.rb, line 81 def remove_socket_file FileUtils.rm(path, force: true) end