diff options
Diffstat (limited to 'spec/bundler/support/rubygems_ext.rb')
-rw-r--r-- | spec/bundler/support/rubygems_ext.rb | 69 |
1 files changed, 37 insertions, 32 deletions
diff --git a/spec/bundler/support/rubygems_ext.rb b/spec/bundler/support/rubygems_ext.rb index 59429884d6..ea774429c9 100644 --- a/spec/bundler/support/rubygems_ext.rb +++ b/spec/bundler/support/rubygems_ext.rb @@ -9,7 +9,7 @@ module Spec extend self def dev_setup - install_gems(dev_gemfile, dev_lockfile) + install_gems(dev_gemfile) end def gem_load(gem_name, bin_container) @@ -33,25 +33,25 @@ module Spec ENV["HOME"] = Path.home.to_s ENV["TMPDIR"] = Path.tmpdir.to_s - ENV["XDG_CONFIG_HOME"] = Path.xdg_config_home.to_s require "rubygems/user_interaction" Gem::DefaultUserInteraction.ui = Gem::SilentUI.new end def install_parallel_test_deps + Gem.clear_paths + require "parallel" + require "fileutils" - prev_env_test_number = ENV["TEST_ENV_NUMBER"] + install_test_deps - begin - Parallel.processor_count.times do |n| - ENV["TEST_ENV_NUMBER"] = (n + 1).to_s + (2..Parallel.processor_count).each do |n| + source = Path.source_root.join("tmp", "1") + destination = Path.source_root.join("tmp", n.to_s) - install_test_deps - end - ensure - ENV["TEST_ENV_NUMBER"] = prev_env_test_number + FileUtils.rm_rf destination + FileUtils.cp_r source, destination end end @@ -67,9 +67,9 @@ module Spec def install_test_deps setup_test_paths - workaround_loaded_specs_issue - - install_gems(test_gemfile, test_lockfile) + install_gems(test_gemfile) + install_gems(rubocop_gemfile, Path.rubocop_gems.to_s) + install_gems(standard_gemfile, Path.standard_gems.to_s) end def check_source_control_changes(success_message:, error_message:) @@ -94,18 +94,6 @@ module Spec private - # Some rubygems versions include loaded specs when loading gemspec stubs - # from the file system. In this situation, that makes bundler incorrectly - # assume that `rake` is already installed at `tmp/` because it's installed - # globally, and makes it skip installing it to the proper location for our - # tests. To workaround, we remove `rake` from the loaded specs when running - # under those versions, so that `bundler` does the right thing. - def workaround_loaded_specs_issue - current_rubygems_version = Gem::Version.new(Gem::VERSION) - - Gem.loaded_specs.delete("rake") if current_rubygems_version >= Gem::Version.new("3.0.0.beta2") && current_rubygems_version < Gem::Version.new("3.2.0") - end - def gem_load_and_activate(gem_name, bin_container) gem_activate(gem_name) load Gem.bin_path(gem_name, bin_container) @@ -119,14 +107,27 @@ module Spec gem gem_name, gem_requirement end - def install_gems(gemfile, lockfile) + def install_gems(gemfile, path = nil) old_gemfile = ENV["BUNDLE_GEMFILE"] ENV["BUNDLE_GEMFILE"] = gemfile.to_s - require "bundler" - definition = Bundler::Definition.build(gemfile, lockfile, nil) - definition.validate_runtime! - Bundler::Installer.install(Path.source_root, definition, :path => ENV["GEM_HOME"]) + + 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 + + output = `#{Gem.ruby} #{File.expand_path("support/bundle.rb", Path.spec_dir)} install` + raise "Error when installing gems in #{gemfile}: #{output}" unless $?.success? ensure + if path + ENV["BUNDLE_PATH"] = old_path + else + ENV["BUNDLE_PATH__SYSTEM"] = old_path__system + end + ENV["BUNDLE_GEMFILE"] = old_gemfile end @@ -134,8 +135,12 @@ module Spec Path.test_gemfile end - def test_lockfile - lockfile_for(test_gemfile) + def rubocop_gemfile + Path.rubocop_gemfile + end + + def standard_gemfile + Path.standard_gemfile end def dev_gemfile |