Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Commit dc1567c

Browse files
committed
Add fork_supported?.
This is needed for the new fork-based bisect runner in rspec/rspec-core#2511.
1 parent fd1ff3b commit dc1567c

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

lib/rspec/support/ruby_features.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,22 @@ def mri?
5656
module RubyFeatures
5757
module_function
5858

59+
if Ruby.jruby?
60+
# On JRuby 1.7 `--1.8` mode, `Process.respond_to?(:fork)` returns true,
61+
# but when you try to fork, it raises an error:
62+
# NotImplementedError: fork is not available on this platform
63+
#
64+
# When we drop support for JRuby 1.7 and/or Ruby 1.8, we can drop
65+
# this special case.
66+
def fork_supported?
67+
false
68+
end
69+
else
70+
def fork_supported?
71+
Process.respond_to?(:fork)
72+
end
73+
end
74+
5975
def optional_and_splat_args_supported?
6076
Method.method_defined?(:parameters)
6177
end

spec/rspec/support/ruby_features_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ module Support
7575
end
7676
end
7777

78+
specify "#fork_supported? exists" do
79+
RubyFeatures.fork_supported?
80+
end
81+
7882
specify "#supports_exception_cause? exists" do
7983
RubyFeatures.supports_exception_cause?
8084
end

0 commit comments

Comments
 (0)