Sync Bundler and adapt to new spec setup
This commit is contained in:
parent
684cfa42d7
commit
756479324f
Notes:
git
2025-04-10 10:22:08 +00:00
@ -1,12 +1,7 @@
|
||||
#!/usr/bin/env ruby
|
||||
# frozen_string_literal: true
|
||||
|
||||
require_relative "../../spec/bundler/support/rubygems_ext"
|
||||
|
||||
require_relative "../../spec/bundler/support/switch_rubygems"
|
||||
|
||||
require "rubygems"
|
||||
$LOAD_PATH.unshift(File.expand_path("../../lib", __FILE__))
|
||||
require_relative "../bundler/support/setup"
|
||||
|
||||
require "turbo_tests"
|
||||
TurboTests::CLI.new(ARGV).run
|
||||
|
@ -95,8 +95,6 @@ RSpec.configure do |config|
|
||||
|
||||
extend(Spec::Builders)
|
||||
|
||||
check_test_gems!
|
||||
|
||||
build_repo1
|
||||
|
||||
reset_paths!
|
||||
@ -119,8 +117,4 @@ RSpec.configure do |config|
|
||||
ensure
|
||||
reset!
|
||||
end
|
||||
|
||||
config.after :suite do
|
||||
FileUtils.rm_r Spec::Path.pristine_system_gem_path
|
||||
end
|
||||
end
|
||||
|
@ -276,14 +276,6 @@ module Spec
|
||||
update_repo(path,**kwargs, &blk)
|
||||
end
|
||||
|
||||
def check_test_gems!
|
||||
if rake_path.nil?
|
||||
Spec::Rubygems.install_test_deps
|
||||
end
|
||||
|
||||
Helpers.install_dev_bundler unless pristine_system_gem_path.exist?
|
||||
end
|
||||
|
||||
def update_repo(path, build_compact_index: true)
|
||||
exempted_caller = Gem.ruby_version >= Gem::Version.new("3.4.0.dev") ? "#{Module.nesting.first}#build_repo" : "build_repo"
|
||||
if path == gem_repo1 && caller_locations(1, 1).first.label != exempted_caller
|
||||
@ -453,6 +445,7 @@ module Spec
|
||||
build_path = @context.tmp + full_name
|
||||
bundler_path = build_path + "#{full_name}.gem"
|
||||
|
||||
require "fileutils"
|
||||
FileUtils.mkdir_p build_path
|
||||
|
||||
@context.shipped_files.each do |shipped_file|
|
||||
@ -461,7 +454,7 @@ module Spec
|
||||
target_shipped_file = build_path + target_shipped_file
|
||||
target_shipped_dir = File.dirname(target_shipped_file)
|
||||
FileUtils.mkdir_p target_shipped_dir unless File.directory?(target_shipped_dir)
|
||||
FileUtils.cp shipped_file, target_shipped_file, preserve: true
|
||||
FileUtils.cp File.expand_path(shipped_file, @context.source_root), target_shipped_file, preserve: true
|
||||
end
|
||||
|
||||
@context.replace_version_file(@version, dir: build_path)
|
||||
|
@ -25,12 +25,8 @@ module Spec
|
||||
@relative_gemspec ||= ruby_core? ? "lib/bundler/bundler.gemspec" : "bundler.gemspec"
|
||||
end
|
||||
|
||||
def gemspec_dir
|
||||
@gemspec_dir ||= gemspec.parent
|
||||
end
|
||||
|
||||
def loaded_gemspec
|
||||
@loaded_gemspec ||= Gem::Specification.load(gemspec.to_s)
|
||||
@loaded_gemspec ||= Dir.chdir(source_root) { Gem::Specification.load(gemspec.to_s) }
|
||||
end
|
||||
|
||||
def test_gemfile
|
||||
@ -102,11 +98,11 @@ module Spec
|
||||
end
|
||||
|
||||
def tmp(*path)
|
||||
tmp_root(scope).join(*path)
|
||||
tmp_root.join("#{test_env_version}.#{scope}").join(*path)
|
||||
end
|
||||
|
||||
def tmp_root(scope)
|
||||
source_root.join("tmp", "#{test_env_version}.#{scope}")
|
||||
def tmp_root
|
||||
source_root.join("tmp")
|
||||
end
|
||||
|
||||
# Bump this version whenever you make a breaking change to the spec setup
|
||||
@ -180,15 +176,15 @@ module Spec
|
||||
end
|
||||
|
||||
def base_system_gems
|
||||
tmp("gems/base")
|
||||
tmp_root.join("gems/base")
|
||||
end
|
||||
|
||||
def rubocop_gems
|
||||
tmp("gems/rubocop")
|
||||
tmp_root.join("gems/rubocop")
|
||||
end
|
||||
|
||||
def standard_gems
|
||||
tmp("gems/standard")
|
||||
tmp_root.join("gems/standard")
|
||||
end
|
||||
|
||||
def file_uri_for(path)
|
||||
@ -227,7 +223,7 @@ module Spec
|
||||
end
|
||||
|
||||
def pristine_system_gem_path
|
||||
tmp("gems/base_system")
|
||||
tmp_root.join("gems/pristine_system")
|
||||
end
|
||||
|
||||
def local_gem_path(*path, base: bundled_app)
|
||||
@ -281,7 +277,7 @@ module Spec
|
||||
end
|
||||
|
||||
def rake_path
|
||||
Dir["#{base_system_gems}/#{Bundler.ruby_scope}/**/rake*.gem"].first
|
||||
Dir["#{base_system_gems}/*/*/**/rake*.gem"].first
|
||||
end
|
||||
|
||||
def sinatra_dependency_paths
|
||||
|
@ -10,10 +10,6 @@ module Spec
|
||||
module Rubygems
|
||||
extend self
|
||||
|
||||
def dev_setup
|
||||
install_gems(dev_gemfile)
|
||||
end
|
||||
|
||||
def gem_load(gem_name, bin_container)
|
||||
require_relative "switch_rubygems"
|
||||
|
||||
@ -50,41 +46,19 @@ module Spec
|
||||
Gem::DefaultUserInteraction.ui = Gem::SilentUI.new
|
||||
end
|
||||
|
||||
def install_parallel_test_deps
|
||||
Gem.clear_paths
|
||||
|
||||
require "parallel"
|
||||
require "fileutils"
|
||||
|
||||
install_test_deps
|
||||
|
||||
(2..Parallel.processor_count).each do |n|
|
||||
source = Path.tmp_root("1")
|
||||
destination = Path.tmp_root(n.to_s)
|
||||
|
||||
FileUtils.cp_r source, destination, remove_destination: true
|
||||
end
|
||||
end
|
||||
|
||||
def setup_test_paths
|
||||
Gem.clear_paths
|
||||
|
||||
ENV["BUNDLE_PATH"] = nil
|
||||
ENV["GEM_HOME"] = ENV["GEM_PATH"] = Path.base_system_gem_path.to_s
|
||||
ENV["PATH"] = [Path.system_gem_path("bin"), ENV["PATH"]].join(File::PATH_SEPARATOR)
|
||||
ENV["PATH"] = [Path.bindir, ENV["PATH"]].join(File::PATH_SEPARATOR) if Path.ruby_core?
|
||||
end
|
||||
|
||||
def install_test_deps
|
||||
Gem.clear_paths
|
||||
dev_bundle("install", gemfile: test_gemfile, path: Path.base_system_gems.to_s)
|
||||
dev_bundle("install", gemfile: rubocop_gemfile, path: Path.rubocop_gems.to_s)
|
||||
dev_bundle("install", gemfile: standard_gemfile, path: Path.standard_gems.to_s)
|
||||
|
||||
install_gems(test_gemfile, Path.base_system_gems.to_s)
|
||||
install_gems(rubocop_gemfile, Path.rubocop_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"
|
||||
require_relative "helpers"
|
||||
Helpers.install_dev_bundler
|
||||
end
|
||||
|
||||
def check_source_control_changes(success_message:, error_message:)
|
||||
@ -107,6 +81,36 @@ module Spec
|
||||
end
|
||||
end
|
||||
|
||||
def dev_bundle(*args, gemfile: dev_gemfile, path: nil)
|
||||
old_gemfile = ENV["BUNDLE_GEMFILE"]
|
||||
old_orig_gemfile = ENV["BUNDLER_ORIG_BUNDLE_GEMFILE"]
|
||||
ENV["BUNDLE_GEMFILE"] = gemfile.to_s
|
||||
ENV["BUNDLER_ORIG_BUNDLE_GEMFILE"] = nil
|
||||
|
||||
if path
|
||||
old_path = ENV["BUNDLE_PATH"]
|
||||
ENV["BUNDLE_PATH"] = path
|
||||
else
|
||||
old_path__system = ENV["BUNDLE_PATH__SYSTEM"]
|
||||
ENV["BUNDLE_PATH__SYSTEM"] = "true"
|
||||
end
|
||||
|
||||
require "shellwords"
|
||||
# We don't use `Open3` here because it does not work on JRuby + Windows
|
||||
output = `ruby #{File.expand_path("support/bundle.rb", Path.spec_dir)} #{args.shelljoin}`
|
||||
raise output unless $?.success?
|
||||
output
|
||||
ensure
|
||||
if path
|
||||
ENV["BUNDLE_PATH"] = old_path
|
||||
else
|
||||
ENV["BUNDLE_PATH__SYSTEM"] = old_path__system
|
||||
end
|
||||
|
||||
ENV["BUNDLER_ORIG_BUNDLE_GEMFILE"] = old_orig_gemfile
|
||||
ENV["BUNDLE_GEMFILE"] = old_gemfile
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def gem_load_and_activate(gem_name, bin_container)
|
||||
@ -135,34 +139,6 @@ module Spec
|
||||
gem gem_name, gem_requirement
|
||||
end
|
||||
|
||||
def install_gems(gemfile, path = nil)
|
||||
old_gemfile = ENV["BUNDLE_GEMFILE"]
|
||||
old_orig_gemfile = ENV["BUNDLER_ORIG_BUNDLE_GEMFILE"]
|
||||
ENV["BUNDLE_GEMFILE"] = gemfile.to_s
|
||||
ENV["BUNDLER_ORIG_BUNDLE_GEMFILE"] = nil
|
||||
|
||||
if path
|
||||
old_path = ENV["BUNDLE_PATH"]
|
||||
ENV["BUNDLE_PATH"] = path
|
||||
else
|
||||
old_path__system = ENV["BUNDLE_PATH__SYSTEM"]
|
||||
ENV["BUNDLE_PATH__SYSTEM"] = "true"
|
||||
end
|
||||
|
||||
# We don't use `Open3` here because it does not work on JRuby + Windows
|
||||
output = `#{Gem.ruby} #{File.expand_path("support/bundle.rb", Path.spec_dir)} install`
|
||||
raise output unless $?.success?
|
||||
ensure
|
||||
if path
|
||||
ENV["BUNDLE_PATH"] = old_path
|
||||
else
|
||||
ENV["BUNDLE_PATH__SYSTEM"] = old_path__system
|
||||
end
|
||||
|
||||
ENV["BUNDLER_ORIG_BUNDLE_GEMFILE"] = old_orig_gemfile
|
||||
ENV["BUNDLE_GEMFILE"] = old_gemfile
|
||||
end
|
||||
|
||||
def test_gemfile
|
||||
Path.test_gemfile
|
||||
end
|
||||
|
9
spec/bundler/support/setup.rb
Normal file
9
spec/bundler/support/setup.rb
Normal file
@ -0,0 +1,9 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require_relative "switch_rubygems"
|
||||
|
||||
require_relative "rubygems_ext"
|
||||
Spec::Rubygems.install_test_deps
|
||||
|
||||
require_relative "path"
|
||||
$LOAD_PATH.unshift(File.expand_path("../../lib", __dir__)) if Spec::Path.ruby_core?
|
@ -135,6 +135,12 @@ module SyncDefaultGems
|
||||
File.write("lib/bundler/bundler.gemspec", gemspec_content)
|
||||
|
||||
cp_r("#{upstream}/bundler/spec", "spec/bundler")
|
||||
rm_rf("spec/bundler/bin")
|
||||
|
||||
parallel_tests_content = File.read("#{upstream}/bundler/bin/parallel_rspec").gsub("../spec", "../bundler")
|
||||
File.write("spec/bin/parallel_rspec", parallel_tests_content)
|
||||
chmod("+x", "spec/bin/parallel_rspec")
|
||||
|
||||
%w[dev_gems test_gems rubocop_gems standard_gems].each do |gemfile|
|
||||
["rb.lock", "rb"].each do |ext|
|
||||
cp_r("#{upstream}/tool/bundler/#{gemfile}.#{ext}", "tool/bundler")
|
||||
|
Loading…
x
Reference in New Issue
Block a user