From 1935433f5f6fecc786955dcf80e8f65ada6bcaeb Mon Sep 17 00:00:00 2001 From: Samuel Giddins Date: Thu, 17 Aug 2023 15:38:53 -0700 Subject: [rubygems/rubygems] Ensure that loading multiple gemspecs with legacy YAML class references does not warn Before this, you would get constant redefinition warnings on Psych::DefaultKey Additionally, ensure the retries wont continue infinitely in the case of the ArgumentError not being caused by Marshal trying to load the undefined classes https://github.com/rubygems/rubygems/commit/919e8c2de4 --- test/rubygems/test_gem_specification.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'test') diff --git a/test/rubygems/test_gem_specification.rb b/test/rubygems/test_gem_specification.rb index 9e68c40b7c..d37e1d1571 100644 --- a/test/rubygems/test_gem_specification.rb +++ b/test/rubygems/test_gem_specification.rb @@ -1094,6 +1094,25 @@ dependencies: [] assert_equal(yaml_defined, Object.const_defined?("YAML")) end + def test_handles_dependencies_with_other_syck_requirements_argument_error + yaml_defined = Object.const_defined?("YAML") + + data = Marshal.dump(Gem::Specification.new do |s| + v = Gem::Version.allocate + v.instance_variable_set :@version, "YAML::Syck::DefaultKey" + s.instance_variable_set :@version, v + end) + + assert_raises(ArgumentError) { Marshal.load(data) } + out, err = capture_output do + assert_raises(ArgumentError) { Marshal.load(data) } + end + assert_empty out + assert_empty err + + assert_equal(yaml_defined, Object.const_defined?("YAML")) + end + def test_initialize spec = Gem::Specification.new do |s| s.name = "blah" -- cgit v1.2.3