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

Commit 88aee8b

Browse files
committed
Update ripper_supported? for truffleruby and ripper specs to allow exceptions
1 parent 596198a commit 88aee8b

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

lib/rspec/support/ruby_features.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ def non_mri?
4747
def mri?
4848
!defined?(RUBY_ENGINE) || RUBY_ENGINE == 'ruby'
4949
end
50+
51+
def truffleruby?
52+
defined?(RUBY_ENGINE) && RUBY_ENGINE == 'truffleruby'
53+
end
5054
end
5155

5256
# @api private
@@ -101,7 +105,7 @@ def supports_taint?
101105
end
102106
ripper_requirements = [ComparableVersion.new(RUBY_VERSION) >= '1.9.2']
103107

104-
ripper_requirements.push(false) if Ruby.rbx?
108+
ripper_requirements.push(false) if Ruby.rbx? || Ruby.truffleruby?
105109

106110
if Ruby.jruby?
107111
ripper_requirements.push(Ruby.jruby_version >= '1.7.5')

spec/rspec/support/ruby_features_spec.rb

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -126,21 +126,29 @@ def ripper_works_correctly?
126126
# https://github.com/jruby/jruby/issues/3386
127127
def ripper_reports_correct_line_number?
128128
in_sub_process_if_possible do
129-
require 'ripper'
130-
tokens = ::Ripper.lex('foo')
131-
token = tokens.first
132-
location = token.first
133-
line_number = location.first
134-
line_number == 1
129+
begin
130+
require 'ripper'
131+
tokens = ::Ripper.lex('foo')
132+
token = tokens.first
133+
location = token.first
134+
line_number = location.first
135+
line_number == 1
136+
rescue
137+
false
138+
end
135139
end
136140
end
137141

138142
# https://github.com/jruby/jruby/issues/4562
139143
def ripper_can_parse_source_including_keywordish_symbol?
140144
in_sub_process_if_possible do
141-
require 'ripper'
142-
sexp = ::Ripper.sexp(':if')
143-
!sexp.nil?
145+
begin
146+
require 'ripper'
147+
sexp = ::Ripper.sexp(':if')
148+
!sexp.nil?
149+
rescue
150+
false
151+
end
144152
end
145153
end
146154

0 commit comments

Comments
 (0)