ruby-changes:66324
From: Hiroshi <ko1@a...>
Date: Fri, 28 May 2021 12:17:47 +0900 (JST)
Subject: [ruby-changes:66324] f7d661e783 (master): [rubygems/rubygems] Try fix ruby-core CI
https://git.ruby-lang.org/ruby.git/commit/?id=f7d661e783 From f7d661e783e02f87e1e0d0d67b1ca2ed306a1904 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA <hsbt@r...> Date: Mon, 17 May 2021 11:59:59 +0900 Subject: [rubygems/rubygems] Try fix ruby-core CI * Port https://github.com/ruby/ruby/commit/8e91b969df08b7a2eb27a5d6d38733eea42dc7ad from ruby-core, and make it compatible with psych 3 & 4. --- lib/rubygems/test_case.rb | 22 ++++++++++++ test/rubygems/test_gem_commands_signin_command.rb | 12 +++---- .../test_gem_commands_specification_command.rb | 6 ++-- test/rubygems/test_gem_config_file.rb | 10 +++--- test/rubygems/test_gem_gemcutter_utilities.rb | 10 +++--- test/rubygems/test_gem_package.rb | 30 ++++++++-------- test/rubygems/test_gem_specification.rb | 42 +++++++++++----------- 7 files changed, 77 insertions(+), 55 deletions(-) diff --git a/lib/rubygems/test_case.rb b/lib/rubygems/test_case.rb index 8dde204..b3e2336 100644 --- a/lib/rubygems/test_case.rb +++ b/lib/rubygems/test_case.rb @@ -692,6 +692,28 @@ class Gem::TestCase < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/lib/rubygems/test_case.rb#L692 path end + ## + # Load a YAML string, the psych 3 way + + def load_yaml(yaml) + if YAML.respond_to?(:unsafe_load) + YAML.unsafe_load(yaml) + else + YAML.load(yaml) + end + end + + ## + # Load a YAML file, the psych 3 way + + def load_yaml_file(file) + if YAML.respond_to?(:unsafe_load_file) + YAML.unsafe_load_file(file) + else + YAML.load_file(file) + end + end + def all_spec_names Gem::Specification.map(&:full_name) end diff --git a/test/rubygems/test_gem_commands_signin_command.rb b/test/rubygems/test_gem_commands_signin_command.rb index a36744e..596f262 100644 --- a/test/rubygems/test_gem_commands_signin_command.rb +++ b/test/rubygems/test_gem_commands_signin_command.rb @@ -30,10 +30,10 @@ class TestGemCommandsSigninCommand < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_signin_command.rb#L30 host = 'http://some-gemcutter-compatible-host.org' util_capture(nil, host) { @cmd.execute } - old_credentials = YAML.unsafe_load_file Gem.configuration.credentials_path + old_credentials = load_yaml_file Gem.configuration.credentials_path util_capture(nil, host) { @cmd.execute } - new_credentials = YAML.unsafe_load_file Gem.configuration.credentials_path + new_credentials = load_yaml_file Gem.configuration.credentials_path assert_equal old_credentials[host], new_credentials[host] end @@ -45,7 +45,7 @@ class TestGemCommandsSigninCommand < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_signin_command.rb#L45 host = 'http://some-gemcutter-compatible-host.org' util_capture(nil, host, api_key) { @cmd.execute } - credentials = YAML.unsafe_load_file Gem.configuration.credentials_path + credentials = load_yaml_file Gem.configuration.credentials_path assert_equal credentials[:rubygems_api_key], api_key @@ -60,7 +60,7 @@ class TestGemCommandsSigninCommand < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_signin_command.rb#L60 assert_match %r{Signed in.}, sign_in_ui.output api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903' - credentials = YAML.unsafe_load_file Gem.configuration.credentials_path + credentials = load_yaml_file Gem.configuration.credentials_path assert_equal api_key, credentials[host] end @@ -68,7 +68,7 @@ class TestGemCommandsSigninCommand < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_signin_command.rb#L68 util_capture { @cmd.execute } api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903' - credentials = YAML.unsafe_load_file Gem.configuration.credentials_path + credentials = load_yaml_file Gem.configuration.credentials_path assert_equal api_key, credentials[:rubygems_api_key] end @@ -94,7 +94,7 @@ class TestGemCommandsSigninCommand < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_signin_command.rb#L94 assert_match "show_dashboard [y/N]", key_name_ui.output assert_equal "name=test-key&push_rubygem=true", fetcher.last_request.body - credentials = YAML.unsafe_load_file Gem.configuration.credentials_path + credentials = load_yaml_file Gem.configuration.credentials_path assert_equal api_key, credentials[:rubygems_api_key] end diff --git a/test/rubygems/test_gem_commands_specification_command.rb b/test/rubygems/test_gem_commands_specification_command.rb index 4dac3eb..a04746f 100644 --- a/test/rubygems/test_gem_commands_specification_command.rb +++ b/test/rubygems/test_gem_commands_specification_command.rb @@ -114,7 +114,7 @@ class TestGemCommandsSpecificationCommand < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_specification_command.rb#L114 @cmd.execute end - assert_equal "foo", YAML.unsafe_load(@ui.output) + assert_equal "foo", load_yaml(@ui.output) end def test_execute_file @@ -230,7 +230,7 @@ class TestGemCommandsSpecificationCommand < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_specification_command.rb#L230 assert_match %r{\A--- !ruby/object:Gem::Specification}, @ui.output assert_match %r{name: foo}, @ui.output - spec = YAML.unsafe_load @ui.output + spec = load_yaml @ui.output assert_equal Gem::Version.new("2.0.0"), spec.version end @@ -252,7 +252,7 @@ class TestGemCommandsSpecificationCommand < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_specification_command.rb#L252 assert_match %r{\A--- !ruby/object:Gem::Specification}, @ui.output assert_match %r{name: foo}, @ui.output - spec = YAML.unsafe_load @ui.output + spec = load_yaml @ui.output assert_equal Gem::Version.new("2.0.1.pre"), spec.version end diff --git a/test/rubygems/test_gem_config_file.rb b/test/rubygems/test_gem_config_file.rb index e155810..77d7a08 100644 --- a/test/rubygems/test_gem_config_file.rb +++ b/test/rubygems/test_gem_config_file.rb @@ -195,7 +195,7 @@ class TestGemConfigFile < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_config_file.rb#L195 end def test_check_credentials_permissions - skip 'chmod not supported' if win_platform? + pend 'chmod not supported' if win_platform? @cfg.rubygems_api_key = 'x' @@ -322,7 +322,7 @@ if you believe they were disclosed to a third party. https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_config_file.rb#L322 end def test_load_api_keys_bad_permission - skip 'chmod not supported' if win_platform? + pend 'chmod not supported' if win_platform? @cfg.rubygems_api_key = 'x' @@ -354,7 +354,7 @@ if you believe they were disclosed to a third party. https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_config_file.rb#L354 :rubygems_api_key => 'x', } - assert_equal expected, YAML.unsafe_load_file(@cfg.credentials_path) + assert_equal expected, load_yaml_file(@cfg.credentials_path) unless win_platform? stat = File.stat @cfg.credentials_path @@ -364,7 +364,7 @@ if you believe they were disclosed to a third party. https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_config_file.rb#L364 end def test_rubygems_api_key_equals_bad_permission - skip 'chmod not supported' if win_platform? + pend 'chmod not supported' if win_platform? @cfg.rubygems_api_key = 'x' @@ -378,7 +378,7 @@ if you believe they were disclosed to a third party. https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_config_file.rb#L378 :rubygems_api_key => 'x', } - assert_equal expected, YAML.unsafe_load_file(@cfg.credentials_path) + assert_equal expected, load_yaml_file(@cfg.credentials_path) stat = File.stat @cfg.credentials_path diff --git a/test/rubygems/test_gem_gemcutter_utilities.rb b/test/rubygems/test_gem_gemcutter_utilities.rb index 5f55f7e..27c99fd 100644 --- a/test/rubygems/test_gem_gemcutter_utilities.rb +++ b/test/rubygems/test_gem_gemcutter_utilities.rb @@ -101,7 +101,7 @@ class TestGemGemcutterUtilities < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_gemcutter_utilities.rb#L101 assert @fetcher.last_request["authorization"] assert_match %r{Signed in.}, @sign_in_ui.output - credentials = YAML.unsafe_load_file Gem.configuration.credentials_path + credentials = load_yaml_file Gem.configuration.credentials_path assert_equal api_key, credentials[:rubygems_api_key] end @@ -115,7 +115,7 @@ class TestGemGemcutterUtilities < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_gemcutter_utilities.rb#L115 assert @fetcher.last_request["authorization"] assert_match %r{Signed in.}, @sign_in_ui.output - credentials = YAML.unsafe_load_file Gem.configuration.credentials_path + credentials = load_yaml_file Gem.configuration.credentials_path assert_equal api_key, credentials['http://example.com'] end @@ -129,7 +129,7 @@ class TestGemGemcutterUtilities < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_gemcutter_utilities.rb#L129 assert @fetcher.last_request["authorization"] assert_match %r{Signed in.}, @sign_in_ui.output - credentials = YAML.unsafe_load_file Gem.configuration.credentials_path + credentials = load_yaml_file Gem.configuration.credentials_path assert_equal api_key, credentials[:rubygems_api_key] end @@ -142,7 +142,7 @@ class TestGemGemcutterUtilities < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_gemcutter_utilities.rb#L142 assert @fetcher.last_request["authorization"] (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/