[ruby/prism] Update ractor_test.rb per review
https://github.com/ruby/prism/commit/fd96a6821f
This commit is contained in:
parent
ab8b199be8
commit
e47078fb30
Notes:
git
2025-03-20 21:23:53 +00:00
@ -1,11 +1,9 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
return unless defined?(Ractor)
|
return if !defined?(Ractor) || !defined?(fork)
|
||||||
|
|
||||||
require_relative "test_helper"
|
require_relative "test_helper"
|
||||||
|
|
||||||
return if Prism::TestCase.windows?
|
|
||||||
|
|
||||||
module Prism
|
module Prism
|
||||||
class RactorTest < TestCase
|
class RactorTest < TestCase
|
||||||
def test_version
|
def test_version
|
||||||
@ -60,19 +58,13 @@ module Prism
|
|||||||
# Note that this must be done in a subprocess, otherwise it can mess up
|
# Note that this must be done in a subprocess, otherwise it can mess up
|
||||||
# CRuby's test suite.
|
# CRuby's test suite.
|
||||||
def with_ractor(*arguments, &block)
|
def with_ractor(*arguments, &block)
|
||||||
reader, writer = IO.pipe
|
IO.popen("-") do |reader|
|
||||||
|
if reader
|
||||||
pid = fork do
|
reader.gets.chomp
|
||||||
reader.close
|
else
|
||||||
writer.puts(ignore_warnings { Ractor.new(*arguments, &block) }.take)
|
puts(ignore_warnings { Ractor.new(*arguments, &block) }.take)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
writer.close
|
|
||||||
result = reader.gets.chomp
|
|
||||||
reader.close
|
|
||||||
|
|
||||||
Process.wait(pid)
|
|
||||||
result
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user