summaryrefslogtreecommitdiff
path: root/spec/bundler
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2022-07-23 08:44:47 +0200
committergit <svn-admin@ruby-lang.org>2022-08-02 16:10:18 +0900
commitf4f681463f71c2fc63e1a07f36f2665f2b9db002 (patch)
tree6d9c7f6b576fdfcd480156bdbd2ce6b20141307f /spec/bundler
parent9189c2d5efa94131050df4994c801fb187d7b43d (diff)
[rubygems/rubygems] Don't discard candidates matching ruby metadata
Do dependency filtering and materialization in one step. Before, dependency filtering would not consider ruby metadata so it would discard variants that end up not being materializable in the end. https://github.com/rubygems/rubygems/commit/0c0d40d417 Co-authored-by: Ian Ker-Seymer <ian.kerseymer@shopify.com>
Diffstat (limited to 'spec/bundler')
-rw-r--r--spec/bundler/install/gemfile/specific_platform_spec.rb47
-rw-r--r--spec/bundler/install/gems/resolving_spec.rb22
2 files changed, 65 insertions, 4 deletions
diff --git a/spec/bundler/install/gemfile/specific_platform_spec.rb b/spec/bundler/install/gemfile/specific_platform_spec.rb
index 6994cb2af1..48349aaef4 100644
--- a/spec/bundler/install/gemfile/specific_platform_spec.rb
+++ b/spec/bundler/install/gemfile/specific_platform_spec.rb
@@ -374,6 +374,41 @@ RSpec.describe "bundle install with specific platforms" do
ERROR
end
+ it "can fallback to a source gem when platform gems are incompatible with current ruby version" do
+ setup_multiplatform_gem_with_source_gem
+
+ source = file_uri_for(gem_repo2)
+
+ gemfile <<~G
+ source "#{source}"
+
+ gem "my-precompiled-gem"
+ G
+
+ # simulate lockfile which includes both a precompiled gem with:
+ # - Gem the current platform (with imcompatible ruby version)
+ # - A source gem with compatible ruby version
+ lockfile <<-L
+ GEM
+ remote: #{source}/
+ specs:
+ my-precompiled-gem (3.0.0)
+ my-precompiled-gem (3.0.0-#{Bundler.local_platform})
+
+ PLATFORMS
+ ruby
+ #{Bundler.local_platform}
+
+ DEPENDENCIES
+ my-precompiled-gem
+
+ BUNDLED WITH
+ #{Bundler::VERSION}
+ L
+
+ bundle :install
+ end
+
private
def setup_multiplatform_gem
@@ -404,4 +439,16 @@ RSpec.describe "bundle install with specific platforms" do
build_gem("CFPropertyList")
end
end
+
+ def setup_multiplatform_gem_with_source_gem
+ build_repo2 do
+ build_gem("my-precompiled-gem", "3.0.0")
+ build_gem("my-precompiled-gem", "3.0.0") do |s|
+ s.platform = Bundler.local_platform
+
+ # purposely unresolvable
+ s.required_ruby_version = ">= 1000.0.0"
+ end
+ end
+ end
end
diff --git a/spec/bundler/install/gems/resolving_spec.rb b/spec/bundler/install/gems/resolving_spec.rb
index 1679ad4460..a55db83dc4 100644
--- a/spec/bundler/install/gems/resolving_spec.rb
+++ b/spec/bundler/install/gems/resolving_spec.rb
@@ -241,7 +241,7 @@ RSpec.describe "bundle install with install-time dependencies" do
expect(the_bundle).to include_gems("rack 1.2")
end
- it "gives a meaningful error if there's a lockfile using the newer incompatible version" do
+ it "automatically updates lockfile to use the older version" do
build_repo2 do
build_gem "parallel_tests", "3.7.0" do |s|
s.required_ruby_version = ">= #{current_ruby_minor}"
@@ -273,9 +273,23 @@ RSpec.describe "bundle install with install-time dependencies" do
#{Bundler::VERSION}
L
- bundle "install --verbose", :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo2.to_s }, :raise_on_error => false
- expect(err).to include("parallel_tests-3.8.0 requires ruby version >= #{next_ruby_minor}")
- expect(err).not_to include("That means the author of parallel_tests (3.8.0) has removed it.")
+ bundle "install --verbose", :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo2.to_s }
+
+ expect(lockfile).to eq <<~L
+ GEM
+ remote: http://localgemserver.test/
+ specs:
+ parallel_tests (3.7.0)
+
+ PLATFORMS
+ #{lockfile_platforms}
+
+ DEPENDENCIES
+ parallel_tests
+
+ BUNDLED WITH
+ #{Bundler::VERSION}
+ L
end
it "gives a meaningful error on ruby version mismatches between dependencies" do