[rubygems/rubygems] Try fix ruby-core CI

* Port
8e91b969df
from ruby-core, and make it compatible with psych 3 & 4.
This commit is contained in:
Hiroshi SHIBATA 2021-05-17 11:59:59 +09:00
Родитель ded7dd9ccc
Коммит f7d661e783
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: F9CF13417264FAC2
7 изменённых файлов: 77 добавлений и 55 удалений

Просмотреть файл

@ -692,6 +692,28 @@ class Gem::TestCase < Test::Unit::TestCase
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

Просмотреть файл

@ -30,10 +30,10 @@ class TestGemCommandsSigninCommand < Gem::TestCase
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
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
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
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
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

Просмотреть файл

@ -114,7 +114,7 @@ class TestGemCommandsSpecificationCommand < Gem::TestCase
@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
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
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

Просмотреть файл

@ -195,7 +195,7 @@ class TestGemConfigFile < Gem::TestCase
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.
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.
: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.
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.
: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

Просмотреть файл

@ -101,7 +101,7 @@ class TestGemGemcutterUtilities < Gem::TestCase
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
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
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
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
@ -177,7 +177,7 @@ class TestGemGemcutterUtilities < Gem::TestCase
assert_match %r{Enter your RubyGems.org credentials.}, @sign_in_ui.output
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]
assert_equal other_api_key, credentials[:other_api_key]
end

Просмотреть файл

@ -22,7 +22,7 @@ class TestGemPackage < Gem::Package::TarTestCase
end
def test_class_new_old_format
skip "jruby can't require the simple_gem file" if Gem.java_platform?
pend "jruby can't require the simple_gem file" if Gem.java_platform?
require_relative "simple_gem"
File.open 'old_format.gem', 'wb' do |io|
io.write SIMPLE_GEM
@ -98,7 +98,7 @@ class TestGemPackage < Gem::Package::TarTestCase
},
}
assert_equal expected, YAML.unsafe_load(checksums)
assert_equal expected, load_yaml(checksums)
end
def test_build_time_uses_source_date_epoch
@ -190,7 +190,7 @@ class TestGemPackage < Gem::Package::TarTestCase
File.symlink('../lib/code.rb', 'lib/code_sym2.rb')
rescue Errno::EACCES => e
if win_platform?
skip "symlink - must be admin with no UAC on Windows"
pend "symlink - must be admin with no UAC on Windows"
else
raise e
end
@ -252,7 +252,7 @@ class TestGemPackage < Gem::Package::TarTestCase
end
def test_build_auto_signed
skip 'openssl is missing' unless Gem::HAVE_OPENSSL
pend 'openssl is missing' unless Gem::HAVE_OPENSSL
FileUtils.mkdir_p File.join(Gem.user_home, '.gem')
@ -295,7 +295,7 @@ class TestGemPackage < Gem::Package::TarTestCase
end
def test_build_auto_signed_encrypted_key
skip 'openssl is missing' unless Gem::HAVE_OPENSSL
pend 'openssl is missing' unless Gem::HAVE_OPENSSL
FileUtils.mkdir_p File.join(Gem.user_home, '.gem')
@ -364,7 +364,7 @@ class TestGemPackage < Gem::Package::TarTestCase
end
def test_build_signed
skip 'openssl is missing' unless Gem::HAVE_OPENSSL
pend 'openssl is missing' unless Gem::HAVE_OPENSSL
spec = Gem::Specification.new 'build', '1'
spec.summary = 'build'
@ -401,7 +401,7 @@ class TestGemPackage < Gem::Package::TarTestCase
end
def test_build_signed_encrypted_key
skip 'openssl is missing' unless Gem::HAVE_OPENSSL
pend 'openssl is missing' unless Gem::HAVE_OPENSSL
spec = Gem::Specification.new 'build', '1'
spec.summary = 'build'
@ -543,7 +543,7 @@ class TestGemPackage < Gem::Package::TarTestCase
package.extract_tar_gz tgz_io, @destination
rescue Errno::EACCES => e
if win_platform?
skip "symlink - must be admin with no UAC on Windows"
pend "symlink - must be admin with no UAC on Windows"
else
raise e
end
@ -582,7 +582,7 @@ class TestGemPackage < Gem::Package::TarTestCase
assert_equal("installing into parent path lib/link/outside.txt of " +
"#{destination_subdir} is not allowed", e.message)
elsif win_platform?
skip "symlink - must be admin with no UAC on Windows"
pend "symlink - must be admin with no UAC on Windows"
else
raise e
end
@ -601,7 +601,7 @@ class TestGemPackage < Gem::Package::TarTestCase
destination_user_subdir = File.join destination_user_dir, 'dir'
FileUtils.mkdir_p destination_user_subdir
skip "TMPDIR seems too long to add it as symlink into tar" if destination_user_dir.size > 90
pend "TMPDIR seems too long to add it as symlink into tar" if destination_user_dir.size > 90
tgz_io = util_tar_gz do |tar|
tar.add_symlink 'link', destination_user_dir, 16877
@ -618,7 +618,7 @@ class TestGemPackage < Gem::Package::TarTestCase
assert_equal("installing into parent path #{destination_user_subdir} of " +
"#{destination_subdir} is not allowed", e.message)
elsif win_platform?
skip "symlink - must be admin with no UAC on Windows"
pend "symlink - must be admin with no UAC on Windows"
else
raise e
end
@ -886,7 +886,7 @@ class TestGemPackage < Gem::Package::TarTestCase
end
def test_verify_corrupt
skip "jruby strips the null byte and does not think it's corrupt" if Gem.java_platform?
pend "jruby strips the null byte and does not think it's corrupt" if Gem.java_platform?
tf = Tempfile.open 'corrupt' do |io|
data = Gem::Util.gzip 'a' * 10
io.write \
@ -957,7 +957,7 @@ class TestGemPackage < Gem::Package::TarTestCase
end
def test_verify_security_policy
skip 'openssl is missing' unless Gem::HAVE_OPENSSL
pend 'openssl is missing' unless Gem::HAVE_OPENSSL
package = Gem::Package.new @gem
package.security_policy = Gem::Security::HighSecurity
@ -974,7 +974,7 @@ class TestGemPackage < Gem::Package::TarTestCase
end
def test_verify_security_policy_low_security
skip 'openssl is missing' unless Gem::HAVE_OPENSSL
pend 'openssl is missing' unless Gem::HAVE_OPENSSL
@spec.cert_chain = [PUBLIC_CERT.to_pem]
@spec.signing_key = PRIVATE_KEY
@ -994,7 +994,7 @@ class TestGemPackage < Gem::Package::TarTestCase
end
def test_verify_security_policy_checksum_missing
skip 'openssl is missing' unless Gem::HAVE_OPENSSL
pend 'openssl is missing' unless Gem::HAVE_OPENSSL
@spec.cert_chain = [PUBLIC_CERT.to_pem]
@spec.signing_key = PRIVATE_KEY

Просмотреть файл

@ -973,7 +973,7 @@ dependencies: []
io.write @a2.to_ruby_for_cache
end
rescue Errno::EINVAL
skip "cannot create '#{full_path}' on this platform"
pend "cannot create '#{full_path}' on this platform"
end
spec = Gem::Specification.load full_path
@ -992,7 +992,7 @@ dependencies: []
io.write @a2.to_ruby_for_cache
end
rescue Errno::EINVAL
skip "cannot create '#{full_path}' on this platform"
pend "cannot create '#{full_path}' on this platform"
end
spec = Gem::Specification.load full_path
@ -1011,7 +1011,7 @@ dependencies: []
io.write @a2.to_ruby_for_cache
end
rescue Errno::EINVAL
skip "cannot create '#{full_path}' on this platform"
pend "cannot create '#{full_path}' on this platform"
end
spec = Gem::Specification.load full_path
@ -1451,7 +1451,7 @@ dependencies: []
end
def test_build_args
skip "extensions don't quite work on jruby" if Gem.java_platform?
pend "extensions don't quite work on jruby" if Gem.java_platform?
ext_spec
assert_empty @ext.build_args
@ -1470,7 +1470,7 @@ dependencies: []
end
def test_build_extensions
skip "extensions don't quite work on jruby" if Gem.java_platform?
pend "extensions don't quite work on jruby" if Gem.java_platform?
ext_spec
assert_path_not_exist @ext.extension_dir, 'sanity check'
@ -1506,7 +1506,7 @@ dependencies: []
end
def test_build_extensions_built
skip "extensions don't quite work on jruby" if Gem.java_platform?
pend "extensions don't quite work on jruby" if Gem.java_platform?
ext_spec
refute_empty @ext.extensions, 'sanity check'
@ -1545,7 +1545,7 @@ dependencies: []
end
def test_build_extensions_error
skip "extensions don't quite work on jruby" if Gem.java_platform?
pend "extensions don't quite work on jruby" if Gem.java_platform?
ext_spec
refute_empty @ext.extensions, 'sanity check'
@ -1556,10 +1556,10 @@ dependencies: []
end
def test_build_extensions_extensions_dir_unwritable
skip 'chmod not supported' if Gem.win_platform?
skip 'skipped in root privilege' if Process.uid.zero?
pend 'chmod not supported' if Gem.win_platform?
pend 'skipped in root privilege' if Process.uid.zero?
skip "extensions don't quite work on jruby" if Gem.java_platform?
pend "extensions don't quite work on jruby" if Gem.java_platform?
ext_spec
refute_empty @ext.extensions, 'sanity check'
@ -1591,8 +1591,8 @@ dependencies: []
end
def test_build_extensions_no_extensions_dir_unwritable
skip 'chmod not supported' if Gem.win_platform?
skip "extensions don't quite work on jruby" if Gem.java_platform?
pend 'chmod not supported' if Gem.win_platform?
pend "extensions don't quite work on jruby" if Gem.java_platform?
ext_spec
refute_empty @ext.extensions, 'sanity check'
@ -1631,7 +1631,7 @@ dependencies: []
end
def test_build_extensions_preview
skip "extensions don't quite work on jruby" if Gem.java_platform?
pend "extensions don't quite work on jruby" if Gem.java_platform?
ext_spec
extconf_rb = File.join @ext.gem_dir, @ext.extensions.first
@ -1666,7 +1666,7 @@ dependencies: []
end
def test_contains_requirable_file_eh_extension
skip "extensions don't quite work on jruby" if Gem.java_platform?
pend "extensions don't quite work on jruby" if Gem.java_platform?
ext_spec
_, err = capture_output do
@ -2435,7 +2435,7 @@ end
def test_to_ruby_with_rsa_key
require 'rubygems/openssl'
skip 'openssl is missing' unless defined?(OpenSSL::PKey::RSA)
pend 'openssl is missing' unless defined?(OpenSSL::PKey::RSA)
rsa_key = OpenSSL::PKey::RSA.new(2048)
@a2.signing_key = rsa_key
@ -2649,7 +2649,7 @@ end
yaml_str = @a1.to_yaml
same_spec = YAML.unsafe_load yaml_str
same_spec = load_yaml yaml_str
assert_equal Gem::Platform.new('powerpc-darwin7'), same_spec.platform
assert_equal 'powerpc-darwin7.9.0', same_spec.original_platform
@ -2966,7 +2966,7 @@ duplicate dependency on c (>= 1.2.3, development), (~> 1.2) use:
def test_validate_empty_require_paths
if win_platform?
skip 'test_validate_empty_require_paths skipped on MS Windows (symlink)'
pend 'test_validate_empty_require_paths skipped on MS Windows (symlink)'
else
util_setup_validate
@ -2981,7 +2981,7 @@ duplicate dependency on c (>= 1.2.3, development), (~> 1.2) use:
end
def test_validate_files
skip 'test_validate_files skipped on MS Windows (symlink)' if win_platform?
pend 'test_validate_files skipped on MS Windows (symlink)' if win_platform?
util_setup_validate
@a1.files += ['lib', 'lib2']
@ -3370,7 +3370,7 @@ Did you mean 'Ruby'?
end
def test_validate_permissions
skip 'chmod not supported' if Gem.win_platform?
pend 'chmod not supported' if Gem.win_platform?
util_setup_validate
@ -3389,7 +3389,7 @@ Did you mean 'Ruby'?
end
def test_validate_permissions_of_missing_file_non_packaging
skip 'chmod not supported' if Gem.win_platform?
pend 'chmod not supported' if Gem.win_platform?
util_setup_validate
@ -3699,7 +3699,7 @@ end
end
def test_missing_extensions_eh
skip "extensions don't quite work on jruby" if Gem.java_platform?
pend "extensions don't quite work on jruby" if Gem.java_platform?
ext_spec
assert @ext.missing_extensions?