summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2024-10-17 16:12:09 +0900
committerTakashi Kokubun <takashikkbn@gmail.com>2024-10-17 08:55:01 -0700
commit494fcc507b3bc218beb6638d33476b647d55969e (patch)
treed685c173f72dd5cc3be063d0fe2fa5ee958d99f0 /spec
parentd03e4228aaeb1bdd3432119e683aa259b028c5b2 (diff)
Merge RubyGems-3.5.22 and Bundler-2.5.22
Diffstat (limited to 'spec')
-rw-r--r--spec/bundler/install/gems/standalone_spec.rb50
-rw-r--r--spec/bundler/runtime/setup_spec.rb7
-rw-r--r--spec/bundler/support/builders.rb2
-rw-r--r--spec/bundler/support/helpers.rb36
-rw-r--r--spec/bundler/support/subprocess.rb2
5 files changed, 55 insertions, 42 deletions
diff --git a/spec/bundler/install/gems/standalone_spec.rb b/spec/bundler/install/gems/standalone_spec.rb
index ee8d9c6d3a..9a46af1946 100644
--- a/spec/bundler/install/gems/standalone_spec.rb
+++ b/spec/bundler/install/gems/standalone_spec.rb
@@ -144,7 +144,6 @@ RSpec.shared_examples "bundle install --standalone" do
skip "Does not work on old Windows Rubies" if Gem.ruby_version < Gem::Version.new("3.2") && Gem.win_platform?
necessary_system_gems = ["tsort --version 0.1.0"]
- necessary_system_gems += ["etc --version 1.4.3"] if Gem.ruby_version >= Gem::Version.new("3.3.2") && Gem.win_platform?
realworld_system_gems(*necessary_system_gems)
end
@@ -176,7 +175,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") }
@@ -187,28 +195,36 @@ 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 += ["base64 --version 0.1.0", "resolv --version 0.2.1"] if Gem.rubygems_version < Gem::Version.new("3.3.a")
- 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 += ["base64 --version 0.1.0", "resolv --version 0.2.1"] if Gem.rubygems_version < Gem::Version.new("3.3.a")
+ 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/runtime/setup_spec.rb b/spec/bundler/runtime/setup_spec.rb
index 175e2551f1..31ac110880 100644
--- a/spec/bundler/runtime/setup_spec.rb
+++ b/spec/bundler/runtime/setup_spec.rb
@@ -865,7 +865,6 @@ end
it "should clean $LOAD_PATH properly" do
gem_name = "very_simple_binary"
full_gem_name = gem_name + "-1.0"
- ext_dir = File.join(tmp("extensions", full_gem_name))
system_gems full_gem_name
@@ -874,12 +873,6 @@ end
G
ruby <<-R
- s = Gem::Specification.find_by_name '#{gem_name}'
- s.extension_dir = '#{ext_dir}'
-
- # Don't build extensions.
- s.class.send(:define_method, :build_extensions) { nil }
-
require 'bundler'
gem '#{gem_name}'
diff --git a/spec/bundler/support/builders.rb b/spec/bundler/support/builders.rb
index a187d2ae48..4d713d8708 100644
--- a/spec/bundler/support/builders.rb
+++ b/spec/bundler/support/builders.rb
@@ -497,7 +497,7 @@ module Spec
write "ext/#{name}.c", <<-C
#include "ruby.h"
- void Init_#{name}_c() {
+ void Init_#{name}_c(void) {
rb_define_module("#{Builders.constantize(name)}_IN_C");
}
C
diff --git a/spec/bundler/support/helpers.rb b/spec/bundler/support/helpers.rb
index 145008ab42..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)
@@ -186,6 +188,12 @@ module Spec
env = options[:env] || {}
env["RUBYOPT"] = opt_add(opt_add("-r#{spec_dir}/support/hax.rb", env["RUBYOPT"]), ENV["RUBYOPT"])
options[:env] = env
+
+ # Sometimes `gem install` commands hang at dns resolution, which has a
+ # default timeout of 60 seconds. When that happens, the timeout for a
+ # command is expired too. So give `gem install` commands a bit more time.
+ options[:timeout] = 120
+
output = sys_exec("#{Path.gem_bin} #{command}", options)
stderr = last_command.stderr
raise stderr if stderr.include?("WARNING") && !allowed_rubygems_warning?(stderr)
@@ -290,18 +298,16 @@ module Spec
options = gems.last.is_a?(Hash) ? gems.pop : {}
install_dir = options.fetch(:path, system_gem_path)
default = options.fetch(:default, false)
- with_gem_path_as(install_dir) do
- gem_repo = options.fetch(:gem_repo, gem_repo1)
- gems.each do |g|
- gem_name = g.to_s
- if gem_name.start_with?("bundler")
- version = gem_name.match(/\Abundler-(?<version>.*)\z/)[:version] if gem_name != "bundler"
- with_built_bundler(version) {|gem_path| install_gem(gem_path, install_dir, default) }
- elsif %r{\A(?:[a-zA-Z]:)?/.*\.gem\z}.match?(gem_name)
- install_gem(gem_name, install_dir, default)
- else
- install_gem("#{gem_repo}/gems/#{gem_name}.gem", install_dir, default)
- end
+ gems.each do |g|
+ gem_name = g.to_s
+ if gem_name.start_with?("bundler")
+ version = gem_name.match(/\Abundler-(?<version>.*)\z/)[:version] if gem_name != "bundler"
+ with_built_bundler(version) {|gem_path| install_gem(gem_path, install_dir, default) }
+ elsif %r{\A(?:[a-zA-Z]:)?/.*\.gem\z}.match?(gem_name)
+ install_gem(gem_name, install_dir, default)
+ else
+ gem_repo = options.fetch(:gem_repo, gem_repo1)
+ install_gem("#{gem_repo}/gems/#{gem_name}.gem", install_dir, default)
end
end
end
@@ -388,10 +394,8 @@ module Spec
opts = gems.last.is_a?(Hash) ? gems.pop : {}
path = opts.fetch(:path, system_gem_path)
- with_gem_path_as(path) do
- gems.each do |gem|
- gem_command "install --no-document #{gem}"
- end
+ gems.each do |gem|
+ gem_command "install --no-document --verbose --install-dir #{path} #{gem}"
end
end
diff --git a/spec/bundler/support/subprocess.rb b/spec/bundler/support/subprocess.rb
index ade18e7805..a4842166b9 100644
--- a/spec/bundler/support/subprocess.rb
+++ b/spec/bundler/support/subprocess.rb
@@ -34,7 +34,7 @@ module Spec
dir = options[:dir]
env = options[:env] || {}
- command_execution = CommandExecution.new(cmd.to_s, working_directory: dir, timeout: 60)
+ command_execution = CommandExecution.new(cmd.to_s, working_directory: dir, timeout: options[:timeout] || 60)
require "open3"
require "shellwords"