summaryrefslogtreecommitdiff
path: root/spec/bundler/resolver
diff options
context:
space:
mode:
Diffstat (limited to 'spec/bundler/resolver')
-rw-r--r--spec/bundler/resolver/basic_spec.rb124
-rw-r--r--spec/bundler/resolver/platform_spec.rb64
2 files changed, 128 insertions, 60 deletions
diff --git a/spec/bundler/resolver/basic_spec.rb b/spec/bundler/resolver/basic_spec.rb
index f739f8c02b..185df1b1c7 100644
--- a/spec/bundler/resolver/basic_spec.rb
+++ b/spec/bundler/resolver/basic_spec.rb
@@ -6,15 +6,15 @@ RSpec.describe "Resolving" do
end
it "resolves a single gem" do
- dep "rack"
+ dep "myrack"
- should_resolve_as %w[rack-1.1]
+ should_resolve_as %w[myrack-1.1]
end
it "resolves a gem with dependencies" do
dep "actionpack"
- should_resolve_as %w[actionpack-2.3.5 activesupport-2.3.5 rack-1.0]
+ should_resolve_as %w[actionpack-2.3.5 activesupport-2.3.5 myrack-1.0]
end
it "resolves a conflicting index" do
@@ -84,7 +84,7 @@ RSpec.describe "Resolving" do
dep "activesupport", "= 3.0.0.beta"
dep "actionpack"
- should_resolve_as %w[activesupport-3.0.0.beta actionpack-3.0.0.beta rack-1.1 rack-mount-0.6]
+ should_resolve_as %w[activesupport-3.0.0.beta actionpack-3.0.0.beta myrack-1.1 myrack-mount-0.6]
end
it "prefers non-pre-releases when doing conservative updates" do
@@ -100,13 +100,22 @@ RSpec.describe "Resolving" do
end
it "raises an exception if a child dependency is not resolved" do
- @index = a_unresovable_child_index
+ @index = a_unresolvable_child_index
dep "chef_app_error"
expect do
resolve
end.to raise_error(Bundler::SolveFailure)
end
+ it "does not try to re-resolve including prereleases if gems involved don't have prereleases" do
+ @index = a_unresolvable_child_index
+ dep "chef_app_error"
+ expect(Bundler.ui).not_to receive(:debug).with("Retrying resolution...", any_args)
+ expect do
+ resolve
+ end.to raise_error(Bundler::SolveFailure)
+ end
+
it "raises an exception with the minimal set of conflicting dependencies" do
@index = build_index do
%w[0.9 1.0 2.0].each {|v| gem("a", v) }
@@ -202,12 +211,12 @@ RSpec.describe "Resolving" do
it "resolves all gems to latest patch" do
# strict is not set, so bar goes up a minor version due to dependency from foo 1.4.5
- should_conservative_resolve_and_include :patch, [], %w[foo-1.4.5 bar-2.1.1]
+ should_conservative_resolve_and_include :patch, true, %w[foo-1.4.5 bar-2.1.1]
end
it "resolves all gems to latest patch strict" do
# strict is set, so foo can only go up to 1.4.4 to avoid bar going up a minor version, and bar can go up to 2.0.5
- should_conservative_resolve_and_include [:patch, :strict], [], %w[foo-1.4.4 bar-2.0.5]
+ should_conservative_resolve_and_include [:patch, :strict], true, %w[foo-1.4.4 bar-2.0.5]
end
it "resolves foo only to latest patch - same dependency case" do
@@ -229,7 +238,7 @@ RSpec.describe "Resolving" do
it "resolves foo only to latest patch - changing dependency declared case" do
# bar is locked AND a declared dependency in the Gemfile, so it will not move, and therefore
# foo can only move up to 1.4.4.
- @base << build_spec("bar", "2.0.3").first
+ @base = Bundler::SpecSet.new([Bundler::LazySpecification.new("bar", Gem::Version.new("2.0.3"), nil)])
should_conservative_resolve_and_include :patch, ["foo"], %w[foo-1.4.4 bar-2.0.3]
end
@@ -247,20 +256,20 @@ RSpec.describe "Resolving" do
it "resolves all gems to latest minor" do
# strict is not set, so bar goes up a major version due to dependency from foo 1.4.5
- should_conservative_resolve_and_include :minor, [], %w[foo-1.5.1 bar-3.0.0]
+ should_conservative_resolve_and_include :minor, true, %w[foo-1.5.1 bar-3.0.0]
end
it "resolves all gems to latest minor strict" do
# strict is set, so foo can only go up to 1.5.0 to avoid bar going up a major version
- should_conservative_resolve_and_include [:minor, :strict], [], %w[foo-1.5.0 bar-2.1.1]
+ should_conservative_resolve_and_include [:minor, :strict], true, %w[foo-1.5.0 bar-2.1.1]
end
it "resolves all gems to latest major" do
- should_conservative_resolve_and_include :major, [], %w[foo-2.0.0 bar-3.0.0]
+ should_conservative_resolve_and_include :major, true, %w[foo-2.0.0 bar-3.0.0]
end
it "resolves all gems to latest major strict" do
- should_conservative_resolve_and_include [:major, :strict], [], %w[foo-2.0.0 bar-3.0.0]
+ should_conservative_resolve_and_include [:major, :strict], true, %w[foo-2.0.0 bar-3.0.0]
end
# Why would this happen in real life? If bar 2.2 has a bug that the author of foo wants to bypass
@@ -283,31 +292,31 @@ RSpec.describe "Resolving" do
end
it "could revert to a previous version level patch" do
- should_conservative_resolve_and_include :patch, [], %w[foo-1.4.4 bar-2.1.1]
+ should_conservative_resolve_and_include :patch, true, %w[foo-1.4.4 bar-2.1.1]
end
it "cannot revert to a previous version in strict mode level patch" do
# fall back to the locked resolution since strict means we can't regress either version
- should_conservative_resolve_and_include [:patch, :strict], [], %w[foo-1.4.3 bar-2.2.3]
+ should_conservative_resolve_and_include [:patch, :strict], true, %w[foo-1.4.3 bar-2.2.3]
end
it "could revert to a previous version level minor" do
- should_conservative_resolve_and_include :minor, [], %w[foo-1.5.0 bar-2.0.5]
+ should_conservative_resolve_and_include :minor, true, %w[foo-1.5.0 bar-2.0.5]
end
it "cannot revert to a previous version in strict mode level minor" do
# fall back to the locked resolution since strict means we can't regress either version
- should_conservative_resolve_and_include [:minor, :strict], [], %w[foo-1.4.3 bar-2.2.3]
+ should_conservative_resolve_and_include [:minor, :strict], true, %w[foo-1.4.3 bar-2.2.3]
end
end
end
it "handles versions that redundantly depend on themselves" do
@index = build_index do
- gem "rack", "3.0.0"
+ gem "myrack", "3.0.0"
gem "standalone_migrations", "7.1.0" do
- dep "rack", "~> 2.0"
+ dep "myrack", "~> 2.0"
end
gem "standalone_migrations", "2.0.4" do
@@ -315,22 +324,22 @@ RSpec.describe "Resolving" do
end
gem "standalone_migrations", "1.0.13" do
- dep "rack", ">= 0"
+ dep "myrack", ">= 0"
end
end
- dep "rack", "~> 3.0"
+ dep "myrack", "~> 3.0"
dep "standalone_migrations"
- should_resolve_as %w[rack-3.0.0 standalone_migrations-2.0.4]
+ should_resolve_as %w[myrack-3.0.0 standalone_migrations-2.0.4]
end
it "ignores versions that incorrectly depend on themselves" do
@index = build_index do
- gem "rack", "3.0.0"
+ gem "myrack", "3.0.0"
gem "standalone_migrations", "7.1.0" do
- dep "rack", "~> 2.0"
+ dep "myrack", "~> 2.0"
end
gem "standalone_migrations", "2.0.4" do
@@ -338,13 +347,76 @@ RSpec.describe "Resolving" do
end
gem "standalone_migrations", "1.0.13" do
- dep "rack", ">= 0"
+ dep "myrack", ">= 0"
end
end
- dep "rack", "~> 3.0"
+ dep "myrack", "~> 3.0"
dep "standalone_migrations"
- should_resolve_as %w[rack-3.0.0 standalone_migrations-1.0.13]
+ should_resolve_as %w[myrack-3.0.0 standalone_migrations-1.0.13]
+ end
+
+ it "does not ignore versions that incorrectly depend on themselves when dependency_api is not available" do
+ @index = build_index do
+ gem "myrack", "3.0.0"
+
+ gem "standalone_migrations", "7.1.0" do
+ dep "myrack", "~> 2.0"
+ end
+
+ gem "standalone_migrations", "2.0.4" do
+ dep "standalone_migrations", ">= 2.0.5"
+ end
+
+ gem "standalone_migrations", "1.0.13" do
+ dep "myrack", ">= 0"
+ end
+ end
+
+ dep "myrack", "~> 3.0"
+ dep "standalone_migrations"
+
+ should_resolve_without_dependency_api %w[myrack-3.0.0 standalone_migrations-2.0.4]
+ end
+
+ it "resolves fine cases that need joining unbounded disjoint ranges" do
+ @index = build_index do
+ gem "inspec", "5.22.3" do
+ dep "ruby", ">= 3.2.2"
+ dep "train-kubernetes", ">= 0.1.7"
+ end
+
+ gem "ruby", "3.2.2"
+
+ gem "train-kubernetes", "0.1.12" do
+ dep "k8s-ruby", ">= 0.14.0"
+ end
+
+ gem "train-kubernetes", "0.1.10" do
+ dep "k8s-ruby", "= 0.10.5"
+ end
+
+ gem "train-kubernetes", "0.1.7" do
+ dep "k8s-ruby", ">= 0.10.5"
+ end
+
+ gem "k8s-ruby", "0.10.5" do
+ dep "ruby","< 3.2.2"
+ end
+
+ gem "k8s-ruby", "0.11.0" do
+ dep "ruby", ">= 3.2.2"
+ end
+
+ gem "k8s-ruby", "0.14.0" do
+ dep "ruby", "< 3.2.2"
+ end
+ end
+
+ dep "inspec", "5.22.3"
+ dep "ruby", "3.2.2"
+
+ should_resolve_as %w[inspec-5.22.3 ruby-3.2.2 train-kubernetes-0.1.7 k8s-ruby-0.11.0]
end
end
diff --git a/spec/bundler/resolver/platform_spec.rb b/spec/bundler/resolver/platform_spec.rb
index a710dfcb28..a1d095d024 100644
--- a/spec/bundler/resolver/platform_spec.rb
+++ b/spec/bundler/resolver/platform_spec.rb
@@ -48,11 +48,11 @@ RSpec.describe "Resolving platform craziness" do
it "takes the latest ruby gem, even if an older platform specific version is available" do
@index = build_index do
gem "foo", "1.0.0"
- gem "foo", "1.0.0", "x64-mingw32"
+ gem "foo", "1.0.0", "x64-mingw-ucrt"
gem "foo", "1.1.0"
end
dep "foo"
- platforms "x64-mingw32"
+ platforms "x64-mingw-ucrt"
should_resolve_as %w[foo-1.1.0]
end
@@ -61,12 +61,12 @@ RSpec.describe "Resolving platform craziness" do
@index = build_index do
gem "bar", "1.0.0"
gem "foo", "1.0.0"
- gem "foo", "1.0.0", "x64-mingw32" do
+ gem "foo", "1.0.0", "x64-mingw-ucrt" do
dep "bar", "< 1"
end
end
dep "foo"
- platforms "x64-mingw32"
+ platforms "x64-mingw-ucrt"
should_resolve_as %w[foo-1.0.0]
end
@@ -74,15 +74,15 @@ RSpec.describe "Resolving platform craziness" do
it "prefers the platform specific gem to the ruby version" do
@index = build_index do
gem "foo", "1.0.0"
- gem "foo", "1.0.0", "x64-mingw32"
+ gem "foo", "1.0.0", "x64-mingw-ucrt"
end
dep "foo"
- platforms "x64-mingw32"
+ platforms "x64-mingw-ucrt"
- should_resolve_as %w[foo-1.0.0-x64-mingw32]
+ should_resolve_as %w[foo-1.0.0-x64-mingw-ucrt]
end
- describe "on a linux platform", :rubygems => ">= 3.1.0.pre.1" do
+ describe "on a linux platform" do
# Ruby's platform is *-linux => platform's libc is glibc, so not musl
# Ruby's platform is *-linux-musl => platform's libc is musl, so not glibc
# Gem's platform is *-linux => gem is glibc + maybe musl compatible
@@ -159,15 +159,15 @@ RSpec.describe "Resolving platform craziness" do
before do
@index = build_index do
gem "foo", "1.0.0"
- gem "foo", "1.0.0", "x64-mingw32"
+ gem "foo", "1.0.0", "x64-mingw-ucrt"
gem "foo", "1.1.0"
- gem "foo", "1.1.0", "x64-mingw32" do |s|
+ gem "foo", "1.1.0", "x64-mingw-ucrt" do |s|
s.required_ruby_version = [">= 2.0", "< 2.4"]
end
gem "Ruby\0", "2.5.1"
end
dep "Ruby\0", "2.5.1"
- platforms "x64-mingw32"
+ platforms "x64-mingw-ucrt"
end
it "takes the latest ruby gem" do
@@ -186,18 +186,18 @@ RSpec.describe "Resolving platform craziness" do
it "takes the latest ruby gem with required_ruby_version if the platform specific gem doesn't match the required_ruby_version" do
@index = build_index do
gem "foo", "1.0.0"
- gem "foo", "1.0.0", "x64-mingw32"
+ gem "foo", "1.0.0", "x64-mingw-ucrt"
gem "foo", "1.1.0" do |s|
s.required_ruby_version = [">= 2.0"]
end
- gem "foo", "1.1.0", "x64-mingw32" do |s|
+ gem "foo", "1.1.0", "x64-mingw-ucrt" do |s|
s.required_ruby_version = [">= 2.0", "< 2.4"]
end
gem "Ruby\0", "2.5.1"
end
dep "foo"
dep "Ruby\0", "2.5.1"
- platforms "x64-mingw32"
+ platforms "x64-mingw-ucrt"
should_resolve_as %w[foo-1.1.0]
end
@@ -205,18 +205,18 @@ RSpec.describe "Resolving platform craziness" do
it "takes the latest ruby gem if the platform specific gem doesn't match the required_ruby_version with multiple platforms" do
@index = build_index do
gem "foo", "1.0.0"
- gem "foo", "1.0.0", "x64-mingw32"
+ gem "foo", "1.0.0", "x64-mingw-ucrt"
gem "foo", "1.1.0" do |s|
s.required_ruby_version = [">= 2.0"]
end
- gem "foo", "1.1.0", "x64-mingw32" do |s|
+ gem "foo", "1.1.0", "x64-mingw-ucrt" do |s|
s.required_ruby_version = [">= 2.0", "< 2.4"]
end
gem "Ruby\0", "2.5.1"
end
dep "foo"
dep "Ruby\0", "2.5.1"
- platforms "x86_64-linux", "x64-mingw32"
+ platforms "x86_64-linux", "x64-mingw-ucrt"
should_resolve_as %w[foo-1.1.0]
end
@@ -342,7 +342,7 @@ RSpec.describe "Resolving platform craziness" do
describe "with mingw32" do
before :each do
@index = build_index do
- platforms "mingw32 mswin32 x64-mingw32 x64-mingw-ucrt" do |platform|
+ platforms "mingw32 mswin32 x64-mingw-ucrt" do |platform|
gem "thin", "1.2.7", platform
end
gem "win32-api", "1.5.1", "universal-mingw32"
@@ -363,10 +363,10 @@ RSpec.describe "Resolving platform craziness" do
should_resolve_as %w[thin-1.2.7-mingw32]
end
- it "finds x64-mingw32 gems" do
- platforms "x64-mingw32"
+ it "finds x64-mingw-ucrt gems" do
+ platforms "x64-mingw-ucrt"
dep "thin"
- should_resolve_as %w[thin-1.2.7-x64-mingw32]
+ should_resolve_as %w[thin-1.2.7-x64-mingw-ucrt]
end
it "finds universal-mingw gems on x86-mingw" do
@@ -376,25 +376,21 @@ RSpec.describe "Resolving platform craziness" do
end
it "finds universal-mingw gems on x64-mingw" do
- platform "x64-mingw32"
+ platform "x64-mingw-ucrt"
dep "win32-api"
should_resolve_as %w[win32-api-1.5.1-universal-mingw32]
end
- if Gem.rubygems_version >= Gem::Version.new("3.2.28")
- it "finds x64-mingw-ucrt gems" do
- platforms "x64-mingw-ucrt"
- dep "thin"
- should_resolve_as %w[thin-1.2.7-x64-mingw-ucrt]
- end
+ it "finds x64-mingw-ucrt gems" do
+ platforms "x64-mingw-ucrt"
+ dep "thin"
+ should_resolve_as %w[thin-1.2.7-x64-mingw-ucrt]
end
- if Gem.rubygems_version >= Gem::Version.new("3.3.18")
- it "finds universal-mingw gems on x64-mingw-ucrt" do
- platform "x64-mingw-ucrt"
- dep "win32-api"
- should_resolve_as %w[win32-api-1.5.1-universal-mingw32]
- end
+ it "finds universal-mingw gems on x64-mingw-ucrt" do
+ platform "x64-mingw-ucrt"
+ dep "win32-api"
+ should_resolve_as %w[win32-api-1.5.1-universal-mingw32]
end
end