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:
Daniel Ritz 2019-10-06 23:41:37 +02:00
parent a4ea17f6b6
commit f3260272f2
2 changed files with 7 additions and 5 deletions

View File

@ -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)

View File

@ -207,4 +207,4 @@ class ForkTrackerTest < ActiveSupport::TestCase
ensure
ActiveSupport::ForkTracker.unregister(handler)
end
end
end if Process.respond_to?(:fork)