diff options
Diffstat (limited to 'test/rubygems')
4 files changed, 14 insertions, 28 deletions
diff --git a/test/rubygems/test_gem_ext_cargo_builder.rb b/test/rubygems/test_gem_ext_cargo_builder.rb index 9c1ee2ae31..5ffe5f0b6f 100644 --- a/test/rubygems/test_gem_ext_cargo_builder.rb +++ b/test/rubygems/test_gem_ext_cargo_builder.rb @@ -31,13 +31,12 @@ class TestGemExtCargoBuilder < Gem::TestCase 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 = Gem::Ext::CargoBuilder.new builder.build nil, @dest_path, output end output = output.join "\n" - bundle = File.join(@dest_path, "release/rust_ruby_example.#{RbConfig::CONFIG['DLEXT']}") + bundle = File.join(@dest_path, "rust_ruby_example.#{RbConfig::CONFIG['DLEXT']}") assert_match(/Finished/, output) assert_match(/release/, output) @@ -58,13 +57,12 @@ class TestGemExtCargoBuilder < Gem::TestCase 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 = Gem::Ext::CargoBuilder.new builder.build nil, @dest_path, output end output = output.join "\n" - bundle = File.join(@dest_path, "release/rust_ruby_example.#{RbConfig::CONFIG['DLEXT']}") + bundle = File.join(@dest_path, "rust_ruby_example.#{RbConfig::CONFIG['DLEXT']}") assert_ffi_handle bundle, "hello_from_rubygems" assert_ffi_handle bundle, "hello_from_rubygems_version" @@ -79,22 +77,17 @@ class TestGemExtCargoBuilder < Gem::TestCase skip_unsupported_platforms! setup_rust_gem "rust_ruby_example" - output = [] - FileUtils.rm(File.join(@ext, "src/lib.rs")) error = assert_raise(Gem::InstallError) do 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.build nil, @dest_path, output + builder = Gem::Ext::CargoBuilder.new + builder.build nil, @dest_path, [] end end - output = output.join "\n" - - assert_match "cargo failed", error.message + assert_match /cargo\s.*\sfailed/, error.message end def test_full_integration @@ -137,7 +130,7 @@ class TestGemExtCargoBuilder < Gem::TestCase Open3.capture2e(*gem, "install", "--verbose", "--local", built_gem, *ARGV) end - stdout_and_stderr_str, status = Open3.capture2e(env_for_subprocess, *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_ext", "-e", "puts 'Result: ' + CustomName.say_hello") assert status.success?, stdout_and_stderr_str assert_match "Result: Hello world!", stdout_and_stderr_str diff --git a/test/rubygems/test_gem_ext_cargo_builder/custom_name/custom_name.gemspec b/test/rubygems/test_gem_ext_cargo_builder/custom_name/custom_name.gemspec index 1f8e270e96..95332ec84f 100644 --- a/test/rubygems/test_gem_ext_cargo_builder/custom_name/custom_name.gemspec +++ b/test/rubygems/test_gem_ext_cargo_builder/custom_name/custom_name.gemspec @@ -5,6 +5,4 @@ Gem::Specification.new do |s| s.extensions = ["Cargo.toml"] s.authors = ["Ian Ker-Seymer"] s.files = ["Cargo.toml", "Cargo.lock", "src/lib.rs"] - - s.metadata["cargo_crate_name"] = "custom-name-ext" end diff --git a/test/rubygems/test_gem_ext_cargo_builder/custom_name/src/lib.rs b/test/rubygems/test_gem_ext_cargo_builder/custom_name/src/lib.rs index 543ad4a70e..28ba3be564 100644 --- a/test/rubygems/test_gem_ext_cargo_builder/custom_name/src/lib.rs +++ b/test/rubygems/test_gem_ext_cargo_builder/custom_name/src/lib.rs @@ -12,7 +12,7 @@ unsafe extern "C" fn say_hello(_klass: VALUE) -> VALUE { #[allow(non_snake_case)] #[no_mangle] -pub extern "C" fn Init_custom_name() { +pub extern "C" fn Init_custom_name_ext() { let name = CString::new("CustomName").unwrap(); let function_name = CString::new("say_hello").unwrap(); // bindgen does not properly detect the arity of the ruby callback function, so we have to transmute diff --git a/test/rubygems/test_gem_ext_cargo_builder_unit.rb b/test/rubygems/test_gem_ext_cargo_builder_unit.rb index dc9350bb3a..0ca8306842 100644 --- a/test/rubygems/test_gem_ext_cargo_builder_unit.rb +++ b/test/rubygems/test_gem_ext_cargo_builder_unit.rb @@ -6,8 +6,7 @@ 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) + builder = Gem::Ext::CargoBuilder.new command = builder.cargo_command(Dir.pwd, @tempdir, ["--all-features"]) assert_includes command, "--all-features" @@ -15,8 +14,7 @@ class TestGemExtCargoBuilderUnit < Gem::TestCase 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 = Gem::Ext::CargoBuilder.new builder.profile = :release command = builder.cargo_command(Dir.pwd, @tempdir) @@ -27,8 +25,7 @@ class TestGemExtCargoBuilderUnit < Gem::TestCase 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) + builder = Gem::Ext::CargoBuilder.new command = builder.cargo_command(Dir.pwd, @tempdir) assert_includes command, "mycargo" @@ -38,8 +35,7 @@ class TestGemExtCargoBuilderUnit < Gem::TestCase 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) + builder = Gem::Ext::CargoBuilder.new env = builder.build_env assert_equal env.fetch("RBCONFIG_RUBY_SO_NAME"), RbConfig::CONFIG["RUBY_SO_NAME"] @@ -49,8 +45,7 @@ class TestGemExtCargoBuilderUnit < Gem::TestCase 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) + builder = Gem::Ext::CargoBuilder.new command = builder.cargo_command(Dir.pwd, @tempdir, ["--locked"]) assert_includes command, "--target" |