mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
parent
ab8b199be8
commit
e47078fb30
Notes:
git
2025-03-20 21:23:53 +00:00
1 changed files with 7 additions and 15 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue