[rubygems/rubygems] Fix pending Bundler specs

When testing under the ruby/ruby setup, mkmf.rb needs to the `$extout`
global variable set properly.

This is because, in this particular case, the `ruby.h` header needed to
compile extensions is constructed from
`$(extout)/include($arch)/ruby/config.h` but `$extout` is not set by
default.

I tried to fix this in mkmf.rb itself but I couldn't figure it. But
setting it externally to workaround the issue fixes the specs, so I'll
start with that. Also setting it externally causes issues when running
specs upstream against Ruby 2.3 (I guess because of some difference with
Ruby 2.3 mkmf.rb implementation). So I'm avoiding doing it on Ruby 2.3 to
woraround that.

https://github.com/rubygems/rubygems/commit/d782984585
This commit is contained in:
David Rodríguez 2022-06-21 20:21:14 +02:00 committed by git
parent 967624bc1d
commit a782d76fbe
9 changed files with 16 additions and 12 deletions

View File

@ -792,7 +792,7 @@ RSpec.describe "bundle clean" do
should_not_have_gems "foo-1.0" should_not_have_gems "foo-1.0"
end end
it "doesn't remove extensions artifacts from bundled git gems after clean", :ruby_repo do it "doesn't remove extensions artifacts from bundled git gems after clean" do
build_git "very_simple_git_binary", &:add_c_extension build_git "very_simple_git_binary", &:add_c_extension
revision = revision_for(lib_path("very_simple_git_binary-1.0")) revision = revision_for(lib_path("very_simple_git_binary-1.0"))
@ -815,7 +815,7 @@ RSpec.describe "bundle clean" do
expect(vendored_gems("bundler/gems/very_simple_git_binary-1.0-#{revision[0..11]}")).to exist expect(vendored_gems("bundler/gems/very_simple_git_binary-1.0-#{revision[0..11]}")).to exist
end end
it "removes extension directories", :ruby_repo do it "removes extension directories" do
gemfile <<-G gemfile <<-G
source "#{file_uri_for(gem_repo1)}" source "#{file_uri_for(gem_repo1)}"
@ -851,7 +851,7 @@ RSpec.describe "bundle clean" do
expect(simple_binary_extensions_dir).to exist expect(simple_binary_extensions_dir).to exist
end end
it "removes git extension directories", :ruby_repo do it "removes git extension directories" do
build_git "very_simple_git_binary", &:add_c_extension build_git "very_simple_git_binary", &:add_c_extension
revision = revision_for(lib_path("very_simple_git_binary-1.0")) revision = revision_for(lib_path("very_simple_git_binary-1.0"))

View File

@ -2,7 +2,7 @@
require "bundler/vendored_fileutils" require "bundler/vendored_fileutils"
RSpec.describe "bundle pristine", :ruby_repo do RSpec.describe "bundle pristine" do
before :each do before :each do
build_lib "baz", :path => bundled_app do |s| build_lib "baz", :path => bundled_app do |s|
s.version = "1.0.0" s.version = "1.0.0"

View File

@ -1206,11 +1206,12 @@ RSpec.describe "bundle install with git sources" do
expect(out).to include(Pathname.glob(default_bundle_path("bundler/gems/extensions/**/foo-1.0-*")).first.to_s) expect(out).to include(Pathname.glob(default_bundle_path("bundler/gems/extensions/**/foo-1.0-*")).first.to_s)
end end
it "does not use old extension after ref changes", :ruby_repo do it "does not use old extension after ref changes" do
git_reader = build_git "foo", :no_default => true do |s| git_reader = build_git "foo", :no_default => true do |s|
s.extensions = ["ext/extconf.rb"] s.extensions = ["ext/extconf.rb"]
s.write "ext/extconf.rb", <<-RUBY s.write "ext/extconf.rb", <<-RUBY
require "mkmf" require "mkmf"
$extout = "$(topdir)/" + RbConfig::CONFIG["EXTOUT"] unless RUBY_VERSION < "2.4"
create_makefile("foo") create_makefile("foo")
RUBY RUBY
s.write "ext/foo.c", "void Init_foo() {}" s.write "ext/foo.c", "void Init_foo() {}"

View File

@ -1,12 +1,13 @@
# frozen_string_literal: true # frozen_string_literal: true
RSpec.describe "installing a gem with native extensions", :ruby_repo do RSpec.describe "installing a gem with native extensions" do
it "installs" do it "installs" do
build_repo2 do build_repo2 do
build_gem "c_extension" do |s| build_gem "c_extension" do |s|
s.extensions = ["ext/extconf.rb"] s.extensions = ["ext/extconf.rb"]
s.write "ext/extconf.rb", <<-E s.write "ext/extconf.rb", <<-E
require "mkmf" require "mkmf"
$extout = "$(topdir)/" + RbConfig::CONFIG["EXTOUT"] unless RUBY_VERSION < "2.4"
name = "c_extension_bundle" name = "c_extension_bundle"
dir_config(name) dir_config(name)
raise "OMG" unless with_config("c_extension") == "hello" raise "OMG" unless with_config("c_extension") == "hello"
@ -51,6 +52,7 @@ RSpec.describe "installing a gem with native extensions", :ruby_repo do
s.extensions = ["ext/extconf.rb"] s.extensions = ["ext/extconf.rb"]
s.write "ext/extconf.rb", <<-E s.write "ext/extconf.rb", <<-E
require "mkmf" require "mkmf"
$extout = "$(topdir)/" + RbConfig::CONFIG["EXTOUT"] unless RUBY_VERSION < "2.4"
name = "c_extension_bundle" name = "c_extension_bundle"
dir_config(name) dir_config(name)
raise "OMG" unless with_config("c_extension") == "hello" raise "OMG" unless with_config("c_extension") == "hello"
@ -95,6 +97,7 @@ RSpec.describe "installing a gem with native extensions", :ruby_repo do
s.extensions = ["ext/extconf.rb"] s.extensions = ["ext/extconf.rb"]
s.write "ext/extconf.rb", <<-E s.write "ext/extconf.rb", <<-E
require "mkmf" require "mkmf"
$extout = "$(topdir)/" + RbConfig::CONFIG["EXTOUT"] unless RUBY_VERSION < "2.4"
name = "c_extension_bundle_#{n}" name = "c_extension_bundle_#{n}"
dir_config(name) dir_config(name)
raise "OMG" unless with_config("c_extension_#{n}") == "#{n}" raise "OMG" unless with_config("c_extension_#{n}") == "#{n}"
@ -147,6 +150,7 @@ RSpec.describe "installing a gem with native extensions", :ruby_repo do
s.extensions = ["ext/extconf.rb"] s.extensions = ["ext/extconf.rb"]
s.write "ext/extconf.rb", <<-E s.write "ext/extconf.rb", <<-E
require "mkmf" require "mkmf"
$extout = "$(topdir)/" + RbConfig::CONFIG["EXTOUT"] unless RUBY_VERSION < "2.4"
name = "c_extension_bundle" name = "c_extension_bundle"
dir_config(name) dir_config(name)
raise "OMG" unless with_config("c_extension") == "hello" && with_config("c_extension_bundle-dir") == "hola" raise "OMG" unless with_config("c_extension") == "hello" && with_config("c_extension_bundle-dir") == "hola"

View File

@ -205,7 +205,7 @@ RSpec.shared_examples "bundle install --standalone" do
end end
end end
describe "with gems with native extension", :ruby_repo do describe "with gems with native extension" do
before do before do
bundle "config set --local path #{bundled_app("bundle")}" bundle "config set --local path #{bundled_app("bundle")}"
install_gemfile <<-G, :standalone => true, :dir => cwd install_gemfile <<-G, :standalone => true, :dir => cwd

View File

@ -205,7 +205,7 @@ RSpec.describe "global gem caching" do
end end
describe "extension caching" do describe "extension caching" do
it "works", :ruby_repo do it "works" do
skip "gets incorrect ref in path" if Gem.win_platform? skip "gets incorrect ref in path" if Gem.win_platform?
build_git "very_simple_git_binary", &:add_c_extension build_git "very_simple_git_binary", &:add_c_extension

View File

@ -176,7 +176,7 @@ RSpec.describe "bundle install" do
expect(the_bundle).to include_gems "rack 1.0.0" expect(the_bundle).to include_gems "rack 1.0.0"
end end
it "re-installs gems whose extensions have been deleted", :ruby_repo do it "re-installs gems whose extensions have been deleted" do
build_lib "very_simple_binary", "1.0.0", :to_system => true do |s| build_lib "very_simple_binary", "1.0.0", :to_system => true do |s|
s.write "lib/very_simple_binary.rb", "raise 'FAIL'" s.write "lib/very_simple_binary.rb", "raise 'FAIL'"
end end

View File

@ -801,7 +801,7 @@ end
expect(out).to eq("yay") expect(out).to eq("yay")
end end
it "should clean $LOAD_PATH properly", :ruby_repo do it "should clean $LOAD_PATH properly" do
gem_name = "very_simple_binary" gem_name = "very_simple_binary"
full_gem_name = gem_name + "-1.0" full_gem_name = gem_name + "-1.0"
ext_dir = File.join(tmp("extensions", full_gem_name)) ext_dir = File.join(tmp("extensions", full_gem_name))

View File

@ -444,8 +444,7 @@ module Spec
write "ext/extconf.rb", <<-RUBY write "ext/extconf.rb", <<-RUBY
require "mkmf" require "mkmf"
$extout = "$(topdir)/" + RbConfig::CONFIG["EXTOUT"] unless RUBY_VERSION < "2.4"
# exit 1 unless with_config("simple")
extension_name = "#{name}_c" extension_name = "#{name}_c"
if extra_lib_dir = with_config("ext-lib") if extra_lib_dir = with_config("ext-lib")