Skip to content

Commit

Permalink
Add test for mini racer forking safety
Browse files Browse the repository at this point in the history
  • Loading branch information
SamSaffron committed Aug 22, 2024
1 parent 6366ea1 commit 072d5a2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/mini_racer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1164,4 +1164,16 @@ def test_threading_safety
Thread.new { MiniRacer::Context.new.eval("100") }.join
GC.start
end


if RUBY_ENGINE == "truffleruby"
skip "TruffleRuby forking is not supported"
else
def test_forking
`bundle exec ruby test/test_forking.rb`
if $?.exitstatus != 0
assert false, "forking test failed"
end
end
end
end
2 changes: 2 additions & 0 deletions test/test_forking.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# use bundle exec to run this script
#
require 'mini_racer'

MiniRacer::Platform.set_flags! :single_threaded
Expand All @@ -25,4 +26,5 @@ def trigger_gc

if Process.respond_to?(:fork)
Process.wait fork { puts @ctx.eval("a"); @ctx.dispose; puts Process.pid; trigger_gc; puts "done #{Process.pid}" }
exit $?.exitstatus || 1
end

0 comments on commit 072d5a2

Please sign in to comment.