[rubygems/rubygems] Avoid concurrent builds of Bundler when running specs

Instead, build it during setup when in CI.

This should avoid some Windows specific test failures when Bundler
copies the same files from multiple processes and runs into EACESS
errors.

https://github.com/rubygems/rubygems/commit/c194a1d753
This commit is contained in:
David Rodriguez 2024-02-02 21:15:26 +01:00 committed by git
parent 176c4bb3c7
commit 5f8375381b
4 changed files with 35 additions and 11 deletions

View File

@ -87,11 +87,10 @@ RSpec.configure do |config|
# Don't wrap output in tests # Don't wrap output in tests
ENV["THOR_COLUMNS"] = "10000" ENV["THOR_COLUMNS"] = "10000"
extend(Spec::Helpers) Spec::Helpers.install_dev_bundler unless ENV["CI"]
system_gems :bundler, path: pristine_system_gem_path
end extend(Spec::Builders)
config.before :all do
check_test_gems! check_test_gems!
build_repo1 build_repo1

View File

@ -5,6 +5,11 @@ require "shellwords"
module Spec module Spec
module Builders module Builders
def self.extended(mod)
mod.extend Path
mod.extend Helpers
end
def self.constantize(name) def self.constantize(name)
name.delete("-").upcase name.delete("-").upcase
end end
@ -22,7 +27,7 @@ module Spec
end end
def build_repo1 def build_repo1
rake_path = Dir["#{Path.base_system_gems}/**/rake*.gem"].first rake_path = Dir["#{base_system_gems}/**/rake*.gem"].first
build_repo gem_repo1 do build_repo gem_repo1 do
FileUtils.cp rake_path, "#{gem_repo1}/gems/" FileUtils.cp rake_path, "#{gem_repo1}/gems/"
@ -240,12 +245,12 @@ module Spec
end end
def check_test_gems! def check_test_gems!
rake_path = Dir["#{Path.base_system_gems}/**/rake*.gem"].first rake_path = Dir["#{base_system_gems}/**/rake*.gem"].first
if rake_path.nil? if rake_path.nil?
FileUtils.rm_rf(Path.base_system_gems) FileUtils.rm_rf(base_system_gems)
Spec::Rubygems.install_test_deps Spec::Rubygems.install_test_deps
rake_path = Dir["#{Path.base_system_gems}/**/rake*.gem"].first rake_path = Dir["#{base_system_gems}/**/rake*.gem"].first
end end
if rake_path.nil? if rake_path.nil?
@ -261,9 +266,9 @@ module Spec
@_build_path = "#{path}/gems" @_build_path = "#{path}/gems"
@_build_repo = File.basename(path) @_build_repo = File.basename(path)
yield yield
with_gem_path_as Path.base_system_gem_path do with_gem_path_as base_system_gem_path do
Dir[Spec::Path.base_system_gem_path.join("gems/rubygems-generate_index*/lib")].first || Dir[base_system_gem_path.join("gems/rubygems-generate_index*/lib")].first ||
raise("Could not find rubygems-generate_index lib directory in #{Spec::Path.base_system_gem_path}") raise("Could not find rubygems-generate_index lib directory in #{base_system_gem_path}")
command = "generate_index" command = "generate_index"
command += " --no-compact" if !build_compact_index && gem_command(command + " --help").include?("--[no-]compact") command += " --no-compact" if !build_compact_index && gem_command(command + " --help").include?("--[no-]compact")

View File

@ -11,6 +11,12 @@ module Spec
include Spec::Options include Spec::Options
include Spec::Subprocess include Spec::Subprocess
def self.extended(mod)
mod.extend Spec::Path
mod.extend Spec::Options
mod.extend Spec::Subprocess
end
def reset! def reset!
Dir.glob("#{tmp}/{gems/*,*}", File::FNM_DOTMATCH).each do |dir| Dir.glob("#{tmp}/{gems/*,*}", File::FNM_DOTMATCH).each do |dir|
next if %w[base base_system remote1 rubocop standard gems rubygems . ..].include?(File.basename(dir)) next if %w[base base_system remote1 rubocop standard gems rubygems . ..].include?(File.basename(dir))
@ -267,6 +273,12 @@ module Spec
end end
end end
def self.install_dev_bundler
extend self
system_gems :bundler, path: pristine_system_gem_path
end
def install_gem(path, install_dir, default = false) def install_gem(path, install_dir, default = false)
raise "OMG `#{path}` does not exist!" unless File.exist?(path) raise "OMG `#{path}` does not exist!" unless File.exist?(path)
@ -277,6 +289,8 @@ module Spec
end end
def with_built_bundler(version = nil, &block) def with_built_bundler(version = nil, &block)
require_relative "builders"
Builders::BundlerBuilder.new(self, "bundler", version)._build(&block) Builders::BundlerBuilder.new(self, "bundler", version)._build(&block)
end end

View File

@ -75,9 +75,15 @@ module Spec
end end
def install_test_deps def install_test_deps
Gem.clear_paths
install_gems(test_gemfile, Path.base_system_gems.to_s) install_gems(test_gemfile, Path.base_system_gems.to_s)
install_gems(rubocop_gemfile, Path.rubocop_gems.to_s) install_gems(rubocop_gemfile, Path.rubocop_gems.to_s)
install_gems(standard_gemfile, Path.standard_gems.to_s) install_gems(standard_gemfile, Path.standard_gems.to_s)
# For some reason, doing this here crashes on JRuby + Windows. So defer to
# when the test suite is running in that case.
Helpers.install_dev_bundler unless Gem.win_platform? && RUBY_ENGINE == "jruby"
end end
def check_source_control_changes(success_message:, error_message:) def check_source_control_changes(success_message:, error_message:)