Methods
Included Modules
- DRb::DRbUndumped
Class Public methods
new()
📝 Source code
# File activesupport/lib/active_support/testing/parallelization/server.rb, line 12
def initialize
@queue = Queue.new
@active_workers = Concurrent::Map.new
@in_flight = Concurrent::Map.new
end
🔎 See on GitHub
Instance Public methods
<<(o)
📝 Source code
# File activesupport/lib/active_support/testing/parallelization/server.rb, line 28
def <<(o)
o[2] = DRbObject.new(o[2]) if o
@queue << o
end
🔎 See on GitHub
active_workers?()
📝 Source code
# File activesupport/lib/active_support/testing/parallelization/server.rb, line 48
def active_workers?
@active_workers.size > 0
end
🔎 See on GitHub
pop()
📝 Source code
# File activesupport/lib/active_support/testing/parallelization/server.rb, line 33
def pop
if test = @queue.pop
@in_flight[[test[0].to_s, test[1]]] = test
test
end
end
🔎 See on GitHub
record(reporter, result)
📝 Source code
# File activesupport/lib/active_support/testing/parallelization/server.rb, line 18
def record(reporter, result)
raise DRb::DRbConnError if result.is_a?(DRb::DRbUnknown)
@in_flight.delete([result.klass, result.name])
reporter.synchronize do
reporter.record(result)
end
end
🔎 See on GitHub
shutdown()
📝 Source code
# File activesupport/lib/active_support/testing/parallelization/server.rb, line 52
def shutdown
# Wait for initial queue to drain
while @queue.length != 0
sleep 0.1
end
@queue.close
# Wait until all workers have finished
while active_workers?
sleep 0.1
end
@in_flight.values.each do |(klass, name, reporter)|
result = Minitest::Result.from(klass.new(name))
error = RuntimeError.new("result not reported")
error.set_backtrace([""])
result.failures << Minitest::UnexpectedError.new(error)
reporter.synchronize do
reporter.record(result)
end
end
end
🔎 See on GitHub
start_worker(worker_id)
📝 Source code
# File activesupport/lib/active_support/testing/parallelization/server.rb, line 40
def start_worker(worker_id)
@active_workers[worker_id] = true
end
🔎 See on GitHub
stop_worker(worker_id)
📝 Source code
# File activesupport/lib/active_support/testing/parallelization/server.rb, line 44
def stop_worker(worker_id)
@active_workers.delete(worker_id)
end
🔎 See on GitHub