mirror of https://github.com/rails/rails
fix(fork-tracker): Only patch fork if it's supported
Some tests are currently wrapped with `if Process.respond_to?(:fork)` but they're still executed on JRuby. The problem is that ForkTracker unconditionally patches `#fork` so `Process` does indeed `respond_to? :fork`. Fix it by installing the patch conditionally with the same check.
This commit is contained in:
parent
a4ea17f6b6
commit
f3260272f2
|
@ -35,10 +35,12 @@ module ActiveSupport
|
|||
end
|
||||
|
||||
def hook!
|
||||
::Object.prepend(CoreExtPrivate)
|
||||
::Kernel.prepend(CoreExtPrivate)
|
||||
::Kernel.singleton_class.prepend(CoreExt)
|
||||
::Process.singleton_class.prepend(CoreExt)
|
||||
if Process.respond_to?(:fork)
|
||||
::Object.prepend(CoreExtPrivate)
|
||||
::Kernel.prepend(CoreExtPrivate)
|
||||
::Kernel.singleton_class.prepend(CoreExt)
|
||||
::Process.singleton_class.prepend(CoreExt)
|
||||
end
|
||||
end
|
||||
|
||||
def after_fork(&block)
|
||||
|
|
|
@ -207,4 +207,4 @@ class ForkTrackerTest < ActiveSupport::TestCase
|
|||
ensure
|
||||
ActiveSupport::ForkTracker.unregister(handler)
|
||||
end
|
||||
end
|
||||
end if Process.respond_to?(:fork)
|
||||
|
|
Loading…
Reference in New Issue