diff options
author | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2020-12-08 16:36:29 +0900 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2020-12-08 17:30:02 +0900 |
commit | 473f9d2df0ddd7fdb5cc73fa3ad49b2f19f22b06 (patch) | |
tree | 6b39312502d32474da0157f5d55620fabd6454ea /spec/bundler/install/gems | |
parent | 4aca77edde91f826aa243e268bf1ef5214530583 (diff) |
Merge prepare version of Bundler 2.2.0
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3864
Diffstat (limited to 'spec/bundler/install/gems')
-rw-r--r-- | spec/bundler/install/gems/compact_index_spec.rb | 69 | ||||
-rw-r--r-- | spec/bundler/install/gems/dependency_api_spec.rb | 20 | ||||
-rw-r--r-- | spec/bundler/install/gems/flex_spec.rb | 3 | ||||
-rw-r--r-- | spec/bundler/install/gems/fund_spec.rb | 37 | ||||
-rw-r--r-- | spec/bundler/install/gems/resolving_spec.rb | 63 |
5 files changed, 131 insertions, 61 deletions
diff --git a/spec/bundler/install/gems/compact_index_spec.rb b/spec/bundler/install/gems/compact_index_spec.rb index 5ef3f38fe7..b5fca9c6ad 100644 --- a/spec/bundler/install/gems/compact_index_spec.rb +++ b/spec/bundler/install/gems/compact_index_spec.rb @@ -138,19 +138,6 @@ RSpec.describe "compact index api" do expect(the_bundle).to include_gems("foo 1.0") end - it "falls back when the API errors out" do - simulate_platform mswin - - gemfile <<-G - source "#{source_uri}" - gem "rcov" - G - - bundle :install, :artifice => "windows" - expect(out).to include("Fetching source index from #{source_uri}") - expect(the_bundle).to include_gems "rcov 1.0.0" - end - it "falls back when the API URL returns 403 Forbidden" do gemfile <<-G source "#{source_uri}" @@ -258,14 +245,37 @@ The checksum of /versions does not match the checksum provided by the server! So end it "does not double check for gems that are only installed locally" do - system_gems %w[rack-1.0.0 thin-1.0 net_a-1.0] + build_repo2 do + build_gem "net_a" do |s| + s.add_dependency "net_b" + s.add_dependency "net_build_extensions" + end + + build_gem "net_b" + + build_gem "net_build_extensions" do |s| + s.add_dependency "rake" + s.extensions << "Rakefile" + s.write "Rakefile", <<-RUBY + task :default do + path = File.expand_path("../lib", __FILE__) + FileUtils.mkdir_p(path) + File.open("\#{path}/net_build_extensions.rb", "w") do |f| + f.puts "NET_BUILD_EXTENSIONS = 'YES'" + end + end + RUBY + end + end + + system_gems %w[rack-1.0.0 thin-1.0 net_a-1.0], :gem_repo => gem_repo2 bundle "config set --local path.system true" ENV["BUNDLER_SPEC_ALL_REQUESTS"] = strip_whitespace(<<-EOS).strip #{source_uri}/versions #{source_uri}/info/rack EOS - install_gemfile <<-G, :artifice => "compact_index", :verbose => true + install_gemfile <<-G, :artifice => "compact_index", :verbose => true, :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo2.to_s } source "#{source_uri}" gem "rack" G @@ -499,13 +509,19 @@ The checksum of /versions does not match the checksum provided by the server! So end it "does not refetch if the only unmet dependency is bundler" do + build_repo2 do + build_gem "bundler_dep" do |s| + s.add_dependency "bundler" + end + end + gemfile <<-G source "#{source_uri}" gem "bundler_dep" G - bundle :install, :artifice => "compact_index" + bundle :install, :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo2.to_s } expect(out).to include("Fetching gem metadata from #{source_uri}") end @@ -598,27 +614,6 @@ The checksum of /versions does not match the checksum provided by the server! So expect(the_bundle).to include_gems "rack 1.0.0" end - it "strips http basic authentication creds for modern index" do - gemfile <<-G - source "#{basic_auth_source_uri}" - gem "rack" - G - - bundle :install, :artifice => "endopint_marshal_fail_basic_authentication" - expect(out).not_to include("#{user}:#{password}") - expect(the_bundle).to include_gems "rack 1.0.0" - end - - it "strips http basic auth creds when it can't reach the server" do - gemfile <<-G - source "#{basic_auth_source_uri}" - gem "rack" - G - - bundle :install, :artifice => "endpoint_500", :raise_on_error => false - expect(out).not_to include("#{user}:#{password}") - end - it "strips http basic auth creds when warning about ambiguous sources", :bundler => "< 3" do gemfile <<-G source "#{basic_auth_source_uri}" diff --git a/spec/bundler/install/gems/dependency_api_spec.rb b/spec/bundler/install/gems/dependency_api_spec.rb index e92669e97c..5e0be89995 100644 --- a/spec/bundler/install/gems/dependency_api_spec.rb +++ b/spec/bundler/install/gems/dependency_api_spec.rb @@ -121,12 +121,20 @@ RSpec.describe "gemcutter's dependency API" do it "falls back when the API errors out" do simulate_platform mswin + build_repo2 do + # The rcov gem is platform mswin32, but has no arch + build_gem "rcov" do |s| + s.platform = Gem::Platform.new([nil, "mswin32", nil]) + s.write "lib/rcov.rb", "RCOV = '1.0.0'" + end + end + gemfile <<-G source "#{source_uri}" gem "rcov" G - bundle :install, :artifice => "windows" + bundle :install, :artifice => "windows", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo2.to_s } expect(out).to include("Fetching source index from #{source_uri}") expect(the_bundle).to include_gems "rcov 1.0.0" end @@ -473,13 +481,19 @@ RSpec.describe "gemcutter's dependency API" do end it "does not refetch if the only unmet dependency is bundler" do + build_repo2 do + build_gem "bundler_dep" do |s| + s.add_dependency "bundler" + end + end + gemfile <<-G source "#{source_uri}" gem "bundler_dep" G - bundle :install, :artifice => "endpoint" + bundle :install, :artifice => "endpoint", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo2.to_s } expect(out).to include("Fetching gem metadata from #{source_uri}") end @@ -578,7 +592,7 @@ RSpec.describe "gemcutter's dependency API" do gem "rack" G - bundle :install, :artifice => "endopint_marshal_fail_basic_authentication" + bundle :install, :artifice => "endpoint_marshal_fail_basic_authentication" expect(out).not_to include("#{user}:#{password}") expect(the_bundle).to include_gems "rack 1.0.0" end diff --git a/spec/bundler/install/gems/flex_spec.rb b/spec/bundler/install/gems/flex_spec.rb index 858c40c07c..7ab0ded26d 100644 --- a/spec/bundler/install/gems/flex_spec.rb +++ b/spec/bundler/install/gems/flex_spec.rb @@ -166,8 +166,7 @@ RSpec.describe "bundle flex_install" do expect(the_bundle).to include_gems "rack_middleware 1.0", "rack 0.9.1" - build_repo2 - update_repo2 do + build_repo2 do build_gem "rack-obama", "2.0" do |s| s.add_dependency "rack", "=1.2" end diff --git a/spec/bundler/install/gems/fund_spec.rb b/spec/bundler/install/gems/fund_spec.rb index 57e7c3aed3..f521b0296f 100644 --- a/spec/bundler/install/gems/fund_spec.rb +++ b/spec/bundler/install/gems/fund_spec.rb @@ -2,11 +2,38 @@ RSpec.describe "bundle install" do context "with gem sources" do + before do + build_repo2 do + build_gem "has_funding_and_other_metadata" do |s| + s.metadata = { + "bug_tracker_uri" => "https://example.com/user/bestgemever/issues", + "changelog_uri" => "https://example.com/user/bestgemever/CHANGELOG.md", + "documentation_uri" => "https://www.example.info/gems/bestgemever/0.0.1", + "homepage_uri" => "https://bestgemever.example.io", + "mailing_list_uri" => "https://groups.example.com/bestgemever", + "funding_uri" => "https://example.com/has_funding_and_other_metadata/funding", + "source_code_uri" => "https://example.com/user/bestgemever", + "wiki_uri" => "https://example.com/user/bestgemever/wiki", + } + end + + build_gem "has_funding", "1.2.3" do |s| + s.metadata = { + "funding_uri" => "https://example.com/has_funding/funding", + } + end + + build_gem "gem_with_dependent_funding", "1.0" do |s| + s.add_dependency "has_funding" + end + end + end + context "when gems include a fund URI" do it "displays the plural fund message after installing" do install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}" - gem 'has_metadata' + source "#{file_uri_for(gem_repo2)}" + gem 'has_funding_and_other_metadata' gem 'has_funding' gem 'rack-obama' G @@ -16,7 +43,7 @@ RSpec.describe "bundle install" do it "displays the singular fund message after installing" do install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}" + source "#{file_uri_for(gem_repo2)}" gem 'has_funding' gem 'rack-obama' G @@ -28,7 +55,7 @@ RSpec.describe "bundle install" do context "when gems do not include fund messages" do it "does not display any fund messages" do install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}" + source "#{file_uri_for(gem_repo2)}" gem "activesupport" G @@ -39,7 +66,7 @@ RSpec.describe "bundle install" do context "when a dependency includes a fund message" do it "does not display the fund message" do install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}" + source "#{file_uri_for(gem_repo2)}" gem 'gem_with_dependent_funding' G diff --git a/spec/bundler/install/gems/resolving_spec.rb b/spec/bundler/install/gems/resolving_spec.rb index f621b01366..1c01ce588b 100644 --- a/spec/bundler/install/gems/resolving_spec.rb +++ b/spec/bundler/install/gems/resolving_spec.rb @@ -1,9 +1,46 @@ # frozen_string_literal: true RSpec.describe "bundle install with install-time dependencies" do + before do + build_repo2 do + # Test complicated gem dependencies for install + build_gem "net_a" do |s| + s.add_dependency "net_b" + s.add_dependency "net_build_extensions" + end + + build_gem "net_b" + + build_gem "net_build_extensions" do |s| + s.add_dependency "rake" + s.extensions << "Rakefile" + s.write "Rakefile", <<-RUBY + task :default do + path = File.expand_path("../lib", __FILE__) + FileUtils.mkdir_p(path) + File.open("\#{path}/net_build_extensions.rb", "w") do |f| + f.puts "NET_BUILD_EXTENSIONS = 'YES'" + end + end + RUBY + end + + build_gem "net_c" do |s| + s.add_dependency "net_a" + s.add_dependency "net_d" + end + + build_gem "net_d" + + build_gem "net_e" do |s| + s.add_dependency "net_d" + end + end + end + it "installs gems with implicit rake dependencies" do install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}" + source "#{file_uri_for(gem_repo2)}" gem "with_implicit_rake_dep" gem "another_implicit_rake_dep" gem "rake" @@ -43,7 +80,7 @@ RSpec.describe "bundle install with install-time dependencies" do describe "with crazy rubygem plugin stuff" do it "installs plugins" do install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}" + source "#{file_uri_for(gem_repo2)}" gem "net_b" G @@ -52,7 +89,7 @@ RSpec.describe "bundle install with install-time dependencies" do it "installs plugins depended on by other plugins" do install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}" + source "#{file_uri_for(gem_repo2)}" gem "net_a" G @@ -61,7 +98,7 @@ RSpec.describe "bundle install with install-time dependencies" do it "installs multiple levels of dependencies" do install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}" + source "#{file_uri_for(gem_repo2)}" gem "net_c" gem "net_e" G @@ -72,7 +109,7 @@ RSpec.describe "bundle install with install-time dependencies" do context "with ENV['BUNDLER_DEBUG_RESOLVER'] set" do it "produces debug output" do gemfile <<-G - source "#{file_uri_for(gem_repo1)}" + source "#{file_uri_for(gem_repo2)}" gem "net_c" gem "net_e" G @@ -86,7 +123,7 @@ RSpec.describe "bundle install with install-time dependencies" do context "with ENV['DEBUG_RESOLVER'] set" do it "produces debug output" do gemfile <<-G - source "#{file_uri_for(gem_repo1)}" + source "#{file_uri_for(gem_repo2)}" gem "net_c" gem "net_e" G @@ -100,7 +137,7 @@ RSpec.describe "bundle install with install-time dependencies" do context "with ENV['DEBUG_RESOLVER_TREE'] set" do it "produces debug output" do gemfile <<-G - source "#{file_uri_for(gem_repo1)}" + source "#{file_uri_for(gem_repo2)}" gem "net_c" gem "net_e" G @@ -126,6 +163,10 @@ RSpec.describe "bundle install with install-time dependencies" do it "installs the older version" do build_repo2 do + build_gem "rack", "1.2" do |s| + s.executables = "rackup" + end + build_gem "rack", "9001.0.0" do |s| s.required_ruby_version = "> 9000" end @@ -198,13 +239,7 @@ 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 + let(:error_message_platform) { " #{Bundler.local_platform}" } shared_examples_for "ruby version conflicts" do it "raises an error during resolution" do |