summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2025-07-23 20:09:47 +0200
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2025-07-25 11:10:37 +0900
commite67f595e8f3f76f20d7a6b9fd0498ff7b641391c (patch)
tree4e1c0adfe8fc9b11c0c91d5ec7f106a5ea520d7d
parent63c422377543a8d8ec8efc4aacb6c0f1a8533ff7 (diff)
[rubygems/rubygems] Build bundler gem just once for specs
When we need to reset system gems during specs, there's no need to rebuild bundler, we can copy over the original gem home. https://github.com/rubygems/rubygems/commit/7b4f80747b
-rw-r--r--spec/bundler/cache/gems_spec.rb8
-rw-r--r--spec/bundler/cache/git_spec.rb10
-rw-r--r--spec/bundler/commands/cache_spec.rb8
-rw-r--r--spec/bundler/commands/check_spec.rb2
-rw-r--r--spec/bundler/commands/outdated_spec.rb2
-rw-r--r--spec/bundler/install/deploy_spec.rb4
-rw-r--r--spec/bundler/install/gemfile/git_spec.rb6
-rw-r--r--spec/bundler/install/gemfile/platform_spec.rb2
-rw-r--r--spec/bundler/install/global_cache_spec.rb12
-rw-r--r--spec/bundler/spec_helper.rb2
-rw-r--r--spec/bundler/support/helpers.rb21
11 files changed, 43 insertions, 34 deletions
diff --git a/spec/bundler/cache/gems_spec.rb b/spec/bundler/cache/gems_spec.rb
index 780972b9af..b23d475a5f 100644
--- a/spec/bundler/cache/gems_spec.rb
+++ b/spec/bundler/cache/gems_spec.rb
@@ -291,7 +291,7 @@ RSpec.describe "bundle cache" do
expect(cached_gem("platform_specific-1.0-java")).to exist
end
- pristine_system_gems :bundler
+ pristine_system_gems
simulate_platform "x86-darwin-100" do
install_gemfile <<-G
@@ -313,7 +313,7 @@ RSpec.describe "bundle cache" do
rubygems_version: "1.3.2"
FileUtils.rm_r default_bundle_path
- system_gems :bundler
+ default_system_gems
FileUtils.rm bundled_app_lock
bundle :install, raise_on_error: false
@@ -346,7 +346,7 @@ RSpec.describe "bundle cache" do
end
FileUtils.rm_r default_bundle_path
- system_gems :bundler
+ default_system_gems
lockfile <<-L
GEM
@@ -371,7 +371,7 @@ RSpec.describe "bundle cache" do
setup_main_repo
cached_gem("myrack-1.0.0").rmtree
build_gem "myrack", "1.0.0", path: bundled_app("vendor/cache")
- pristine_system_gems :bundler
+ pristine_system_gems
lockfile <<-L
GEM
diff --git a/spec/bundler/cache/git_spec.rb b/spec/bundler/cache/git_spec.rb
index e9dee60a98..66eaf65dd1 100644
--- a/spec/bundler/cache/git_spec.rb
+++ b/spec/bundler/cache/git_spec.rb
@@ -164,7 +164,7 @@ RSpec.describe "bundle cache with git" do
bundle "config set path vendor/bundle"
bundle :install
- pristine_system_gems :bundler
+ pristine_system_gems
with_path_as "" do
bundle "config set deployment true"
bundle "install --local"
@@ -182,7 +182,7 @@ RSpec.describe "bundle cache with git" do
bundle "config set cache_all true"
bundle :cache, "all-platforms" => true
- pristine_system_gems :bundler
+ pristine_system_gems
bundle "config set frozen true"
bundle "install --local --verbose"
expect(out).to_not include("Fetching")
@@ -199,7 +199,7 @@ RSpec.describe "bundle cache with git" do
bundle "config set cache_all true"
bundle :cache, "all-platforms" => true
- pristine_system_gems :bundler
+ pristine_system_gems
bundle "config set frozen true"
bundle "install --local --verbose"
expect(out).to_not include("Fetching")
@@ -216,7 +216,7 @@ RSpec.describe "bundle cache with git" do
bundle "config set cache_all true"
bundle :cache, "all-platforms" => true
- pristine_system_gems :bundler
+ pristine_system_gems
bundle "config set frozen true"
# Remove untracked files (including the empty refs dir in the cache)
@@ -380,7 +380,7 @@ RSpec.describe "bundle cache with git" do
bundle "config set cache_all true"
bundle :cache, "all-platforms" => true, :install => false
- pristine_system_gems :bundler
+ pristine_system_gems
with_path_as "" do
bundle "config set deployment true"
bundle :install, local: true
diff --git a/spec/bundler/commands/cache_spec.rb b/spec/bundler/commands/cache_spec.rb
index 4365b92b8c..20d817a47d 100644
--- a/spec/bundler/commands/cache_spec.rb
+++ b/spec/bundler/commands/cache_spec.rb
@@ -356,7 +356,7 @@ RSpec.describe "bundle install with gem sources" do
G
bundle :cache
- pristine_system_gems :bundler
+ pristine_system_gems
FileUtils.rm_r gem_repo2
bundle "install --local"
@@ -371,7 +371,7 @@ RSpec.describe "bundle install with gem sources" do
G
bundle :cache
- pristine_system_gems :bundler
+ pristine_system_gems
FileUtils.rm_r gem_repo2
bundle "config set --local deployment true"
@@ -388,7 +388,7 @@ RSpec.describe "bundle install with gem sources" do
G
bundle :cache
- pristine_system_gems :bundler
+ pristine_system_gems
FileUtils.rm_r gem_repo2
bundle "config set --local cache_all_platforms true"
@@ -482,7 +482,7 @@ RSpec.describe "bundle install with gem sources" do
bundle :cache
end
- pristine_system_gems :bundler
+ pristine_system_gems
bundle "config set --local force_ruby_platform true"
diff --git a/spec/bundler/commands/check_spec.rb b/spec/bundler/commands/check_spec.rb
index fccaf76170..4793210e97 100644
--- a/spec/bundler/commands/check_spec.rb
+++ b/spec/bundler/commands/check_spec.rb
@@ -329,7 +329,7 @@ RSpec.describe "bundle check" do
it "shows what is missing with the current Gemfile if it is not satisfied" do
FileUtils.rm_r default_bundle_path
- system_gems :bundler
+ default_system_gems
bundle :check, raise_on_error: false
expect(err).to match(/The following gems are missing/)
expect(err).to include("* myrack (1.0")
diff --git a/spec/bundler/commands/outdated_spec.rb b/spec/bundler/commands/outdated_spec.rb
index d3f9dae8c5..b66b8c9e53 100644
--- a/spec/bundler/commands/outdated_spec.rb
+++ b/spec/bundler/commands/outdated_spec.rb
@@ -974,7 +974,7 @@ RSpec.describe "bundle outdated" do
gem "terranova", '8'
G
- pristine_system_gems :bundler
+ pristine_system_gems
update_git "foo", path: lib_path("foo")
update_repo2 do
diff --git a/spec/bundler/install/deploy_spec.rb b/spec/bundler/install/deploy_spec.rb
index 4d378d4941..3560a3965c 100644
--- a/spec/bundler/install/deploy_spec.rb
+++ b/spec/bundler/install/deploy_spec.rb
@@ -88,7 +88,7 @@ RSpec.describe "install in deployment or frozen mode" do
it "still works if you are not in the app directory and specify --gemfile" do
bundle "install"
- pristine_system_gems :bundler
+ pristine_system_gems
bundle "config set --local deployment true"
bundle "config set --local path vendor/bundle"
bundle "install --gemfile #{tmp}/bundled_app/Gemfile", dir: tmp
@@ -547,7 +547,7 @@ RSpec.describe "install in deployment or frozen mode" do
bundle "install --local"
expect(out).to include("Updating files in vendor/cache")
- pristine_system_gems :bundler
+ pristine_system_gems
bundle "config set --local deployment true"
bundle "install --verbose"
expect(out).not_to include("can't be updated because frozen mode is set")
diff --git a/spec/bundler/install/gemfile/git_spec.rb b/spec/bundler/install/gemfile/git_spec.rb
index 9104af1679..cd83ad71c0 100644
--- a/spec/bundler/install/gemfile/git_spec.rb
+++ b/spec/bundler/install/gemfile/git_spec.rb
@@ -37,7 +37,7 @@ RSpec.describe "bundle install with git sources" do
end
it "caches the git repo globally and properly uses the cached repo on the next invocation" do
- pristine_system_gems :bundler
+ pristine_system_gems
bundle "config set global_gem_cache true"
bundle :install
expect(Dir["#{home}/.bundle/cache/git/foo-1.0-*"]).to have_attributes size: 1
@@ -1241,7 +1241,7 @@ RSpec.describe "bundle install with git sources" do
gem "valim", "= 1.0", :git => "#{lib_path("valim")}"
G
- pristine_system_gems :bundler
+ pristine_system_gems
bundle "config set --local deployment true"
bundle :install
@@ -1628,7 +1628,7 @@ In Gemfile:
G
bundle "config set --global path vendor/bundle"
bundle :install
- pristine_system_gems :bundler
+ pristine_system_gems
bundle "install", env: { "PATH" => "" }
expect(out).to_not include("You need to install git to be able to use gems from git repositories.")
diff --git a/spec/bundler/install/gemfile/platform_spec.rb b/spec/bundler/install/gemfile/platform_spec.rb
index d517c12125..5ed5e66185 100644
--- a/spec/bundler/install/gemfile/platform_spec.rb
+++ b/spec/bundler/install/gemfile/platform_spec.rb
@@ -161,7 +161,7 @@ RSpec.describe "bundle install across platforms" do
expect(the_bundle).to include_gems "nokogiri 1.4.2 java", "weakling 0.0.3"
- pristine_system_gems :bundler
+ pristine_system_gems
bundle "config set --local force_ruby_platform true"
bundle "install"
diff --git a/spec/bundler/install/global_cache_spec.rb b/spec/bundler/install/global_cache_spec.rb
index 884112d621..0a7daf173c 100644
--- a/spec/bundler/install/global_cache_spec.rb
+++ b/spec/bundler/install/global_cache_spec.rb
@@ -95,7 +95,7 @@ RSpec.describe "global gem caching" do
gem "myrack"
G
- pristine_system_gems :bundler
+ pristine_system_gems
expect(the_bundle).not_to include_gems "myrack 1.0.0"
expect(source_global_cache("myrack-1.0.0.gem")).to exist
# myrack 1.0.0 is not installed and it is in the global cache
@@ -105,7 +105,7 @@ RSpec.describe "global gem caching" do
gem "myrack", "0.9.1"
G
- pristine_system_gems :bundler
+ pristine_system_gems
expect(the_bundle).not_to include_gems "myrack 0.9.1"
expect(source2_global_cache("myrack-0.9.1.gem")).to exist
# myrack 0.9.1 is not installed and it is in the global cache
@@ -119,7 +119,7 @@ RSpec.describe "global gem caching" do
# myrack 1.0.0 is installed and myrack 0.9.1 is not
expect(the_bundle).to include_gems "myrack 1.0.0"
expect(the_bundle).not_to include_gems "myrack 0.9.1"
- pristine_system_gems :bundler
+ pristine_system_gems
gemfile <<-G
source "#{source2}"
@@ -141,7 +141,7 @@ RSpec.describe "global gem caching" do
G
bundle :install, artifice: "compact_index"
- pristine_system_gems :bundler
+ pristine_system_gems
expect(the_bundle).not_to include_gems "myrack 1.0.0"
expect(source_global_cache("myrack-1.0.0.gem")).to exist
# myrack 1.0.0 is not installed and it is in the global cache
@@ -152,7 +152,7 @@ RSpec.describe "global gem caching" do
G
bundle :install, artifice: "compact_index"
- pristine_system_gems :bundler
+ pristine_system_gems
expect(the_bundle).not_to include_gems "myrack 0.9.1"
expect(source2_global_cache("myrack-0.9.1.gem")).to exist
# myrack 0.9.1 is not installed and it is in the global cache
@@ -204,7 +204,7 @@ RSpec.describe "global gem caching" do
expect(the_bundle).to include_gems "activesupport 2.3.5"
expect(source_global_cache("myrack-1.0.0.gem")).to exist
expect(source_global_cache("activesupport-2.3.5.gem")).to exist
- pristine_system_gems :bundler
+ pristine_system_gems
# Both gems are now only in the global cache
expect(the_bundle).not_to include_gems "myrack 1.0.0"
expect(the_bundle).not_to include_gems "activesupport 2.3.5"
diff --git a/spec/bundler/spec_helper.rb b/spec/bundler/spec_helper.rb
index 35b249bb92..87bdf8b9f3 100644
--- a/spec/bundler/spec_helper.rb
+++ b/spec/bundler/spec_helper.rb
@@ -107,7 +107,7 @@ RSpec.configure do |config|
end
config.around :each do |example|
- FileUtils.cp_r pristine_system_gem_path, system_gem_path
+ default_system_gems
with_gem_path_as(system_gem_path) do
Bundler.ui.silence { example.run }
diff --git a/spec/bundler/support/helpers.rb b/spec/bundler/support/helpers.rb
index 774042bebf..a0d2d2bb23 100644
--- a/spec/bundler/support/helpers.rb
+++ b/spec/bundler/support/helpers.rb
@@ -310,9 +310,10 @@ module Spec
default = options.fetch(:default, false)
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, released: options.fetch(:released, false)) {|gem_path| install_gem(gem_path, install_dir, default) }
+ bundler = gem_name.match(/\Abundler-(?<version>.*)\z/)
+
+ if bundler
+ with_built_bundler(bundler[:version], released: options.fetch(:released, false)) {|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
@@ -325,7 +326,7 @@ module Spec
def self.install_dev_bundler
extend self
- system_gems :bundler, path: pristine_system_gem_path
+ with_built_bundler {|gem_path| install_gem(gem_path, pristine_system_gem_path) }
end
def install_gem(path, install_dir, default = false)
@@ -395,7 +396,11 @@ module Spec
def pristine_system_gems(*gems)
FileUtils.rm_r(system_gem_path)
- system_gems(*gems)
+ if gems.any?
+ system_gems(*gems)
+ else
+ default_system_gems
+ end
end
def cache_gems(*gems, gem_repo: gem_repo1)
@@ -412,7 +417,11 @@ module Spec
def simulate_new_machine
FileUtils.rm_r bundled_app(".bundle")
- pristine_system_gems :bundler
+ pristine_system_gems
+ end
+
+ def default_system_gems
+ FileUtils.cp_r pristine_system_gem_path, system_gem_path
end
def simulate_ruby_platform(ruby_platform)