Skip to content

Commit

Permalink
Remove codes for unsupported Ruby (#17353)
Browse files Browse the repository at this point in the history
Protocol Buffers  only supports Ruby >= 3.0 since 360531c

Closes #17353

COPYBARA_INTEGRATE_REVIEW=#17353 from y-yagi:remove_codes_for_ruby27 80571a4
PiperOrigin-RevId: 658528987
  • Loading branch information
y-yagi authored and copybara-github committed Aug 1, 2024
1 parent 258f3e9 commit 184f3a3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 19 deletions.
4 changes: 1 addition & 3 deletions ruby/tests/gc_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)))

old_gc = GC.stress
# Ruby 2.7.0 - 2.7.1 has a GC bug in its parser, so turn off stress for now
# See https://bugs.ruby-lang.org/issues/16807
GC.stress = 0x01 | 0x04 unless RUBY_VERSION.match?(/^2\.7\./)
GC.stress = 0x01 | 0x04
require 'generated_code_pb'
require 'generated_code_proto2_pb'
GC.stress = old_gc
Expand Down
20 changes: 4 additions & 16 deletions ruby/tests/repeated_field_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -215,28 +215,16 @@ def test_array_accessor
arr[-5..-1]
end
check_self_modifying_method(m.repeated_string, reference_arr) do |arr|
# Infinite range; introduce in Ruby 2.7.
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7')
eval "arr[0..]"
end
eval "arr[0..]"
end
check_self_modifying_method(m.repeated_string, reference_arr) do |arr|
# Beginless range; introduced in Ruby 2.7.
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7')
eval "arr[..-1]"
end
eval "arr[..-1]"
end
check_self_modifying_method(m.repeated_string, reference_arr) do |arr|
# Infinite range; introduce in Ruby 2.7.
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7')
eval "arr[0...]" # Exclusive range
end
eval "arr[0...]" # Exclusive range
end
check_self_modifying_method(m.repeated_string, reference_arr) do |arr|
# Beginless range; introduced in Ruby 2.7.
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7')
eval "arr[...-1]" # Exclusive range
end
eval "arr[...-1]" # Exclusive range
end
check_self_modifying_method(m.repeated_string, reference_arr) do |arr|
arr[-1, 1]
Expand Down

0 comments on commit 184f3a3

Please sign in to comment.