Add tests for `$LOAD_PATH.dup` and `Ractor.make_shareable`

This commit is contained in:
Jean Boussier 2023-10-30 09:32:37 +01:00
parent 31cd669855
commit 9bf5f12f33
3 changed files with 19 additions and 8 deletions

View File

@ -1,5 +1,7 @@
# Unreleased
* Ensure `$LOAD_PATH.dup` is Ractor shareable to fix an conflit with `did_you_mean`.
* Allow to ignore direcotries using absolute paths.
* Support YAML and JSON CompileCache on TruffleRuby.
* Support LoadPathCache on TruffleRuby.

View File

@ -56,16 +56,10 @@ module Bootsnap
end
def dup
new_obj = super
new_obj.remove_instance_variable(:@lpc_observer)
new_obj
[] + self
end
def clone
new_obj = super
ChangeObserver.unregister(new_obj)
new_obj
end
alias_method :clone, :dup
end
def self.register(arr, observer)

View File

@ -10,6 +10,7 @@ module Bootsnap
def setup
super
@observer = Object.new
@observer.instance_variable_set(:@mutex, Mutex.new)
@arr = []
ChangeObserver.register(@arr, @observer)
end
@ -78,6 +79,20 @@ module Bootsnap
assert_equal(%w(a), @arr)
end
def test_dup_returns_ractor_shareable_instance
return unless defined?(Ractor)
ChangeObserver.register(@arr, @observer)
Ractor.make_shareable(@arr.dup.freeze)
end
def test_clone_returns_ractor_shareable_instance
return unless defined?(Ractor)
ChangeObserver.register(@arr, @observer)
Ractor.make_shareable(@arr.clone.freeze)
end
def test_uniq_without_block
@observer.expects(:reinitialize).never
@arr.uniq!