summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2024-10-04 18:21:41 +0200
committergit <svn-admin@ruby-lang.org>2024-10-10 14:51:32 +0000
commit3fdf0e7e6deee8a275869c1ced389f6e4d9975ea (patch)
tree100fef3d15c29a70f0abf98032c02ec67c00f827 /spec
parentf63873e7a2d07e23694148ea500da3baf09cc680 (diff)
[rubygems/rubygems] Fix specs with missing extensions getting activated
https://github.com/rubygems/rubygems/commit/c80998a22a
Diffstat (limited to 'spec')
-rw-r--r--spec/bundler/install/gems/standalone_spec.rb48
-rw-r--r--spec/bundler/support/helpers.rb2
2 files changed, 34 insertions, 16 deletions
diff --git a/spec/bundler/install/gems/standalone_spec.rb b/spec/bundler/install/gems/standalone_spec.rb
index 65b14ea425..abd77d33de 100644
--- a/spec/bundler/install/gems/standalone_spec.rb
+++ b/spec/bundler/install/gems/standalone_spec.rb
@@ -142,7 +142,6 @@ RSpec.shared_examples "bundle install --standalone" do
describe "with default gems and a lockfile", :ruby_repo do
before do
necessary_system_gems = ["tsort --version 0.1.0"]
- necessary_system_gems += ["etc --version 1.4.3"]
realworld_system_gems(*necessary_system_gems)
end
@@ -173,7 +172,16 @@ RSpec.shared_examples "bundle install --standalone" do
bundle "lock", dir: cwd
bundle "config set --local path #{bundled_app("bundle")}"
- bundle :install, standalone: true, dir: cwd, env: { "BUNDLER_GEM_DEFAULT_DIR" => system_gem_path.to_s }
+
+ # Make sure rubyinstaller2 does not activate the etc gem in its
+ # `operating_system.rb` file, but completely disable that since it's not
+ # really needed here
+ if Gem.win_platform?
+ FileUtils.mkdir_p bundled_app("rubygems/defaults")
+ FileUtils.touch bundled_app("rubygems/defaults/operating_system.rb")
+ end
+
+ bundle :install, standalone: true, dir: cwd, env: { "BUNDLER_GEM_DEFAULT_DIR" => system_gem_path.to_s }, load_path: bundled_app
load_path_lines = bundled_app("bundle/bundler/setup.rb").read.split("\n").select {|line| line.start_with?("$:.unshift") }
@@ -184,27 +192,35 @@ RSpec.shared_examples "bundle install --standalone" do
end
it "works for gems with extensions and points to the vendored copies, not to the default copies" do
- necessary_gems_in_bundle_path = ["optparse --version 0.1.1", "psych --version 3.3.2", "logger --version 1.4.3", "etc --version 1.4.3", "stringio --version 3.1.0", "shellwords --version 0.2.0", "open3 --version 0.2.1"]
- necessary_gems_in_bundle_path += ["yaml --version 0.1.1"] if Gem.rubygems_version < Gem::Version.new("3.4.a")
- realworld_system_gems(*necessary_gems_in_bundle_path, path: scoped_gem_path(bundled_app("bundle")))
+ simulate_platform "arm64-darwin-23" do
+ necessary_gems_in_bundle_path = ["optparse --version 0.1.1", "psych --version 3.3.2", "logger --version 1.4.3", "etc --version 1.4.3", "stringio --version 3.1.0", "shellwords --version 0.2.0", "open3 --version 0.2.1"]
+ necessary_gems_in_bundle_path += ["yaml --version 0.1.1"] if Gem.rubygems_version < Gem::Version.new("3.4.a")
+ realworld_system_gems(*necessary_gems_in_bundle_path, path: scoped_gem_path(bundled_app("bundle")))
- build_gem "baz", "1.0.0", to_system: true, default: true, &:add_c_extension
+ build_gem "baz", "1.0.0", to_system: true, default: true, &:add_c_extension
- build_repo4 do
- build_gem "baz", "1.0.0", &:add_c_extension
- end
+ build_repo4 do
+ build_gem "baz", "1.0.0", &:add_c_extension
+ end
- gemfile <<-G
- source "https://gem.repo4"
- gem "baz"
- G
+ gemfile <<-G
+ source "https://gem.repo4"
+ gem "baz"
+ G
- bundle "config set --local path #{bundled_app("bundle")}"
+ bundle "config set --local path #{bundled_app("bundle")}"
- simulate_platform "arm64-darwin-23" do
bundle "lock", dir: cwd
- bundle :install, standalone: true, dir: cwd, env: { "BUNDLER_GEM_DEFAULT_DIR" => system_gem_path.to_s }
+ # Make sure rubyinstaller2 does not activate the etc gem in its
+ # `operating_system.rb` file, but completely disable that since it's not
+ # really needed here
+ if Gem.win_platform?
+ FileUtils.mkdir_p bundled_app("rubygems/defaults")
+ FileUtils.touch bundled_app("rubygems/defaults/operating_system.rb")
+ end
+
+ bundle :install, standalone: true, dir: cwd, env: { "BUNDLER_GEM_DEFAULT_DIR" => system_gem_path.to_s }, load_path: bundled_app
end
load_path_lines = bundled_app("bundle/bundler/setup.rb").read.split("\n").select {|line| line.start_with?("$:.unshift") }
diff --git a/spec/bundler/support/helpers.rb b/spec/bundler/support/helpers.rb
index 411d634bbf..da75c0d6d1 100644
--- a/spec/bundler/support/helpers.rb
+++ b/spec/bundler/support/helpers.rb
@@ -76,9 +76,11 @@ module Spec
requires = options.delete(:requires) || []
dir = options.delete(:dir) || bundled_app
+ custom_load_path = options.delete(:load_path)
load_path = []
load_path << spec_dir
+ load_path << custom_load_path if custom_load_path
build_ruby_options = { load_path: load_path, requires: requires, env: env }
build_ruby_options.merge!(artifice: options.delete(:artifice)) if options.key?(:artifice)