summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2022-07-13 14:44:32 +0900
committernagachika <nagachika@ruby-lang.org>2022-09-03 15:54:07 +0900
commita01f5ad1ec2455e97e27eb2758588ff5e63c4131 (patch)
treecd3fd955c118214e37017265687c48d231ae0cce /test
parentb9f6a09bd2127ea51612bd27bef5830831b48d4f (diff)
Merge RubyGems-3.3.16 and Bundler-2.3.16
Diffstat (limited to 'test')
-rw-r--r--test/rubygems/data/excon-0.7.7.gemspec.rzbin0 -> 388 bytes
-rw-r--r--test/rubygems/data/pry-0.4.7.gemspec.rz (renamed from test/rubygems/data/null-type.gemspec.rz)bin433 -> 433 bytes
-rw-r--r--test/rubygems/helper.rb4
-rw-r--r--test/rubygems/test_gem.rb2
-rw-r--r--test/rubygems/test_gem_commands_sources_command.rb50
-rw-r--r--test/rubygems/test_gem_config_file.rb6
-rw-r--r--test/rubygems/test_gem_ext_cargo_builder.rb69
-rw-r--r--test/rubygems/test_gem_ext_cargo_builder/custom_name/Cargo.lock160
-rw-r--r--test/rubygems/test_gem_ext_cargo_builder/custom_name/Cargo.toml3
-rw-r--r--test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.lock160
-rw-r--r--test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.toml3
-rw-r--r--test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/build.rb4
-rw-r--r--test/rubygems/test_gem_ext_cargo_builder_link_flag_converter.rb33
-rw-r--r--test/rubygems/test_gem_ext_cargo_builder_unit.rb75
-rw-r--r--test/rubygems/test_gem_gemcutter_utilities.rb2
-rw-r--r--test/rubygems/test_gem_package.rb2
-rw-r--r--test/rubygems/test_gem_remote_fetcher.rb30
-rw-r--r--test/rubygems/test_gem_resolver.rb2
-rw-r--r--test/rubygems/test_gem_specification.rb20
-rw-r--r--test/rubygems/test_require.rb20
-rw-r--r--test/rubygems/test_rubygems.rb6
21 files changed, 435 insertions, 216 deletions
diff --git a/test/rubygems/data/excon-0.7.7.gemspec.rz b/test/rubygems/data/excon-0.7.7.gemspec.rz
new file mode 100644
index 0000000000..159bd4bb1c
--- /dev/null
+++ b/test/rubygems/data/excon-0.7.7.gemspec.rz
Binary files differ
diff --git a/test/rubygems/data/null-type.gemspec.rz b/test/rubygems/data/pry-0.4.7.gemspec.rz
index 58fc1ed8a0..58fc1ed8a0 100644
--- a/test/rubygems/data/null-type.gemspec.rz
+++ b/test/rubygems/data/pry-0.4.7.gemspec.rz
Binary files differ
diff --git a/test/rubygems/helper.rb b/test/rubygems/helper.rb
index a0b2c98505..75eed7be6b 100644
--- a/test/rubygems/helper.rb
+++ b/test/rubygems/helper.rb
@@ -618,7 +618,7 @@ class Gem::TestCase < Test::Unit::TestCase
gem = File.join(@tempdir, File.basename(gem)).tap(&Gem::UNTAINT)
end
- Gem::Installer.at(gem, options.merge({:wrappers => true})).install
+ Gem::Installer.at(gem, options.merge({ :wrappers => true })).install
end
##
@@ -1191,7 +1191,7 @@ Also, a list:
# Is this test being run on a ruby/ruby repository?
#
- def testing_ruby_repo?
+ def ruby_repo?
!ENV["GEM_COMMAND"].nil?
end
diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb
index 53fb058e99..4d9644d5c9 100644
--- a/test/rubygems/test_gem.rb
+++ b/test/rubygems/test_gem.rb
@@ -1430,7 +1430,7 @@ class TestGem < Gem::TestCase
a = util_spec "a", "1"
b = util_spec "b", "1", "c" => nil
c = util_spec "c", "2"
- d = util_spec "d", "1", {'e' => '= 1'}, "lib/d#{$$}.rb"
+ d = util_spec "d", "1", { 'e' => '= 1' }, "lib/d#{$$}.rb"
e = util_spec "e", "1"
install_specs a, c, b, e, d
diff --git a/test/rubygems/test_gem_commands_sources_command.rb b/test/rubygems/test_gem_commands_sources_command.rb
index 7bca0f3803..6a5d8b06f5 100644
--- a/test/rubygems/test_gem_commands_sources_command.rb
+++ b/test/rubygems/test_gem_commands_sources_command.rb
@@ -202,6 +202,56 @@ Error fetching http://beta-gems.example.com:
assert_equal '', @ui.error
end
+ def test_execute_add_existent_source_invalid_uri
+ spec_fetcher
+
+ uri = "https://u:p@example.com/specs.#{@marshal_version}.gz"
+
+ @cmd.handle_options %w[--add https://u:p@example.com]
+ @fetcher.data[uri] = proc do
+ raise Gem::RemoteFetcher::FetchError.new('it died', uri)
+ end
+
+ use_ui @ui do
+ assert_raise Gem::MockGemUi::TermError do
+ @cmd.execute
+ end
+ end
+
+ expected = <<-EOF
+Error fetching https://u:REDACTED@example.com:
+\tit died (https://u:REDACTED@example.com/specs.#{@marshal_version}.gz)
+ EOF
+
+ assert_equal expected, @ui.output
+ assert_equal '', @ui.error
+ end
+
+ def test_execute_add_existent_source_invalid_uri_with_error_by_chance_including_the_uri_password
+ spec_fetcher
+
+ uri = "https://u:secret@example.com/specs.#{@marshal_version}.gz"
+
+ @cmd.handle_options %w[--add https://u:secret@example.com]
+ @fetcher.data[uri] = proc do
+ raise Gem::RemoteFetcher::FetchError.new('it secretly died', uri)
+ end
+
+ use_ui @ui do
+ assert_raise Gem::MockGemUi::TermError do
+ @cmd.execute
+ end
+ end
+
+ expected = <<-EOF
+Error fetching https://u:REDACTED@example.com:
+\tit secretly died (https://u:REDACTED@example.com/specs.#{@marshal_version}.gz)
+ EOF
+
+ assert_equal expected, @ui.output
+ assert_equal '', @ui.error
+ end
+
def test_execute_add_redundant_source
spec_fetcher
diff --git a/test/rubygems/test_gem_config_file.rb b/test/rubygems/test_gem_config_file.rb
index 32375e6936..3e09079df8 100644
--- a/test/rubygems/test_gem_config_file.rb
+++ b/test/rubygems/test_gem_config_file.rb
@@ -190,7 +190,7 @@ class TestGemConfigFile < Gem::TestCase
util_config_file
- assert_equal({:rubygems => '701229f217cdf23b1344c7b4b54ca97'},
+ assert_equal({ :rubygems => '701229f217cdf23b1344c7b4b54ca97' },
@cfg.api_keys)
end
@@ -317,8 +317,8 @@ if you believe they were disclosed to a third party.
util_config_file
- assert_equal({:rubygems => '701229f217cdf23b1344c7b4b54ca97',
- :other => 'a5fdbb6ba150cbb83aad2bb2fede64c'}, @cfg.api_keys)
+ assert_equal({ :rubygems => '701229f217cdf23b1344c7b4b54ca97',
+ :other => 'a5fdbb6ba150cbb83aad2bb2fede64c' }, @cfg.api_keys)
end
def test_load_api_keys_bad_permission
diff --git a/test/rubygems/test_gem_ext_cargo_builder.rb b/test/rubygems/test_gem_ext_cargo_builder.rb
index 559a31f5ad..2da98c03e2 100644
--- a/test/rubygems/test_gem_ext_cargo_builder.rb
+++ b/test/rubygems/test_gem_ext_cargo_builder.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
require_relative 'helper'
require 'rubygems/ext'
@@ -7,12 +8,9 @@ class TestGemExtCargoBuilder < Gem::TestCase
super
@rust_envs = {
- 'CARGO_HOME' => File.join(@orig_env['HOME'], '.cargo'),
- 'RUSTUP_HOME' => File.join(@orig_env['HOME'], '.rustup'),
+ 'CARGO_HOME' => ENV.fetch('CARGO_HOME', File.join(@orig_env['HOME'], '.cargo')),
+ 'RUSTUP_HOME' => ENV.fetch('RUSTUP_HOME', File.join(@orig_env['HOME'], '.rustup')),
}
-
- system(@rust_envs, 'cargo', '-V', out: IO::NULL, err: [:child, :out])
- pend 'cargo not present' unless $?.success?
end
def setup_rust_gem(name)
@@ -57,15 +55,35 @@ class TestGemExtCargoBuilder < Gem::TestCase
end
output = output.join "\n"
-
bundle = File.join(@dest_path, "release/rust_ruby_example.#{RbConfig::CONFIG['DLEXT']}")
- require(bundle)
+ assert_match "Finished release [optimized] target(s)", output
+ assert_ffi_handle bundle, 'Init_rust_ruby_example'
+ rescue Exception => e
+ pp output if output
+
+ raise(e)
+ end
- assert_match RustRubyExample.reverse('hello'), 'olleh'
+ def test_build_dev_profile
+ skip_unsupported_platforms!
+ setup_rust_gem "rust_ruby_example"
- assert_match "Compiling rust_ruby_example v0.1.0", output
- assert_match "Finished release [optimized] target(s)", output
+ output = []
+
+ Dir.chdir @ext do
+ ENV.update(@rust_envs)
+ spec = Gem::Specification.new 'rust_ruby_example', '0.1.0'
+ builder = Gem::Ext::CargoBuilder.new(spec)
+ builder.profile = :dev
+ builder.build nil, @dest_path, output
+ end
+
+ output = output.join "\n"
+ bundle = File.join(@dest_path, "debug/rust_ruby_example.#{RbConfig::CONFIG['DLEXT']}")
+
+ assert_match "Finished dev [unoptimized + debuginfo] target(s)", output
+ assert_ffi_handle bundle, 'Init_rust_ruby_example'
rescue Exception => e
pp output if output
@@ -98,21 +116,23 @@ class TestGemExtCargoBuilder < Gem::TestCase
skip_unsupported_platforms!
setup_rust_gem "rust_ruby_example"
+ require 'open3'
+
Dir.chdir @ext do
require 'tmpdir'
- gem = [@rust_envs, *ruby_with_rubygems_in_load_path, File.expand_path('../../bin/gem', __dir__)]
+ env_for_subprocess = @rust_envs.merge("GEM_HOME" => Gem.paths.home)
+ gem = [env_for_subprocess, *ruby_with_rubygems_in_load_path, File.expand_path('../../bin/gem', __dir__)]
Dir.mktmpdir("rust_ruby_example") do |dir|
built_gem = File.expand_path(File.join(dir, "rust_ruby_example.gem"))
Open3.capture2e(*gem, "build", "rust_ruby_example.gemspec", "--output", built_gem)
Open3.capture2e(*gem, "install", "--verbose", "--local", built_gem, *ARGV)
- end
- stdout_and_stderr_str, status = Open3.capture2e(@rust_envs, *ruby_with_rubygems_in_load_path, "-rrust_ruby_example", "-e", "puts 'Result: ' + RustRubyExample.reverse('hello world')")
-
- assert status.success?, stdout_and_stderr_str
- assert_match "Result: #{"hello world".reverse}", stdout_and_stderr_str
+ stdout_and_stderr_str, status = Open3.capture2e(env_for_subprocess, *ruby_with_rubygems_in_load_path, "-rrust_ruby_example", "-e", "puts 'Result: ' + RustRubyExample.reverse('hello world')")
+ assert status.success?, stdout_and_stderr_str
+ assert_match "Result: #{"hello world".reverse}", stdout_and_stderr_str
+ end
end
end
@@ -123,7 +143,8 @@ class TestGemExtCargoBuilder < Gem::TestCase
Dir.chdir @ext do
require 'tmpdir'
- gem = [@rust_envs, *ruby_with_rubygems_in_load_path, File.expand_path('../../bin/gem', __dir__)]
+ env_for_subprocess = @rust_envs.merge("GEM_HOME" => Gem.paths.home)
+ gem = [env_for_subprocess, *ruby_with_rubygems_in_load_path, File.expand_path('../../bin/gem', __dir__)]
Dir.mktmpdir("custom_name") do |dir|
built_gem = File.expand_path(File.join(dir, "custom_name.gem"))
@@ -131,17 +152,27 @@ class TestGemExtCargoBuilder < Gem::TestCase
Open3.capture2e(*gem, "install", "--verbose", "--local", built_gem, *ARGV)
end
- stdout_and_stderr_str, status = Open3.capture2e(@rust_envs, *ruby_with_rubygems_in_load_path, "-rcustom_name", "-e", "puts 'Result: ' + CustomName.say_hello")
+ stdout_and_stderr_str, status = Open3.capture2e(env_for_subprocess, *ruby_with_rubygems_in_load_path, "-rcustom_name", "-e", "puts 'Result: ' + CustomName.say_hello")
assert status.success?, stdout_and_stderr_str
assert_match "Result: Hello world!", stdout_and_stderr_str
end
end
+ private
+
def skip_unsupported_platforms!
pend "jruby not supported" if java_platform?
pend "truffleruby not supported (yet)" if RUBY_ENGINE == 'truffleruby'
pend "mswin not supported (yet)" if /mswin/ =~ RUBY_PLATFORM && ENV.key?('GITHUB_ACTIONS')
- pend "ruby.h is not provided by ruby repo" if testing_ruby_repo?
+ system(@rust_envs, 'cargo', '-V', out: IO::NULL, err: [:child, :out])
+ pend 'cargo not present' unless $?.success?
+ pend "ruby.h is not provided by ruby repo" if ruby_repo?
+ end
+
+ def assert_ffi_handle(bundle, name)
+ require 'fiddle'
+ dylib_handle = Fiddle.dlopen bundle
+ assert_nothing_raised { dylib_handle[name] }
end
end
diff --git a/test/rubygems/test_gem_ext_cargo_builder/custom_name/Cargo.lock b/test/rubygems/test_gem_ext_cargo_builder/custom_name/Cargo.lock
index b1b94017b5..cb1bdb3c61 100644
--- a/test/rubygems/test_gem_ext_cargo_builder/custom_name/Cargo.lock
+++ b/test/rubygems/test_gem_ext_cargo_builder/custom_name/Cargo.lock
@@ -12,6 +12,15 @@ dependencies = [
]
[[package]]
+name = "ansi_term"
+version = "0.12.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
+dependencies = [
+ "winapi",
+]
+
+[[package]]
name = "atty"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -23,15 +32,10 @@ dependencies = [
]
[[package]]
-name = "autocfg"
-version = "1.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
-
-[[package]]
name = "bindgen"
version = "0.59.2"
-source = "git+https://github.com/rust-lang/rust-bindgen?rev=f34e4103f304500c96d332f5cecc9067c980d0f9#f34e4103f304500c96d332f5cecc9067c980d0f9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2bd2a9a458e8f4304c52c43ebb0cfbd520289f8379a52e329a38afda99bf8eb8"
dependencies = [
"bitflags",
"cexpr",
@@ -57,6 +61,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
+name = "cc"
+version = "1.0.73"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11"
+
+[[package]]
name = "cexpr"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -73,9 +83,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "clang-sys"
-version = "1.3.1"
+version = "1.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4cc00842eed744b858222c4c9faf7243aafc6d33f92f96935263ef4d8a41ce21"
+checksum = "5a050e2153c5be08febd6734e29298e844fdb0fa21aeddd63b4eb7baa106c69b"
dependencies = [
"glob",
"libc",
@@ -84,17 +94,17 @@ dependencies = [
[[package]]
name = "clap"
-version = "3.1.5"
+version = "2.34.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ced1892c55c910c1219e98d6fc8d71f6bddba7905866ce740066d8bfea859312"
+checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c"
dependencies = [
+ "ansi_term",
"atty",
"bitflags",
- "indexmap",
- "os_str_bytes",
"strsim",
- "termcolor",
"textwrap",
+ "unicode-width",
+ "vec_map",
]
[[package]]
@@ -130,12 +140,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
[[package]]
-name = "hashbrown"
-version = "0.11.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e"
-
-[[package]]
name = "hermit-abi"
version = "0.1.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -151,16 +155,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
[[package]]
-name = "indexmap"
-version = "1.8.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223"
-dependencies = [
- "autocfg",
- "hashbrown",
-]
-
-[[package]]
name = "lazy_static"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -174,9 +168,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
[[package]]
name = "libc"
-version = "0.2.119"
+version = "0.2.126"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1bf2e165bb3457c8e098ea76f3e3bc9db55f87aa90d52d0e6be741470916aaa4"
+checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836"
[[package]]
name = "libloading"
@@ -189,19 +183,28 @@ dependencies = [
]
[[package]]
+name = "linkify"
+version = "0.8.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "28d9967eb7d0bc31c39c6f52e8fce42991c0cd1f7a2078326f0b7a399a584c8d"
+dependencies = [
+ "memchr",
+]
+
+[[package]]
name = "log"
-version = "0.4.14"
+version = "0.4.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710"
+checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
dependencies = [
"cfg-if",
]
[[package]]
name = "memchr"
-version = "2.4.1"
+version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a"
+checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
[[package]]
name = "minimal-lexical"
@@ -211,22 +214,12 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
[[package]]
name = "nom"
-version = "7.1.0"
+version = "7.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1b1d11e1ef389c76fe5b81bcaf2ea32cf88b62bc494e19f493d0b30e7a930109"
+checksum = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36"
dependencies = [
"memchr",
"minimal-lexical",
- "version_check",
-]
-
-[[package]]
-name = "os_str_bytes"
-version = "6.0.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64"
-dependencies = [
- "memchr",
]
[[package]]
@@ -237,43 +230,47 @@ checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
[[package]]
name = "pkg-config"
-version = "0.3.24"
+version = "0.3.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "58893f751c9b0412871a09abd62ecd2a00298c6c83befa223ef98c52aef40cbe"
+checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae"
[[package]]
name = "proc-macro2"
-version = "1.0.36"
+version = "1.0.39"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029"
+checksum = "c54b25569025b7fc9651de43004ae593a75ad88543b17178aa5e1b9c4f15f56f"
dependencies = [
- "unicode-xid",
+ "unicode-ident",
]
[[package]]
name = "quote"
-version = "1.0.15"
+version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145"
+checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1"
dependencies = [
"proc-macro2",
]
[[package]]
name = "rb-sys"
-version = "0.6.0"
-source = "git+https://github.com/ianks/rb-sys?tag=v0.6.0#1aa5b589e86a14e01aba806511818c19f85d71f6"
+version = "0.9.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f5465c5bd695ef70959b91b4ca9cfd515e9af012f6d9f0ae46f09fa4bcc3b722"
dependencies = [
"bindgen",
- "libc",
+ "cc",
+ "lazy_static",
+ "linkify",
"pkg-config",
+ "shell-words",
]
[[package]]
name = "regex"
-version = "1.5.5"
+version = "1.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286"
+checksum = "d83f127d94bdbcda4c8cc2e50f6f84f4b611f69c902699ca385a39c3a75f9ff1"
dependencies = [
"aho-corasick",
"memchr",
@@ -282,9 +279,9 @@ dependencies = [
[[package]]
name = "regex-syntax"
-version = "0.6.25"
+version = "0.6.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b"
+checksum = "49b3de9ec5dc0a3417da371aab17d729997c15010e7fd24ff707773a33bddb64"
[[package]]
name = "rustc-hash"
@@ -293,6 +290,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
[[package]]
+name = "shell-words"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde"
+
+[[package]]
name = "shlex"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -300,9 +303,9 @@ checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3"
[[package]]
name = "strsim"
-version = "0.10.0"
+version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
+checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
[[package]]
name = "termcolor"
@@ -315,27 +318,36 @@ dependencies = [
[[package]]
name = "textwrap"
-version = "0.15.0"
+version = "0.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
+dependencies = [
+ "unicode-width",
+]
+
+[[package]]
+name = "unicode-ident"
+version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb"
+checksum = "d22af068fba1eb5edcb4aea19d382b2a3deb4c8f9d475c589b6ada9e0fd493ee"
[[package]]
-name = "unicode-xid"
-version = "0.2.2"
+name = "unicode-width"
+version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
+checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973"
[[package]]
-name = "version_check"
-version = "0.9.4"
+name = "vec_map"
+version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
+checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
[[package]]
name = "which"
-version = "4.2.4"
+version = "4.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2a5a7e487e921cf220206864a94a89b6c6905bfc19f1057fa26a4cb360e5c1d2"
+checksum = "5c4fb54e6113b6a8772ee41c3404fb0301ac79604489467e0a9ce1f3e97c24ae"
dependencies = [
"either",
"lazy_static",
diff --git a/test/rubygems/test_gem_ext_cargo_builder/custom_name/Cargo.toml b/test/rubygems/test_gem_ext_cargo_builder/custom_name/Cargo.toml
index e0232f729d..cbc9225140 100644
--- a/test/rubygems/test_gem_ext_cargo_builder/custom_name/Cargo.toml
+++ b/test/rubygems/test_gem_ext_cargo_builder/custom_name/Cargo.toml
@@ -6,5 +6,4 @@ version = "0.1.0"
crate-type = ["cdylib"]
[dependencies]
-# Needed until bindgen has the `allowlist_file` feature
-rb-sys = { git = "https://github.com/ianks/rb-sys", tag = "v0.6.0" }
+rb-sys = "0.9.4"
diff --git a/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.lock b/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.lock
index accff220e5..edbeda8420 100644
--- a/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.lock
+++ b/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.lock
@@ -12,6 +12,15 @@ dependencies = [
]
[[package]]
+name = "ansi_term"
+version = "0.12.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
+dependencies = [
+ "winapi",
+]
+
+[[package]]
name = "atty"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -23,15 +32,10 @@ dependencies = [
]
[[package]]
-name = "autocfg"
-version = "1.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
-
-[[package]]
name = "bindgen"
version = "0.59.2"
-source = "git+https://github.com/rust-lang/rust-bindgen?rev=f34e4103f304500c96d332f5cecc9067c980d0f9#f34e4103f304500c96d332f5cecc9067c980d0f9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2bd2a9a458e8f4304c52c43ebb0cfbd520289f8379a52e329a38afda99bf8eb8"
dependencies = [
"bitflags",
"cexpr",
@@ -57,6 +61,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
+name = "cc"
+version = "1.0.73"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11"
+
+[[package]]
name = "cexpr"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -73,9 +83,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "clang-sys"
-version = "1.3.1"
+version = "1.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4cc00842eed744b858222c4c9faf7243aafc6d33f92f96935263ef4d8a41ce21"
+checksum = "5a050e2153c5be08febd6734e29298e844fdb0fa21aeddd63b4eb7baa106c69b"
dependencies = [
"glob",
"libc",
@@ -84,17 +94,17 @@ dependencies = [
[[package]]
name = "clap"
-version = "3.1.5"
+version = "2.34.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ced1892c55c910c1219e98d6fc8d71f6bddba7905866ce740066d8bfea859312"
+checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c"
dependencies = [
+ "ansi_term",
"atty",
"bitflags",
- "indexmap",
- "os_str_bytes",
"strsim",
- "termcolor",
"textwrap",
+ "unicode-width",
+ "vec_map",
]
[[package]]
@@ -123,12 +133,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
[[package]]
-name = "hashbrown"
-version = "0.11.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e"
-
-[[package]]
name = "hermit-abi"
version = "0.1.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -144,16 +148,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
[[package]]
-name = "indexmap"
-version = "1.8.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223"
-dependencies = [
- "autocfg",
- "hashbrown",
-]
-
-[[package]]
name = "lazy_static"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -167,9 +161,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
[[package]]
name = "libc"
-version = "0.2.119"
+version = "0.2.126"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1bf2e165bb3457c8e098ea76f3e3bc9db55f87aa90d52d0e6be741470916aaa4"
+checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836"
[[package]]
name = "libloading"
@@ -182,19 +176,28 @@ dependencies = [
]
[[package]]
+name = "linkify"
+version = "0.8.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "28d9967eb7d0bc31c39c6f52e8fce42991c0cd1f7a2078326f0b7a399a584c8d"
+dependencies = [
+ "memchr",
+]
+
+[[package]]
name = "log"
-version = "0.4.14"
+version = "0.4.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710"
+checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
dependencies = [
"cfg-if",
]
[[package]]
name = "memchr"
-version = "2.4.1"
+version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a"
+checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
[[package]]
name = "minimal-lexical"
@@ -204,22 +207,12 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
[[package]]
name = "nom"
-version = "7.1.0"
+version = "7.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1b1d11e1ef389c76fe5b81bcaf2ea32cf88b62bc494e19f493d0b30e7a930109"
+checksum = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36"
dependencies = [
"memchr",
"minimal-lexical",
- "version_check",
-]
-
-[[package]]
-name = "os_str_bytes"
-version = "6.0.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64"
-dependencies = [
- "memchr",
]
[[package]]
@@ -230,43 +223,47 @@ checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
[[package]]
name = "pkg-config"
-version = "0.3.24"
+version = "0.3.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "58893f751c9b0412871a09abd62ecd2a00298c6c83befa223ef98c52aef40cbe"
+checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae"
[[package]]
name = "proc-macro2"
-version = "1.0.36"
+version = "1.0.39"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029"
+checksum = "c54b25569025b7fc9651de43004ae593a75ad88543b17178aa5e1b9c4f15f56f"
dependencies = [
- "unicode-xid",
+ "unicode-ident",
]
[[package]]
name = "quote"
-version = "1.0.15"
+version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145"
+checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1"
dependencies = [
"proc-macro2",
]
[[package]]
name = "rb-sys"
-version = "0.6.0"
-source = "git+https://github.com/ianks/rb-sys?tag=v0.6.0#1aa5b589e86a14e01aba806511818c19f85d71f6"
+version = "0.9.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f5465c5bd695ef70959b91b4ca9cfd515e9af012f6d9f0ae46f09fa4bcc3b722"
dependencies = [
"bindgen",
- "libc",
+ "cc",
+ "lazy_static",
+ "linkify",
"pkg-config",
+ "shell-words",
]
[[package]]
name = "regex"
-version = "1.5.5"
+version = "1.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286"
+checksum = "d83f127d94bdbcda4c8cc2e50f6f84f4b611f69c902699ca385a39c3a75f9ff1"
dependencies = [
"aho-corasick",
"memchr",
@@ -275,9 +272,9 @@ dependencies = [
[[package]]
name = "regex-syntax"
-version = "0.6.25"
+version = "0.6.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b"
+checksum = "49b3de9ec5dc0a3417da371aab17d729997c15010e7fd24ff707773a33bddb64"
[[package]]
name = "rust_ruby_example"
@@ -293,6 +290,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
[[package]]
+name = "shell-words"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde"
+
+[[package]]
name = "shlex"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -300,9 +303,9 @@ checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3"
[[package]]
name = "strsim"
-version = "0.10.0"
+version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
+checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
[[package]]
name = "termcolor"
@@ -315,27 +318,36 @@ dependencies = [
[[package]]
name = "textwrap"
-version = "0.15.0"
+version = "0.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
+dependencies = [
+ "unicode-width",
+]
+
+[[package]]
+name = "unicode-ident"
+version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb"
+checksum = "d22af068fba1eb5edcb4aea19d382b2a3deb4c8f9d475c589b6ada9e0fd493ee"
[[package]]
-name = "unicode-xid"
-version = "0.2.2"
+name = "unicode-width"
+version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
+checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973"
[[package]]
-name = "version_check"
-version = "0.9.4"
+name = "vec_map"
+version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
+checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
[[package]]
name = "which"
-version = "4.2.4"
+version = "4.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2a5a7e487e921cf220206864a94a89b6c6905bfc19f1057fa26a4cb360e5c1d2"
+checksum = "5c4fb54e6113b6a8772ee41c3404fb0301ac79604489467e0a9ce1f3e97c24ae"
dependencies = [
"either",
"lazy_static",
diff --git a/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.toml b/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.toml
index 66a98f3885..3aec0690b0 100644
--- a/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.toml
+++ b/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.toml
@@ -6,5 +6,4 @@ version = "0.1.0"
crate-type = ["cdylib"]
[dependencies]
-# Needed until bindgen has the `allowlist_file` feature
-rb-sys = { git = "https://github.com/ianks/rb-sys", tag = "v0.6.0" }
+rb-sys = "0.9.4"
diff --git a/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/build.rb b/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/build.rb
index da9e82315e..869bbb5de8 100644
--- a/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/build.rb
+++ b/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/build.rb
@@ -15,7 +15,7 @@ gemspec = File.expand_path('rust_ruby_example.gemspec', __dir__)
Dir.mktmpdir("rust_ruby_example") do |dir|
built_gem = File.expand_path(File.join(dir, "rust_ruby_example.gem"))
- system *gem, "build", gemspec, "--output", built_gem
- system *gem, "install", "--verbose", "--local", built_gem, *ARGV
+ system(*gem, "build", gemspec, "--output", built_gem)
+ system(*gem, "install", "--verbose", "--local", built_gem, *ARGV)
system %q(ruby -rrust_ruby_example -e "puts 'Result: ' + RustRubyExample.reverse('hello world')")
end
diff --git a/test/rubygems/test_gem_ext_cargo_builder_link_flag_converter.rb b/test/rubygems/test_gem_ext_cargo_builder_link_flag_converter.rb
new file mode 100644
index 0000000000..3abcb83fa9
--- /dev/null
+++ b/test/rubygems/test_gem_ext_cargo_builder_link_flag_converter.rb
@@ -0,0 +1,33 @@
+# frozen_string_literal: true
+require_relative 'helper'
+require 'rubygems/ext'
+require 'rubygems/ext/cargo_builder/link_flag_converter'
+
+class TestGemExtCargoBuilderLinkFlagConverter < Gem::TestCase
+ CASES = {
+ test_search_path_basic: ["-L/usr/local/lib", ["-L", "native=/usr/local/lib"]],
+ test_search_path_space: ["-L /usr/local/lib", ["-L", "native=/usr/local/lib"]],
+ test_search_path_space_in_path: ["-L/usr/local/my\ lib", ["-L", "native=/usr/local/my\ lib"]],
+ test_simple_lib: ["-lfoo", ["-l", "foo"]],
+ test_lib_with_nonascii: ["-lws2_32", ["-l", "ws2_32"]],
+ test_simple_lib_space: ["-l foo", ["-l", "foo"]],
+ test_verbose_lib_space: ["--library=foo", ["-l", "foo"]],
+ test_libstatic_with_colon: ["-l:libssp.a", ["-l", "static=ssp"]],
+ test_libstatic_with_colon_space: ["-l :libssp.a", ["-l", "static=ssp"]],
+ test_unconventional_lib_with_colon: ["-l:ssp.a", ["-C", "link_arg=-l:ssp.a"]],
+ test_dylib_with_colon_space: ["-l :libssp.dylib", ["-l", "dylib=ssp"]],
+ test_so_with_colon_space: ["-l :libssp.so", ["-l", "dylib=ssp"]],
+ test_dll_with_colon_space: ["-l :libssp.dll", ["-l", "dylib=ssp"]],
+ test_framework: ["-F/some/path", ["-l", "framework=/some/path"]],
+ test_framework_space: ["-F /some/path", ["-l", "framework=/some/path"]],
+ test_non_lib_dash_l: ["test_rubygems_20220413-976-lemgf9/prefix", ["-C", "link_arg=test_rubygems_20220413-976-lemgf9/prefix"]],
+ }.freeze
+
+ CASES.each do |test_name, (arg, expected)|
+ raise "duplicate test name" if instance_methods.include?(test_name)
+
+ define_method(test_name) do
+ assert_equal(expected, Gem::Ext::CargoBuilder::LinkFlagConverter.convert(arg))
+ end
+ end
+end
diff --git a/test/rubygems/test_gem_ext_cargo_builder_unit.rb b/test/rubygems/test_gem_ext_cargo_builder_unit.rb
new file mode 100644
index 0000000000..f6712e44a1
--- /dev/null
+++ b/test/rubygems/test_gem_ext_cargo_builder_unit.rb
@@ -0,0 +1,75 @@
+# frozen_string_literal: true
+
+require_relative 'helper'
+require 'rubygems/ext'
+
+class TestGemExtCargoBuilderUnit < Gem::TestCase
+ def test_cargo_command_passes_args
+ skip_unsupported_platforms!
+ spec = Gem::Specification.new 'rust_ruby_example', '0.1.0'
+ builder = Gem::Ext::CargoBuilder.new(spec)
+ command = builder.cargo_command(Dir.pwd, @tempdir, ['--all-features'])
+
+ assert_includes command, '--all-features'
+ end
+
+ def test_cargo_command_locks_in_release_profile
+ skip_unsupported_platforms!
+ spec = Gem::Specification.new 'rust_ruby_example', '0.1.0'
+ builder = Gem::Ext::CargoBuilder.new(spec)
+ builder.profile = :release
+ command = builder.cargo_command(Dir.pwd, @tempdir)
+
+ assert_includes command, '--locked'
+ end
+
+ def test_cargo_command_does_not_lock_in_dev_profile
+ skip_unsupported_platforms!
+ spec = Gem::Specification.new 'rust_ruby_example', '0.1.0'
+ builder = Gem::Ext::CargoBuilder.new(spec)
+ builder.profile = :dev
+ command = builder.cargo_command(Dir.pwd, @tempdir)
+
+ assert_not_includes command, '--locked'
+ end
+
+ def test_cargo_command_passes_respects_cargo_env_var
+ skip_unsupported_platforms!
+ old_cargo = ENV['CARGO']
+ ENV['CARGO'] = 'mycargo'
+ spec = Gem::Specification.new 'rust_ruby_example', '0.1.0'
+ builder = Gem::Ext::CargoBuilder.new(spec)
+ command = builder.cargo_command(Dir.pwd, @tempdir)
+
+ assert_includes command, 'mycargo'
+ ensure
+ ENV['CARGO'] = old_cargo
+ end
+
+ def test_build_env_includes_rbconfig
+ skip_unsupported_platforms!
+ spec = Gem::Specification.new 'rust_ruby_example', '0.1.0'
+ builder = Gem::Ext::CargoBuilder.new(spec)
+ env = builder.build_env
+
+ assert_equal env.fetch('RBCONFIG_RUBY_SO_NAME'), RbConfig::CONFIG['RUBY_SO_NAME']
+ end
+
+ def test_cargo_command_passes_respects_cargo_build_target
+ skip_unsupported_platforms!
+ old_cargo = ENV['CARGO_BUILD_TARGET']
+ ENV['CARGO_BUILD_TARGET'] = 'x86_64-unknown-linux-gnu'
+ spec = Gem::Specification.new 'rust_ruby_example', '0.1.0'
+ builder = Gem::Ext::CargoBuilder.new(spec)
+ command = builder.cargo_command(Dir.pwd, @tempdir, ['--locked'])
+
+ assert_includes command, '--target'
+ assert_includes command, 'x86_64-unknown-linux-gnu'
+ ensure
+ ENV['CARGO_BUILD_TARGET'] = old_cargo
+ end
+
+ def skip_unsupported_platforms!
+ pend "jruby not supported" if java_platform?
+ end
+end
diff --git a/test/rubygems/test_gem_gemcutter_utilities.rb b/test/rubygems/test_gem_gemcutter_utilities.rb
index 667aba4701..9bfc22a202 100644
--- a/test/rubygems/test_gem_gemcutter_utilities.rb
+++ b/test/rubygems/test_gem_gemcutter_utilities.rb
@@ -254,7 +254,7 @@ class TestGemGemcutterUtilities < Gem::TestCase
end
def test_verify_api_key
- keys = {:other => 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903'}
+ keys = { :other => 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903' }
File.open Gem.configuration.credentials_path, 'w' do |f|
f.write keys.to_yaml
end
diff --git a/test/rubygems/test_gem_package.rb b/test/rubygems/test_gem_package.rb
index 9172b7eef5..34660bdccd 100644
--- a/test/rubygems/test_gem_package.rb
+++ b/test/rubygems/test_gem_package.rb
@@ -218,7 +218,7 @@ class TestGemPackage < Gem::Package::TarTestCase
end
assert_equal %w[lib/code.rb], files
- assert_equal [{'lib/code_sym.rb' => 'code.rb'}, {'lib/code_sym2.rb' => '../lib/code.rb'}], symlinks
+ assert_equal [{ 'lib/code_sym.rb' => 'code.rb' }, { 'lib/code_sym2.rb' => '../lib/code.rb' }], symlinks
end
def test_build
diff --git a/test/rubygems/test_gem_remote_fetcher.rb b/test/rubygems/test_gem_remote_fetcher.rb
index 3ce9be7c90..fa82a117a1 100644
--- a/test/rubygems/test_gem_remote_fetcher.rb
+++ b/test/rubygems/test_gem_remote_fetcher.rb
@@ -705,7 +705,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
def test_fetch_http_with_additional_headers
ENV["http_proxy"] = @proxy_uri
ENV["no_proxy"] = URI::parse(@server_uri).host
- fetcher = Gem::RemoteFetcher.new nil, nil, {"X-Captain" => "murphy"}
+ fetcher = Gem::RemoteFetcher.new nil, nil, { "X-Captain" => "murphy" }
@fetcher = fetcher
assert_equal "murphy", fetcher.fetch_path(@server_uri)
end
@@ -745,7 +745,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
def test_fetch_s3_config_creds
Gem.configuration[:s3_source] = {
- 'my-bucket' => {:id => 'testuser', :secret => 'testpass'},
+ 'my-bucket' => { :id => 'testuser', :secret => 'testpass' },
}
url = 's3://my-bucket/gems/specs.4.8.gz'
Time.stub :now, Time.at(1561353581) do
@@ -757,7 +757,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
def test_fetch_s3_config_creds_with_region
Gem.configuration[:s3_source] = {
- 'my-bucket' => {:id => 'testuser', :secret => 'testpass', :region => 'us-west-2'},
+ 'my-bucket' => { :id => 'testuser', :secret => 'testpass', :region => 'us-west-2' },
}
url = 's3://my-bucket/gems/specs.4.8.gz'
Time.stub :now, Time.at(1561353581) do
@@ -769,7 +769,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
def test_fetch_s3_config_creds_with_token
Gem.configuration[:s3_source] = {
- 'my-bucket' => {:id => 'testuser', :secret => 'testpass', :security_token => 'testtoken'},
+ 'my-bucket' => { :id => 'testuser', :secret => 'testpass', :security_token => 'testtoken' },
}
url = 's3://my-bucket/gems/specs.4.8.gz'
Time.stub :now, Time.at(1561353581) do
@@ -784,7 +784,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
ENV['AWS_SECRET_ACCESS_KEY'] = 'testpass'
ENV['AWS_SESSION_TOKEN'] = nil
Gem.configuration[:s3_source] = {
- 'my-bucket' => {:provider => 'env'},
+ 'my-bucket' => { :provider => 'env' },
}
url = 's3://my-bucket/gems/specs.4.8.gz'
Time.stub :now, Time.at(1561353581) do
@@ -800,7 +800,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
ENV['AWS_SECRET_ACCESS_KEY'] = 'testpass'
ENV['AWS_SESSION_TOKEN'] = nil
Gem.configuration[:s3_source] = {
- 'my-bucket' => {:provider => 'env', :region => 'us-west-2'},
+ 'my-bucket' => { :provider => 'env', :region => 'us-west-2' },
}
url = 's3://my-bucket/gems/specs.4.8.gz'
Time.stub :now, Time.at(1561353581) do
@@ -816,7 +816,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
ENV['AWS_SECRET_ACCESS_KEY'] = 'testpass'
ENV['AWS_SESSION_TOKEN'] = 'testtoken'
Gem.configuration[:s3_source] = {
- 'my-bucket' => {:provider => 'env'},
+ 'my-bucket' => { :provider => 'env' },
}
url = 's3://my-bucket/gems/specs.4.8.gz'
Time.stub :now, Time.at(1561353581) do
@@ -836,7 +836,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
def test_fetch_s3_instance_profile_creds
Gem.configuration[:s3_source] = {
- 'my-bucket' => {:provider => 'instance_profile'},
+ 'my-bucket' => { :provider => 'instance_profile' },
}
url = 's3://my-bucket/gems/specs.4.8.gz'
@@ -850,7 +850,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
def test_fetch_s3_instance_profile_creds_with_region
Gem.configuration[:s3_source] = {
- 'my-bucket' => {:provider => 'instance_profile', :region => 'us-west-2'},
+ 'my-bucket' => { :provider => 'instance_profile', :region => 'us-west-2' },
}
url = 's3://my-bucket/gems/specs.4.8.gz'
@@ -864,7 +864,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
def test_fetch_s3_instance_profile_creds_with_token
Gem.configuration[:s3_source] = {
- 'my-bucket' => {:provider => 'instance_profile'},
+ 'my-bucket' => { :provider => 'instance_profile' },
}
url = 's3://my-bucket/gems/specs.4.8.gz'
@@ -894,7 +894,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
def test_fetch_s3_no_host
Gem.configuration[:s3_source] = {
- 'my-bucket' => {:id => 'testuser', :secret => 'testpass'},
+ 'my-bucket' => { :id => 'testuser', :secret => 'testpass' },
}
url = 's3://other-bucket/gems/specs.4.8.gz'
@@ -904,7 +904,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
end
def test_fetch_s3_no_id
- Gem.configuration[:s3_source] = { 'my-bucket' => {:secret => 'testpass'} }
+ Gem.configuration[:s3_source] = { 'my-bucket' => { :secret => 'testpass' } }
url = 's3://my-bucket/gems/specs.4.8.gz'
refute_fetch_s3 url, 's3_source for my-bucket missing id or secret'
@@ -913,7 +913,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
end
def test_fetch_s3_no_secret
- Gem.configuration[:s3_source] = { 'my-bucket' => {:id => 'testuser'} }
+ Gem.configuration[:s3_source] = { 'my-bucket' => { :id => 'testuser' } }
url = 's3://my-bucket/gems/specs.4.8.gz'
refute_fetch_s3 url, 's3_source for my-bucket missing id or secret'
@@ -973,7 +973,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
def test_ssl_client_cert_auth_connection
ssl_server = start_ssl_server({
:SSLVerifyClient =>
- OpenSSL::SSL::VERIFY_PEER | OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT})
+ OpenSSL::SSL::VERIFY_PEER | OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT })
temp_ca_cert = File.join(__dir__, 'ca_cert.pem')
temp_client_cert = File.join(__dir__, 'client.pem')
@@ -988,7 +988,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
def test_do_not_allow_invalid_client_cert_auth_connection
ssl_server = start_ssl_server({
:SSLVerifyClient =>
- OpenSSL::SSL::VERIFY_PEER | OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT})
+ OpenSSL::SSL::VERIFY_PEER | OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT })
temp_ca_cert = File.join(__dir__, 'ca_cert.pem')
temp_client_cert = File.join(__dir__, 'invalid_client.pem')
diff --git a/test/rubygems/test_gem_resolver.rb b/test/rubygems/test_gem_resolver.rb
index ea9f9049ce..ab0cdaddb9 100644
--- a/test/rubygems/test_gem_resolver.rb
+++ b/test/rubygems/test_gem_resolver.rb
@@ -191,7 +191,7 @@ class TestGemResolver < Gem::TestCase
# With the following gems already installed:
# a-1, b-1, c-1, e-1
- res.skip_gems = {'a' => [a1_spec], 'b' => [b1_spec], 'c' => [c1_spec], 'e' => [e1_spec]}
+ res.skip_gems = { 'a' => [a1_spec], 'b' => [b1_spec], 'c' => [c1_spec], 'e' => [e1_spec] }
# Make sure the following gems end up getting used/installed/upgraded:
# a-2 (upgraded)
diff --git a/test/rubygems/test_gem_specification.rb b/test/rubygems/test_gem_specification.rb
index ccb81caf37..3f88fd1910 100644
--- a/test/rubygems/test_gem_specification.rb
+++ b/test/rubygems/test_gem_specification.rb
@@ -158,7 +158,7 @@ end
util_spec "pkg#{pkgi}", pkg_version.to_s, deps
end
end
- base = util_spec "pkg_base", "1", {"pkg0" => ">= 0"}
+ base = util_spec "pkg_base", "1", { "pkg0" => ">= 0" }
Gem::Specification.reset
install_specs(*packages.flatten.reverse)
@@ -305,10 +305,10 @@ end
def test_require_should_not_conflict
base = util_spec "0", "1", "A" => ">= 1"
- a1 = util_spec "A", "1", {"c" => ">= 2", "b" => "> 0"}, "lib/a.rb"
- a2 = util_spec "A", "2", {"c" => ">= 2", "b" => "> 0"}, "lib/a.rb"
- b1 = util_spec "b", "1", {"c" => "= 1"}, "lib/d#{$$}.rb"
- b2 = util_spec "b", "2", {"c" => "= 2"}, "lib/d#{$$}.rb"
+ a1 = util_spec "A", "1", { "c" => ">= 2", "b" => "> 0" }, "lib/a.rb"
+ a2 = util_spec "A", "2", { "c" => ">= 2", "b" => "> 0" }, "lib/a.rb"
+ b1 = util_spec "b", "1", { "c" => "= 1" }, "lib/d#{$$}.rb"
+ b2 = util_spec "b", "2", { "c" => "= 2" }, "lib/d#{$$}.rb"
c1 = util_spec "c", "1", {}, "lib/c.rb"
c2 = util_spec "c", "2", {}, "lib/c.rb"
c3 = util_spec "c", "3", {}, "lib/c.rb"
@@ -1068,7 +1068,15 @@ dependencies: []
end
def test_handles_private_null_type
- path = File.expand_path 'data/null-type.gemspec.rz', __dir__
+ path = File.expand_path 'data/pry-0.4.7.gemspec.rz', __dir__
+
+ data = Marshal.load Gem::Util.inflate(Gem.read_binary(path))
+
+ assert_instance_of Gem::Specification, data
+ end
+
+ def test_handles_dependencies_with_syck_requirements_bug
+ path = File.expand_path 'data/excon-0.7.7.gemspec.rz', __dir__
data = Marshal.load Gem::Util.inflate(Gem.read_binary(path))
diff --git a/test/rubygems/test_require.rb b/test/rubygems/test_require.rb
index 9aa057442a..3e393a4df3 100644
--- a/test/rubygems/test_require.rb
+++ b/test/rubygems/test_require.rb
@@ -63,8 +63,8 @@ class TestGemRequire < Gem::TestCase
# Providing -I on the commandline should always beat gems
def test_dash_i_beats_gems
- a1 = util_spec "a", "1", {"b" => "= 1"}, "lib/test_gem_require_a.rb"
- b1 = util_spec "b", "1", {"c" => "> 0"}, "lib/b/c.rb"
+ a1 = util_spec "a", "1", { "b" => "= 1" }, "lib/test_gem_require_a.rb"
+ b1 = util_spec "b", "1", { "c" => "> 0" }, "lib/b/c.rb"
c1 = util_spec "c", "1", nil, "lib/c/c.rb"
c2 = util_spec "c", "2", nil, "lib/c/c.rb"
@@ -102,8 +102,8 @@ class TestGemRequire < Gem::TestCase
# Providing -I on the commandline should always beat gems
def test_dash_i_beats_default_gems
- a1 = new_default_spec "a", "1", {"b" => "= 1"}, "test_gem_require_a.rb"
- b1 = new_default_spec "b", "1", {"c" => "> 0"}, "b/c.rb"
+ a1 = new_default_spec "a", "1", { "b" => "= 1" }, "test_gem_require_a.rb"
+ b1 = new_default_spec "b", "1", { "c" => "> 0" }, "b/c.rb"
c1 = new_default_spec "c", "1", nil, "c/c.rb"
c2 = new_default_spec "c", "2", nil, "c/c.rb"
@@ -169,7 +169,7 @@ class TestGemRequire < Gem::TestCase
end
def test_require_is_not_lazy_with_exact_req
- a1 = util_spec "a", "1", {"b" => "= 1"}, "lib/test_gem_require_a.rb"
+ a1 = util_spec "a", "1", { "b" => "= 1" }, "lib/test_gem_require_a.rb"
b1 = util_spec "b", "1", nil, "lib/b/c.rb"
b2 = util_spec "b", "2", nil, "lib/b/c.rb"
@@ -184,7 +184,7 @@ class TestGemRequire < Gem::TestCase
end
def test_require_is_lazy_with_inexact_req
- a1 = util_spec "a", "1", {"b" => ">= 1"}, "lib/test_gem_require_a.rb"
+ a1 = util_spec "a", "1", { "b" => ">= 1" }, "lib/test_gem_require_a.rb"
b1 = util_spec "b", "1", nil, "lib/b/c.rb"
b2 = util_spec "b", "2", nil, "lib/b/c.rb"
@@ -199,7 +199,7 @@ class TestGemRequire < Gem::TestCase
end
def test_require_is_not_lazy_with_one_possible
- a1 = util_spec "a", "1", {"b" => ">= 1"}, "lib/test_gem_require_a.rb"
+ a1 = util_spec "a", "1", { "b" => ">= 1" }, "lib/test_gem_require_a.rb"
b1 = util_spec "b", "1", nil, "lib/b/c.rb"
install_specs b1, a1
@@ -243,7 +243,7 @@ class TestGemRequire < Gem::TestCase
require 'benchmark' # the stdlib
- a1 = util_spec "a", "1", {"b" => ">= 1"}, "lib/test_gem_require_a.rb"
+ a1 = util_spec "a", "1", { "b" => ">= 1" }, "lib/test_gem_require_a.rb"
b1 = util_spec "b", "1", nil, "lib/benchmark.rb"
b2 = util_spec "b", "2", nil, "lib/benchmark.rb"
@@ -444,7 +444,7 @@ class TestGemRequire < Gem::TestCase
end
def test_realworld_default_gem
- omit "this test can't work under ruby-core setup" if testing_ruby_repo?
+ omit "this test can't work under ruby-core setup" if ruby_repo?
cmd = <<-RUBY
$stderr = $stdout
@@ -457,7 +457,7 @@ class TestGemRequire < Gem::TestCase
end
def test_realworld_upgraded_default_gem
- omit "this test can't work under ruby-core setup" if testing_ruby_repo?
+ omit "this test can't work under ruby-core setup" if ruby_repo?
newer_json = util_spec("json", "999.99.9", nil, ["lib/json.rb"])
install_gem newer_json
diff --git a/test/rubygems/test_rubygems.rb b/test/rubygems/test_rubygems.rb
index cc650ff343..739a9985b0 100644
--- a/test/rubygems/test_rubygems.rb
+++ b/test/rubygems/test_rubygems.rb
@@ -2,7 +2,7 @@ require_relative 'helper'
class GemTest < Gem::TestCase
def test_rubygems_normal_behaviour
- _ = Gem::Util.popen(*ruby_with_rubygems_in_load_path, '-e', "'require \"rubygems\"'", {:err => [:child, :out]}).strip
+ _ = Gem::Util.popen(*ruby_with_rubygems_in_load_path, '-e', "'require \"rubygems\"'", { :err => [:child, :out] }).strip
assert $?.success?
end
@@ -13,7 +13,7 @@ class GemTest < Gem::TestCase
intentionally_not_implemented_method
RUBY
- output = Gem::Util.popen(*ruby_with_rubygems_and_fake_operating_system_in_load_path(path), '-e', "'require \"rubygems\"'", {:err => [:child, :out]}).strip
+ output = Gem::Util.popen(*ruby_with_rubygems_and_fake_operating_system_in_load_path(path), '-e', "'require \"rubygems\"'", { :err => [:child, :out] }).strip
assert !$?.success?
assert_includes output, "undefined local variable or method `intentionally_not_implemented_method'"
assert_includes output, "Loading the rubygems/defaults/operating_system.rb file caused an error. " \
@@ -40,7 +40,7 @@ class GemTest < Gem::TestCase
*ruby_with_rubygems_and_fake_operating_system_in_load_path(path),
'-e',
"require \"rubygems\"; puts Gem::Specification.stubs.map(&:full_name)",
- {:err => [:child, :out]}
+ { :err => [:child, :out] }
).strip
begin
assert_empty output