diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/bundler/bundler_spec.rb | 2 | ||||
-rw-r--r-- | spec/bundler/compact_index_client/updater_spec.rb | 2 | ||||
-rw-r--r-- | spec/bundler/dsl_spec.rb | 35 | ||||
-rw-r--r-- | spec/commands/binstubs_spec.rb | 4 | ||||
-rw-r--r-- | spec/commands/exec_spec.rb | 24 | ||||
-rw-r--r-- | spec/commands/lock_spec.rb | 2 | ||||
-rw-r--r-- | spec/commands/show_spec.rb | 2 | ||||
-rw-r--r-- | spec/install/gemfile/gemspec_spec.rb | 2 | ||||
-rw-r--r-- | spec/install/gemfile/platform_spec.rb | 4 | ||||
-rw-r--r-- | spec/install/gemfile/ruby_spec.rb | 2 | ||||
-rw-r--r-- | spec/install/gemfile/sources_spec.rb | 4 | ||||
-rw-r--r-- | spec/install/gems/resolving_spec.rb | 54 | ||||
-rw-r--r-- | spec/realworld/edgecases_spec.rb | 4 | ||||
-rw-r--r-- | spec/resolver/platform_spec.rb | 96 | ||||
-rw-r--r-- | spec/runtime/gem_tasks_spec.rb | 2 | ||||
-rw-r--r-- | spec/runtime/platform_spec.rb | 1 | ||||
-rw-r--r-- | spec/support/indexes.rb | 4 |
17 files changed, 174 insertions, 70 deletions
diff --git a/spec/bundler/bundler_spec.rb b/spec/bundler/bundler_spec.rb index 7237f644e2..56ef4ce75a 100644 --- a/spec/bundler/bundler_spec.rb +++ b/spec/bundler/bundler_spec.rb @@ -338,7 +338,7 @@ EOF end context "with unwritable files in a parent dir" do - # Regression test for https://github.com/bundler/bundler/pull/6316 + # Regression test for https://github.com/rubygems/bundler/pull/6316 # It doesn't matter if there are other unwritable files so long as # bundle_path can be created before do diff --git a/spec/bundler/compact_index_client/updater_spec.rb b/spec/bundler/compact_index_client/updater_spec.rb index fd554a7b0d..cbbfba7cb8 100644 --- a/spec/bundler/compact_index_client/updater_spec.rb +++ b/spec/bundler/compact_index_client/updater_spec.rb @@ -12,7 +12,7 @@ RSpec.describe Bundler::CompactIndexClient::Updater do subject(:updater) { described_class.new(fetcher) } context "when the ETag header is missing" do - # Regression test for https://github.com/bundler/bundler/issues/5463 + # Regression test for https://github.com/rubygems/bundler/issues/5463 let(:response) { double(:response, :body => "") } diff --git a/spec/bundler/dsl_spec.rb b/spec/bundler/dsl_spec.rb index 319472d4b0..9299c014af 100644 --- a/spec/bundler/dsl_spec.rb +++ b/spec/bundler/dsl_spec.rb @@ -174,41 +174,6 @@ RSpec.describe Bundler::Dsl do end end - describe "#gemspec" do - let(:spec) do - Gem::Specification.new do |gem| - gem.name = "example" - gem.platform = platform - end - end - - before do - allow(Dir).to receive(:[]).and_return(["spec_path"]) - allow(Bundler).to receive(:load_gemspec).with("spec_path").and_return(spec) - allow(Bundler).to receive(:default_gemfile).and_return(Pathname.new("./Gemfile")) - end - - context "with a ruby platform" do - let(:platform) { "ruby" } - - it "keeps track of the ruby platforms in the dependency" do - allow(Gem::Platform).to receive(:local).and_return(rb) - subject.gemspec - expect(subject.dependencies.last.platforms).to eq(Bundler::Dependency::REVERSE_PLATFORM_MAP[Gem::Platform::RUBY]) - end - end - - context "with a jruby platform" do - let(:platform) { "java" } - - it "keeps track of the jruby platforms in the dependency" do - allow(Gem::Platform).to receive(:local).and_return(java) - subject.gemspec - expect(subject.dependencies.last.platforms).to eq(Bundler::Dependency::REVERSE_PLATFORM_MAP[Gem::Platform::JAVA]) - end - end - end - context "can bundle groups of gems with" do # git "https://github.com/rails/rails.git" do # gem "railties" diff --git a/spec/commands/binstubs_spec.rb b/spec/commands/binstubs_spec.rb index f77e1772bb..a5e48753fb 100644 --- a/spec/commands/binstubs_spec.rb +++ b/spec/commands/binstubs_spec.rb @@ -2,7 +2,7 @@ RSpec.describe "bundle binstubs <gem>" do before do - skip "https://github.com/bundler/bundler/issues/6894" if Gem.win_platform? + skip "https://github.com/rubygems/bundler/issues/6894" if Gem.win_platform? end context "when the gem exists in the lockfile" do @@ -278,7 +278,7 @@ RSpec.describe "bundle binstubs <gem>" do end it "sets correct permissions for binstubs" do - skip "https://github.com/bundler/bundler/issues/6895" if Gem.win_platform? + skip "https://github.com/rubygems/bundler/issues/6895" if Gem.win_platform? with_umask(0o002) do install_gemfile <<-G diff --git a/spec/commands/exec_spec.rb b/spec/commands/exec_spec.rb index f27eb5ca42..17fc959baf 100644 --- a/spec/commands/exec_spec.rb +++ b/spec/commands/exec_spec.rb @@ -68,7 +68,7 @@ RSpec.describe "bundle exec" do end it "respects custom process title when loading through ruby" do - skip "https://github.com/bundler/bundler/issues/6898" if Gem.win_platform? + skip "https://github.com/rubygems/bundler/issues/6898" if Gem.win_platform? script_that_changes_its_own_title_and_checks_if_picked_up_by_ps_unix_utility = <<~'RUBY' Process.setproctitle("1-2-3-4-5-6-7-8-9-10-11-12-13-14-15") @@ -93,7 +93,7 @@ RSpec.describe "bundle exec" do end it "handles --keep-file-descriptors" do - skip "https://github.com/bundler/bundler/issues/6898" if Gem.win_platform? + skip "https://github.com/rubygems/bundler/issues/6898" if Gem.win_platform? require "tempfile" @@ -126,7 +126,7 @@ RSpec.describe "bundle exec" do end it "can run a command named --verbose" do - skip "https://github.com/bundler/bundler/issues/6898" if Gem.win_platform? + skip "https://github.com/rubygems/bundler/issues/6898" if Gem.win_platform? install_gemfile 'gem "rack"' File.open(bundled_app("--verbose"), "w") do |f| @@ -286,7 +286,7 @@ RSpec.describe "bundle exec" do end it "does not duplicate already exec'ed RUBYOPT" do - skip "https://github.com/bundler/bundler/issues/6898" if Gem.win_platform? + skip "https://github.com/rubygems/bundler/issues/6898" if Gem.win_platform? install_gemfile <<-G gem "rack" @@ -303,7 +303,7 @@ RSpec.describe "bundle exec" do end it "does not duplicate already exec'ed RUBYLIB" do - skip "https://github.com/bundler/bundler/issues/6898" if Gem.win_platform? + skip "https://github.com/rubygems/bundler/issues/6898" if Gem.win_platform? install_gemfile <<-G gem "rack" @@ -372,7 +372,7 @@ RSpec.describe "bundle exec" do each_prefix.call("exec") do |exec| describe "when #{exec} is used" do before(:each) do - skip "https://github.com/bundler/bundler/issues/6898" if Gem.win_platform? + skip "https://github.com/rubygems/bundler/issues/6898" if Gem.win_platform? install_gemfile <<-G gem "rack" @@ -587,7 +587,7 @@ RSpec.describe "bundle exec" do describe "with gems bundled for deployment" do it "works when calling bundler from another script" do - skip "https://github.com/bundler/bundler/issues/6898" if Gem.win_platform? + skip "https://github.com/rubygems/bundler/issues/6898" if Gem.win_platform? gemfile <<-G module Monkey @@ -642,7 +642,7 @@ RSpec.describe "bundle exec" do shared_examples_for "it runs" do it "like a normally executed executable" do - skip "https://github.com/bundler/bundler/issues/6898" if Gem.win_platform? + skip "https://github.com/rubygems/bundler/issues/6898" if Gem.win_platform? subject expect(exitstatus).to eq(exit_code) if exitstatus @@ -823,7 +823,7 @@ __FILE__: #{path.to_s.inspect} RUBY it "receives the signal" do - skip "https://github.com/bundler/bundler/issues/6898" if Gem.win_platform? + skip "https://github.com/rubygems/bundler/issues/6898" if Gem.win_platform? bundle!("exec #{path}") do |_, o, thr| o.gets # Consumes 'Started' and ensures that thread has started @@ -846,7 +846,7 @@ __FILE__: #{path.to_s.inspect} RUBY it "makes sure no unexpected signals are restored to DEFAULT" do - skip "https://github.com/bundler/bundler/issues/6898" if Gem.win_platform? + skip "https://github.com/rubygems/bundler/issues/6898" if Gem.win_platform? test_signals.each do |n| Signal.trap(n, "IGNORE") @@ -872,7 +872,7 @@ __FILE__: #{path.to_s.inspect} end it "correctly shells out", :ruby_repo do - skip "https://github.com/bundler/bundler/issues/6898" if Gem.win_platform? + skip "https://github.com/rubygems/bundler/issues/6898" if Gem.win_platform? file = bundled_app("file_that_bundle_execs.rb") create_file(file, <<-RB) @@ -890,7 +890,7 @@ __FILE__: #{path.to_s.inspect} let(:expected) { ruby "gem 'openssl', '< 999999'; require 'openssl'; puts OpenSSL::VERSION", :artifice => nil } it "only leaves the default gem in the stdlib available" do - skip "https://github.com/bundler/bundler/issues/6898" if Gem.win_platform? + skip "https://github.com/rubygems/bundler/issues/6898" if Gem.win_platform? skip "openssl isn't a default gem" if expected.empty? install_gemfile! "" # must happen before installing the broken system gem diff --git a/spec/commands/lock_spec.rb b/spec/commands/lock_spec.rb index ceafeb1d7b..ad8f1d6f32 100644 --- a/spec/commands/lock_spec.rb +++ b/spec/commands/lock_spec.rb @@ -251,7 +251,7 @@ RSpec.describe "bundle lock" do expect(err).to include("Removing all platforms from the bundle is not allowed") end - # from https://github.com/bundler/bundler/issues/4896 + # from https://github.com/rubygems/bundler/issues/4896 it "properly adds platforms when platform requirements come from different dependencies" do build_repo4 do build_gem "ffi", "1.9.14" diff --git a/spec/commands/show_spec.rb b/spec/commands/show_spec.rb index 7b329c8e7f..5dd800e7c4 100644 --- a/spec/commands/show_spec.rb +++ b/spec/commands/show_spec.rb @@ -192,7 +192,7 @@ RSpec.describe "bundle show", :bundler => "< 3" do end context "--outdated option" do - # Regression test for https://github.com/bundler/bundler/issues/5375 + # Regression test for https://github.com/rubygems/bundler/issues/5375 before do build_repo2 end diff --git a/spec/install/gemfile/gemspec_spec.rb b/spec/install/gemfile/gemspec_spec.rb index bf1b84cf28..b28d70a798 100644 --- a/spec/install/gemfile/gemspec_spec.rb +++ b/spec/install/gemfile/gemspec_spec.rb @@ -199,7 +199,7 @@ RSpec.describe "bundle install from an existing gemspec" do it "allows the gemspec to activate other gems" do ENV["BUNDLE_PATH__SYSTEM"] = "true" - # see https://github.com/bundler/bundler/issues/5409 + # see https://github.com/rubygems/bundler/issues/5409 # # issue was caused by rubygems having an unresolved gem during a require, # so emulate that diff --git a/spec/install/gemfile/platform_spec.rb b/spec/install/gemfile/platform_spec.rb index eab5e7f00c..52e1cf86fa 100644 --- a/spec/install/gemfile/platform_spec.rb +++ b/spec/install/gemfile/platform_spec.rb @@ -379,8 +379,6 @@ RSpec.describe "bundle install with platform conditionals" do end it "prints a helpful warning when a dependency is unused on any platform" do - skip "prints warning but bundle install fails" if Gem.win_platform? - simulate_platform "ruby" simulate_ruby_engine "ruby" @@ -401,8 +399,6 @@ The dependency #{Gem::Dependency.new("rack", ">= 0")} will be unused by any of t before { bundle! "config set disable_platform_warnings true" } it "does not print the warning when a dependency is unused on any platform" do - skip "skips warning but bundle install fails" if Gem.win_platform? - simulate_platform "ruby" simulate_ruby_engine "ruby" diff --git a/spec/install/gemfile/ruby_spec.rb b/spec/install/gemfile/ruby_spec.rb index d6ac4e3827..aab269b325 100644 --- a/spec/install/gemfile/ruby_spec.rb +++ b/spec/install/gemfile/ruby_spec.rb @@ -5,7 +5,7 @@ RSpec.describe "ruby requirement" do Bundler::RubyVersion.from_string(Bundler::LockfileParser.new(File.read(bundled_app_lock)).ruby_version) end - # As discovered by https://github.com/bundler/bundler/issues/4147, there is + # As discovered by https://github.com/rubygems/bundler/issues/4147, there is # no test coverage to ensure that adding a gem is possible with a ruby # requirement. This test verifies the fix, committed in bfbad5c5. it "allows adding gems" do diff --git a/spec/install/gemfile/sources_spec.rb b/spec/install/gemfile/sources_spec.rb index 61943ef2e5..8b52833ba1 100644 --- a/spec/install/gemfile/sources_spec.rb +++ b/spec/install/gemfile/sources_spec.rb @@ -285,7 +285,7 @@ RSpec.describe "bundle install with gems on multiple sources" do expect(err).not_to include("Warning: the gem 'rack' was found in multiple sources.") expect(the_bundle).to include_gems("depends_on_rack 1.0.1", "rack 1.0.0") - # In https://github.com/bundler/bundler/issues/3585 this failed + # In https://github.com/rubygems/bundler/issues/3585 this failed # when there is already a lock file, and the gems are missing, so try again system_gems [] bundle :install @@ -426,7 +426,7 @@ RSpec.describe "bundle install with gems on multiple sources" do G end - # Reproduction of https://github.com/bundler/bundler/issues/3298 + # Reproduction of https://github.com/rubygems/bundler/issues/3298 it "does not unlock the installed gem on exec" do expect(the_bundle).to include_gems("rack 0.9.1") end diff --git a/spec/install/gems/resolving_spec.rb b/spec/install/gems/resolving_spec.rb index 523f9eb151..323b28fdb1 100644 --- a/spec/install/gems/resolving_spec.rb +++ b/spec/install/gems/resolving_spec.rb @@ -69,6 +69,20 @@ RSpec.describe "bundle install with install-time dependencies" do expect(the_bundle).to include_gems "net_a 1.0", "net_b 1.0", "net_c 1.0", "net_d 1.0", "net_e 1.0" end + context "with ENV['BUNDLER_DEBUG_RESOLVER'] set" do + it "produces debug output" do + gemfile <<-G + source "#{file_uri_for(gem_repo1)}" + gem "net_c" + gem "net_e" + G + + bundle :install, :env => { "BUNDLER_DEBUG_RESOLVER" => "1" } + + expect(err).to include("Creating possibility state for net_c") + end + end + context "with ENV['DEBUG_RESOLVER'] set" do it "produces debug output" do gemfile <<-G @@ -143,6 +157,31 @@ RSpec.describe "bundle install with install-time dependencies" do expect(out).to_not include("rack-9001.0.0 requires ruby version > 9000") expect(the_bundle).to include_gems("rack 1.2") end + + it "installs the older not platform specific version" do + build_repo4 do + build_gem "rack", "9001.0.0" do |s| + s.required_ruby_version = "> 9000" + end + build_gem "rack", "1.2" do |s| + s.platform = mingw + s.required_ruby_version = "> 9000" + end + build_gem "rack", "1.2" + end + + simulate_platform mingw do + install_gemfile <<-G, :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s } + ruby "#{RUBY_VERSION}" + source "http://localgemserver.test/" + gem 'rack' + G + end + + expect(out).to_not include("rack-9001.0.0 requires ruby version > 9000") + expect(out).to_not include("rack-1.2-#{Bundler.local_platform} requires ruby version > 9000") + expect(the_bundle).to include_gems("rack 1.2") + end end context "allows no gems" do @@ -156,6 +195,13 @@ RSpec.describe "bundle install with install-time dependencies" do let(:ruby_requirement) { %("#{RUBY_VERSION}") } let(:error_message_requirement) { "~> #{RUBY_VERSION}.0" } + let(:error_message_platform) do + if Bundler.feature_flag.specific_platform? + " #{Bundler.local_platform}" + else + "" + end + end shared_examples_for "ruby version conflicts" do it "raises an error during resolution" do @@ -172,9 +218,9 @@ RSpec.describe "bundle install with install-time dependencies" do nice_error = strip_whitespace(<<-E).strip Bundler found conflicting requirements for the Ruby\0 version: In Gemfile: - Ruby\0 (#{error_message_requirement}) + Ruby\0 (#{error_message_requirement})#{error_message_platform} - require_ruby was resolved to 1.0, which depends on + require_ruby#{error_message_platform} was resolved to 1.0, which depends on Ruby\0 (> 9000) Ruby\0 (> 9000), which is required by gem 'require_ruby', is not available in the local ruby installation @@ -187,7 +233,7 @@ RSpec.describe "bundle install with install-time dependencies" do describe "with a < requirement" do let(:ruby_requirement) { %("< 5000") } - let(:error_message_requirement) { "< 5000" } + let(:error_message_requirement) { Gem::Requirement.new(["< 5000", "= #{RUBY_VERSION}.#{RUBY_PATCHLEVEL}"]).to_s } it_behaves_like "ruby version conflicts" end @@ -195,7 +241,7 @@ RSpec.describe "bundle install with install-time dependencies" do describe "with a compound requirement" do let(:reqs) { ["> 0.1", "< 5000"] } let(:ruby_requirement) { reqs.map(&:dump).join(", ") } - let(:error_message_requirement) { Gem::Requirement.new(reqs).to_s } + let(:error_message_requirement) { Gem::Requirement.new(reqs + ["= #{RUBY_VERSION}.#{RUBY_PATCHLEVEL}"]).to_s } it_behaves_like "ruby version conflicts" end diff --git a/spec/realworld/edgecases_spec.rb b/spec/realworld/edgecases_spec.rb index a91e6a359e..48c37093b5 100644 --- a/spec/realworld/edgecases_spec.rb +++ b/spec/realworld/edgecases_spec.rb @@ -62,7 +62,7 @@ RSpec.describe "real world edgecases", :realworld => true, :sometimes => true do end it "is able to update a top-level dependency when there is a conflict on a shared transitive child" do - # from https://github.com/bundler/bundler/issues/5031 + # from https://github.com/rubygems/bundler/issues/5031 gemfile <<-G source "https://rubygems.org" @@ -194,7 +194,7 @@ RSpec.describe "real world edgecases", :realworld => true, :sometimes => true do expect(lockfile).to include(rubygems_version("paperclip", "~> 5.1.0")) end - # https://github.com/bundler/bundler/issues/1500 + # https://github.com/rubygems/bundler/issues/1500 it "does not fail install because of gem plugins" do realworld_system_gems("open_gem --version 1.4.2", "rake --version 0.9.2") gemfile <<-G diff --git a/spec/resolver/platform_spec.rb b/spec/resolver/platform_spec.rb index fee0cf1f1c..415c5458df 100644 --- a/spec/resolver/platform_spec.rb +++ b/spec/resolver/platform_spec.rb @@ -28,6 +28,98 @@ RSpec.describe "Resolving platform craziness" do end end + 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.1.0" + end + dep "foo" + platforms "x64-mingw32" + + should_resolve_as %w[foo-1.1.0] + end + + it "takes the ruby version if the platform version is incompatible" do + @index = build_index do + gem "bar", "1.0.0" + gem "foo", "1.0.0" + gem "foo", "1.0.0", "x64-mingw32" do + dep "bar", "< 1" + end + end + dep "foo" + platforms "x64-mingw32" + + should_resolve_as %w[foo-1.0.0] + end + + 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" + end + dep "foo" + platforms "x64-mingw32" + + should_resolve_as %w[foo-1.0.0-x64-mingw32] + end + + it "takes the latest ruby gem 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.1.0" + gem "foo", "1.1.0", "x64-mingw32" 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" + + should_resolve_as %w[foo-1.1.0] + end + + 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.1.0" do |s| + s.required_ruby_version = [">= 2.0"] + end + gem "foo", "1.1.0", "x64-mingw32" 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" + + should_resolve_as %w[foo-1.1.0] + end + + 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.1.0" do |s| + s.required_ruby_version = [">= 2.0"] + end + gem "foo", "1.1.0", "x64-mingw32" 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" + + should_resolve_as %w[foo-1.1.0] + end + describe "with mingw32" do before :each do @index = build_index do @@ -90,11 +182,11 @@ RSpec.describe "Resolving platform craziness" do end end - it "reports on the conflict" do + it "takes the ruby version as fallback" do platforms "ruby", "java" dep "foo" - should_conflict_on "baz" + should_resolve_as %w[bar-1.0.0 baz-1.0.0 foo-1.0.0] end end end diff --git a/spec/runtime/gem_tasks_spec.rb b/spec/runtime/gem_tasks_spec.rb index 4fe9d43e73..d219556a4b 100644 --- a/spec/runtime/gem_tasks_spec.rb +++ b/spec/runtime/gem_tasks_spec.rb @@ -60,7 +60,7 @@ RSpec.describe "require 'bundler/gem_tasks'" do context "rake build when path has spaces" do before do spaced_bundled_app = tmp.join("bundled app") - FileUtils.mv bundled_app, spaced_bundled_app + FileUtils.cp_r bundled_app, spaced_bundled_app bundle! "exec rake build", :dir => spaced_bundled_app end diff --git a/spec/runtime/platform_spec.rb b/spec/runtime/platform_spec.rb index ad9c56d14e..70c7594395 100644 --- a/spec/runtime/platform_spec.rb +++ b/spec/runtime/platform_spec.rb @@ -113,6 +113,7 @@ RSpec.describe "Bundler.setup with multi platform stuff" do bundle! "install" expect(the_bundle).to include_gems "platform_specific 1.0 RUBY" + expect(the_bundle).to not_include_gems "nokogiri" end end diff --git a/spec/support/indexes.rb b/spec/support/indexes.rb index dc6e0bd1e9..7440523fc9 100644 --- a/spec/support/indexes.rb +++ b/spec/support/indexes.rb @@ -26,6 +26,10 @@ module Spec end end source_requirements ||= {} + args[0] ||= [] # base + args[1] ||= Bundler::GemVersionPromoter.new # gem_version_promoter + args[2] ||= [] # additional_base_requirements + args[3] ||= @platforms # platforms Bundler::Resolver.resolve(deps, @index, source_requirements, *args) end |